Domanda

I'm creating an app that supports playing hls files (.m3u8) on a Mac OS environment, and I've just found out that AVFoundation is only available for Mac OS 10.7 onwards.

So, I've been left with QTKit.

Apple's documentation on HLS says that HLS can be played on Mac OS using AVFoundation and QTKit frameworks. (Well, they used the word 'AND'... and I'm hoping QTKit alone can play m3u8 files --- since QuickTime X player plays them well)

Anyways, I've tweaked Apple's MyMediaPlayer sample code to accomodate .m3u8 files. (Sample code can be seen here: http://developer.apple.com/library/mac/#samplecode/MyMediaPlayer/Introduction/Intro.html#//apple_ref/doc/uid/DTS40009203)

and here's the QTMovie initWithAttributes code snippet:

NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys: 
                       absoluteURL, QTMovieURLAttribute, 
                       [NSNumber numberWithBool:YES], QTMovieOpenForPlaybackAttribute ,
                       [NSNumber numberWithBool:YES], QTMovieOpenAsyncRequiredAttribute,
                       [NSNumber numberWithBool:YES], QTMovieOpenAsyncOKAttribute,                           
                       nil]; 

[self willChangeValueForKey:@"movie"];
mMovie = [[QTMovie alloc] initWithAttributes:attrs error:outError];
[self didChangeValueForKey:@"movie"];

What I'm trying to play is this:

prog_index.m3u8 --> which I made using MediaFileSegmenter of Apple.

Please tell me if QTKit framework alone can play HLS files. And if it can, what am I doing wrong?

È stato utile?

Soluzione

Ok, I've just found out that I've been accessing m3u8 files located locally in my directories. Since this is HLS, one needs to have an http server for serving the playlist files.

My previous absoluteURL is file://localhost/Users/guest/Desktop/Music/stream01/index.m3u8

QTKit works after putting up my own server and, changing the path of the playlist files to: http://192.168.0.XX/stream01/index.m3u8

QTKit (adopted to Quick Time X Player) can:

  1. play .m3u8 files (provided they are served by an http server)

  2. play AES-128 encrypted .ts/.aac/.mp3 files in .m3u8 (video and audio)

It finally works! YEY!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top