UIWebView 电影播放器​​被解雇 iOS 6 错误 [英] UIWebView Movie Player getting dismissed iOS 6 bug

查看:31
本文介绍了UIWebView 电影播放器​​被解雇 iOS 6 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在 UIWebView 中启动要播放的视频(通过 YouTube)时,视频会打开,然后调试器会说:

When I try to initiate a video to play (via YouTube) in a UIWebView, the video opens, then the debugger says:

[MPAVController] Autoplay: Enabling autoplay
[MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 0, on player: 1)

这是一个类似的问题:MPMoviePlayerController 几秒钟后停止播放

我唯一的问题是,对于 UIWebView,我无法将 MPMoviePlayerController 设置为 prepareToPlay.至少据我所知不是.如果有人可以帮助解决这个问题,那就太棒了!

My only problem is that with a UIWebView, I can't set up an MPMoviePlayerController to prepareToPlay. At least not as far as my knowledge goes. If anyone can help fix this problem, that would be amazing!

推荐答案

我在iOS 6中也遇到过类似的问题,这是因为在iOS6以外的版本播放YouTube视频时viewWillDisappear 方法没有被调用.但在 iOS6 中,每次播放 YouTube 视频时都会调用此方法.这可能是操作系统级别的错误,但我不确定.

I have also faced a similar problem in iOS 6. The reason behind this is that when YouTube video is played in another than iOS6 version viewWillDisappear method is not called up. But in iOS6 this method is called up every time whenever a YouTube video is played. It may be an OS level bug but I am not sure about it.

不过,我已经修好了,步骤如下.

However, I have fixed it and the steps are as below.

添加全屏进入和退出通知,使用布尔属性并相应更新.

Add full-screen entry and exit notification, use a Boolean property, and updates it accordingly.

// Notification when the player moves to full screen

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeVideofullScreen:) name:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];

// Notification when the player exit from full screen.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeVideoExit:) name:@"UIMoviePlayerControllerDidExitFullscreenNotification" object:nil];

 - (void)youTubeVideofullScreen:(id)sender {
      //Update flag.
      isFullscreen = TRUE;
 }

 - (void)youTubeVideoExit:(id)sender {
        //Update flag.
        isFullscreen = FALSE;
  }

 - (void)viewWillDisappear:(BOOL)animated {
    //Now you can use that flag and avoid the code execution which is interrupting the video
    
      if(!isFullscreen) {
       [super viewWillDisappear:animated]; 

       }
  }

希望对你有帮助.

这篇关于UIWebView 电影播放器​​被解雇 iOS 6 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆