我正在使用此代码播放来自苹果网站的视频流
- (IBAction)playMovie:(UIButton *)sender {
NSLog(@"start playing");
//NSURL *url = [NSURL URLWithString:@"http://spatie.be/test.mov"];
NSURL *url = [NSURL URLWithString:@"http://stream.qtv.apple.com/events/mar/123pibhargjknawdconwecown/12oihbqeorvfhbpiubqnfv3_650_ref.mov"];
moviePlayer = [[MPMoviePlayerController alloc]
initWithContentURL:url];
[[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];
}
- (void) moviePlayBackDidFinish:(NSNotification*)notification {
NSError *error = [[notification userInfo] objectForKey:@"error"];
if (error) {
NSLog(@"Did finish with error: %@", error);
}
MPMoviePlayerController *player = [notification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
if ([player
respondsToSelector:@selector(setFullscreen:animated:)])
{
[player.view removeFromSuperview];
}
}
调用playMovie时,立即调用moviePlayBackDidFinish
并记录错误消息:
完成错误:错误Domain = MediaPlayerErrorDomain Code = -11800 “操作无法完成”UserInfo = 0x78d25d0 {NSLocalizedDescription =无法完成操作}
如何解决此错误?
答案 0 :(得分:1)
您没有将此标记为iOS,但MPMoviePlayer仅限iOS。这应该适用于将在iOS上播放的视频。不幸的是,您尝试播放的视频与iOS不兼容。试试这个网址:
http://stream.qtv.apple.com/events/mar/123pibhargjknawdconwecown/12oihbqeorvfhbpiubqnfv3_ipad_vod_ref.mov