喜的我有一個奇怪的行爲具有的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