every one. I'm trying to figure out how to play live stream using MPMoviePlayerController. For testing i'm using Apples test stream sample http://devimages.apple.com/iphone/samples/bipbopall.html. It's perfectly working in UIWebView, but i can't make it work with MPMoviePlayerController. There is my piece of code:
NSURL *mediaURL = [NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbopall.html"];
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:mediaURL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
[mp setControlStyle:MPMovieControlStyleFullscreen];
[mp setMovieSourceType:MPMovieSourceTypeStreaming];
[mp setFullscreen:YES];
[self.view addSubview:[mp view]];
[mp prepareToPlay];
[mp play];
Actually the controller recieves MPMoviePlayerPlaybackDidFinishNotification without playing anything. Where is the problem?
@Andrew:
Here is Apple documentation of HTTP Live Streaming including sample code http://developer.apple.com/library/ios/search/index.php?Search=HTTP+Live+Streaming+Overview
Dung.
You should use direct link to play list file: http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8
Your problem is probably with the URL.
MPMoviePlayerController
wants the URL directly to the file you want to play. You are providing the URL for anHTML
page which the movie player doesn't understand. That is why it does work inUIWebView
since a web browser understandsHTML
. If you want more information about what's wrong you can check the error doing the following, quoted from Apple's documentation:It would look something like:
If you want to try and play that sample you can try and access the URL for the stream directly, which would be: http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8
Try
object:mp
instead ofobject:nil
in yourNSNotification