iOS 7 MPMoviePlayerController寻找前进按钮将视频带到结束并显示黑屏

iOS 7 MPMoviePlayerController寻找前进按钮将视频带到结束并显示黑屏,第1张

概述我在iOS 7中面临MPMoviePlayerController的问题.我进入全屏,然后在寻找前进按钮(>> |)上单击(只需点一下),视频播放结束,并给出一个带有文本“加载“标题. 我注册了“MPMoviePlayerPlaybackStateDidChangeNotification”的通知. **[[NSNotificationCenter defaultCenter] addObserv 我在iOS 7中面临MPMovIEPlayerController的问题.我进入全屏,然后在寻找前进按钮(>> |)上单击(只需点一下),视频播放结束,并给出一个带有文本“加载“标题.

我注册了“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寻找前进按钮将视频带到结束并显示黑屏所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1111381.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存