喜的我有一个奇怪的行为具有的MPMoviePlayerController的MPMoviePlayerController只能玩一次,第三次,第五次......等等
赔率时间我打它的工作原理视频.. 。没有!
这里说MPMoviePlayerController will play once, then throw an error问题可能是URL,但我不能够找到一个解决办法..
这里是我的代码
NSURL *myUrl = [[NSURL alloc] initWithString:CDNRequest];
moviecontroller = [[MMRMovieViewController alloc] initWithContentURL:myUrl];
[[moviecontroller moviePlayer] setScalingMode:MPMovieScalingModeAspectFit];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playbackFinished:)
name:MPMoviePlayerPlaybackDidFinishNotification object:[moviecontroller moviePlayer]];
[self moviecontroller];
MMRMovieViewController是刚刚延伸的视图控制器MPMoviePlayerViewController。 这里是playbackFinished方法
- (void)playbackFinished:(NSNotification*)notification {
MPMoviePlayerController *moviePlayer = [notification object];
NSNumber* reason = [[notification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];
switch ([reason intValue]) {
case MPMovieFinishReasonPlaybackEnded:
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
NSLog(@"playback ended");
break;
case MPMovieFinishReasonPlaybackError:
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
NSLog(@"playback error");
NSError* error = [[notification userInfo] valueForKey:@"error"];
NSLog(@"error=%@", error);
break;
case MPMovieFinishReasonUserExited:
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
NSLog(@"user exited");
break;
default:
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
break;
}
if (moviePlayer == TRUE) {
[moviePlayer setFullscreen:NO animated:YES];
}
[moviePlayer stop];
[moviePlayer removeFromSuperview];
moviePlayer = nil;
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}
错误日志说: “RROR = ”错误域= MediaPlayerErrorDomain代码= -12847 \“。这部电影格式不支持\” 的UserInfo = {0x5b60030 = NSLocalizedDescription这部电影不支持的格式。}” 但有时它去!所以它不可能是这个原因!
任何帮助表示赞赏!
谢谢!
设置断点/ NSLog语句并打印出CDNRequest的值。有可能无论你用什么逻辑来设置CDNRequest变量,都会在每隔一段时间将其设置为一个错误的值。 – jmstone617 2012-04-01 23:19:21
播放视频的格式..! – Dinesh 2012-04-02 05:18:54
这是它看起来像CDNRequest值的方式:http://cdnselector.xuniplay.fdnames.com/getCDN.aspx?streamid=293655&redirect=true当视频不播放时,NSLog也会打印此值。格式应该是m3u8 – Janky 2012-04-02 08:16:44