当我尝试启动一个视频播放(通过YouTube)在一个 UIWebView, ,视频打开,然后调试器说:

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

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

我唯一的问题是 UIWebView, ,我不能设置一个 MPMoviePlayerControllerprepareToPlay.至少就我所知,不是这样。如果有人可以帮助解决这个问题,那将是惊人的!

有帮助吗?

解决方案

我在ios6中遇到过同样的问题。原因是,在低于ios6时youTube视频播放。viewWillDisappear方法没有调用。但在iOS6中,每当YouTube视频播放时都会调用这个方法。这可能是一个bug,我不知道在这个时候。

我已经修复了如下所示。

设置全屏进入和退出通知的通知,以便您可以设置一些标志值,以避免执行某些代码。

// For FullSCreen Entry 

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

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


- (void)youTubeVideofullScreen:(id)sender
   {   //Set Flag True.
      isFullscreen = TRUE;

   }

- (void)youTubeVideoExit:(id)sender
 {
      //Set Flag False.
     isFullscreen = FALSE;
 }


-(void)viewWillDisappear:(BOOL)animated{
   //Just Check If Flag is TRUE Then Avoid The Execution of Code which Intrupting the Video Playing.
 if(!isFullscreen)
   //here avoid the thing which you want. genrally you were stopping the Video when you will leave the This Video view.
   [super viewWillDisappear:animated];
 }

我相信这对你会有帮助的。

其他提示

我刚刚在我们的一个应用程序中遇到了同样的问题。原来我们在设置 UIWebView将HTML转换为空字符串 -(void)viewWillDisappear.显然,这个方法现在在iOS6中被调用,当从一个 UIWebView, ,所以这可能是你的问题来自哪里。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top