我注册了“MPMovIEPlayerPlaybackStateDIDChangeNotification”的通知.
**[[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(movIEPlayerPlaybackStateDIDChange:) name:MPMovIEPlayerPlaybackStateDIDChangeNotification object:self.player];**
只需点击一下寻找前进按钮就不会被解雇.
还注册了“MPMovIEPlayerPlaybackDIDFinishNotification”
**[[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(movIEPlayerPlaybackDIDFinish:) name:MPMovIEPlayerPlaybackDIDFinishNotification object:nil];**
我获得“MPMovIEFinishReasonPlaybackEnded”事件触发了单击寻找前进按钮.
任何人都知道为什么?这是苹果的错误吗?
我需要停止这种单击时显示黑色屏幕的行为,或者只是禁用单击“寻找前进”按钮,这样就不会发生任何事情.
任何人都知道如何实现这一点?
解决方法 我通过完全删除MPMovIEPlayer对象来修复此问题,将其设置为nil,将其从超级视图中删除,并使用原始视频Url重新添加.代码如下:- (voID)addplayerForUrl:(NSURL *)url { self.player = [[MPMovIEPlayerController alloc] initWithContentURL:url]; self.player.vIEw.frame = self.vIDeoVIEw.bounds; self.player.vIEw.autoresizingMask = UIVIEwautoresizingFlexibleWIDth | UIVIEwautoresizingFlexibleHeight; self.player.controlStyle = MPMovIEControlStyleDefault; [self.vIDeoVIEw insertSubvIEw:self.player.vIEw atIndex:0]; [[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(movIEPlayerLoadStateDIDChangednotification:) name:MPMovIEPlayerReadyFordisplayDIDChangeNotification object:self.player]; [[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(movIEPlayerPlaybackStateDIDChangeNotification:) name:MPMovIEPlayerPlaybackStateDIDChangeNotification object:self.player];}#pragma mark - Notifications- (voID)movIEPlayerLoadStateDIDChangednotification:(NSNotification *)notification { self.isVIDeoPreloaded = YES; self.vIDeoPlaybutton.hIDden = YES; self.photoImageVIEw.hIDden = YES; self.vIDeoloadingImageVIEw.hIDden = YES;}- (voID)movIEPlayerPlaybackStateDIDChangeNotification:(NSNotification *)notification { NSURL *url = self.player.contentURL; switch (self.player.playbackState) { case MPMovIEPlaybackStateSeekingBackward: case MPMovIEPlaybackStateSeekingForward: break; case MPMovIEPlaybackStatePlaying: self.vIDeoPlaybutton.hIDden = YES; if (!self.isVIDeoPreloaded) { self.vIDeoloadingImageVIEw.hIDden = NO; [self.vIDeoloadingImageVIEw startAnimating]; } else { self.vIDeoloadingImageVIEw.hIDden = YES; } break; case MPMovIEPlaybackStatePaused: case MPMovIEPlaybackStateStopped: self.vIDeoPlaybutton.hIDden = NO; self.vIDeoloadingImageVIEw.hIDden = YES; [self.player endSeeking]; [self.player.vIEw removeFromSupervIEw]; [self.player setFullscreen:NO]; self.player = nil; [self addplayerForUrl:url]; break; default: break; } }
注意我如何保持NSURL,就在movIEPlayerPlaybackStateDIDChangeNotification中的switch语句之前.这样,我可以重新初始化并重新添加MPMovIEPlayer对象.
Btw,我的mpmovIEplayer是在tablevIEwCell,如果你想知道.希望这有帮助,让我知道如果你有问题.祝你好运!
总结以上是内存溢出为你收集整理的iOS 7 MPMoviePlayerController寻找前进按钮将视频带到结束并显示黑屏全部内容,希望文章能够帮你解决iOS 7 MPMoviePlayerController寻找前进按钮将视频带到结束并显示黑屏所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)