iOS 7 MPMoviePlayerController搜索转发按钮将视频带到结束并显示黑屏 [英] iOS 7 MPMoviePlayerController seek forward button brings the video to the End and displays Black screen
问题描述
我在iOS 7中遇到MPMoviePlayerController的问题。我进入全屏,然后在搜索转发按钮(>> |)上单击(只需点击一下),视频播放结束并给出带有文本的黑屏标题上的正在加载。
I am facing an issue with MPMoviePlayerController in iOS 7. I enter the fullscreen and then click (just a single tap) on seek forward button (>>|) , and the video playback ends and gives a black screen with a text "Loading" on the header.
我注册了 MPMoviePlayerPlaybackStateDidChangeNotification 的通知。
**[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerPlaybackStateDidChange:)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:self.player];**
它不会被解雇单击向前搜索按钮。
It does not get fired on a single click of seek forward button.
同时注册 MPMoviePlayerPlaybackDidFinishNotification
**[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerPlaybackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];**
我得到 MPMovieFinishReasonPlay backEnded 事件在单击向前搜索按钮时触发。
任何人都知道原因吗?这是苹果中的一个错误吗?
I get "MPMovieFinishReasonPlaybackEnded" event fired on that single click of seek forward button. Any one knows the reason why? Is this a bug in apple?
我需要停止这种在单击时显示黑屏的行为,或者只是禁用单击向前搜索按钮以便不显示任何内容发生。
I need to either stop this behavior of showing a black screen on single click , or just disable single click of seek forward button so that nothing happens.
任何人都知道如何实现这个目标吗?
Any one knows how to achieve this?
推荐答案
单击快进或快退按钮时,将调用MPMoviePlayerLoadStateDidChangeNotification。你应该检查一下loadState,然后再给它一个你的视频和prepareToPlay的路径。
MPMoviePlayerLoadStateDidChangeNotification will be called when you single tap on the fast-forward or rewind button. You should check the loadState and just give it the path to your video and prepareToPlay again.
- (void)moviePlayerLoadStateChanged:(NSNotification *)notification {
MPMoviePlayerController *moviePlayer = notification.object;
MPMovieLoadState loadState = moviePlayer.loadState;
if(loadState == MPMovieLoadStateUnknown) {
moviePlayer.contentURL = [NSURL fileURLWithPath:videoPath]
[moviePlayer prepareToPlay];
}
.....
}
这篇关于iOS 7 MPMoviePlayerController搜索转发按钮将视频带到结束并显示黑屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!