我想在MPMoviePlayerController中播放来自网址的直播视频。我得到了在UIWebView上播放视频的链接。 UIWebView在启动MPMoviePlayerController时提供输出,如NSLog。并且它没有任何问题地播放流!
setting movie path:
http://ibbtks.noc.com.tr/ibbesm/bagdat2lq.stream/playlist.m3u8?k=ffd81df8cfee8f9259eff91dc9a483c4
我从NSLog获得了该视频网址,并将其放入MPMoviePlayerController中。这是我用过的代码,
- (void)playMovie
{
NSURL* myUrl = [NSURL URLWithString:@"http://ibbtks.noc.com.tr/ibbesm/kadikoylq.stream/playlist.m3u8"];
NSURL* appleUrl = [NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/gear4/prog_index.m3u8"];
_moviePlayer = [[MPMoviePlayerController alloc]
initWithContentURL:myUrl];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:_moviePlayer];
_moviePlayer.controlStyle = MPMovieControlStyleDefault;
_moviePlayer.shouldAutoplay = YES;
_moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
[self.view addSubview:_moviePlayer.view];
[_moviePlayer setFullscreen:YES animated:YES];
}
它播放appleUrl流没有问题,但是当我尝试播放myUrl时,它总是加载并且它会出错。错误输出是,
Did finish with error: Error Domain=MediaPlayerErrorDomain Code=-11800 "The operation could not be completed" UserInfo=0x99a9760 {NSLocalizedDescription=The operation could not be completed}
当我尝试在UIWebView或Safari上播放此链接时,它会成功播放视频,正如我所说,它为我提供了我使用的NSLog网址。但是当我尝试自己玩这个网址时,我收到了一个错误。有什么建议吗?
提前致谢。