MPMoviePlayerViewController无法播放IOS 8.4的视频 [英] MPMoviePlayerViewController not playing videos for IOS 8.4
本文介绍了MPMoviePlayerViewController无法播放IOS 8.4的视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的视频在IOS 8.3和更早的版本上播放良好.但是,在最近更新了IOS 8.4 Video Player之后,它停止了工作.视频无法播放,并立即转到MPMoviePlaybackComplete:方法.
My videos are playing well for IOS 8.3 and earlier versions. But after a recent update of IOS 8.4 Video Player stopped working. Videos are not getting played and immediately it's going to MPMoviePlaybackComplete: method.
Here is my code :
self.player = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];
[self.player.moviePlayer setFullscreen:YES animated:YES];
if(subtitlesPathStr){
[self.player.moviePlayer openSRTFileAtPath:subtitlesPathStr
completion:^(BOOL finished) {
// Activate subtitles
[self.player.moviePlayer showSubtitles];
[self.navigationController presentMoviePlayerViewControllerAnimated:self.player];
} failure:^(NSError *error) {
NSLog(@"Error: %@", error.description);
}
];
}else [self.navigationController presentMoviePlayerViewControllerAnimated:self.player];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(MPMoviePlayerLoadStateDidChange:)
name:MPMoviePlayerLoadStateDidChangeNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(MPMoviePlayerDidEnterFullscreenNotification:)
name:MPMoviePlayerDidEnterFullscreenNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(MPMoviePlaybackComplete:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
有人可以告诉我如何解决这个问题吗?
Can somebody tell me how to solve this issue ?
推荐答案
根据播放时间和playableduration添加重置的视频方法.
Add your reset video method based on playbacktime and playableduration.
- (void)playbackDidFinish:(NSNotification*)aNotification {
MPMoviePlayerController *moviePlayer = aNotification.object;
NSNumber *reason = [aNotification.userInfo objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];
if ([reason intValue] == MPMovieFinishReasonPlaybackEnded) {
if (moviePlayer.currentPlaybackTime == moviePlayer.playableDuration) {
[moviePlayer stop];
}
}
}
这篇关于MPMoviePlayerViewController无法播放IOS 8.4的视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文