UIWebView Movie Player getting dismissed iOS 6 bug

2019-02-04 02:56发布

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)

Here's a similar question: MPMoviePlayerController stops playing after a few seconds

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!

2条回答
淡お忘
2楼-- · 2019-02-04 03:28

I just had this very same issue in one of our apps. Turns out we were setting the UIWebView's HTML to an empty string in -(void)viewWillDisappear. Apparently this method is now being called in iOS 6 when displaying a fullscreen video from an UIWebView, so that's probably where your issue comes from.

查看更多
淡お忘
3楼-- · 2019-02-04 03:48

I have Faced The Same Problem in ios6 .Reason is that in below iOS6 when youTube Video Played. viewWillDisappear method did not call .But in iOS6 this methods called every time whenever YouTube video Play .It may be a bug ,i don't know at this time.

I have fixed the Same As Below.

Set The Notification for FullScreen Entry And Exit Notification ,SO that you could set Some Flag Value For Avoiding the Execution of SOme Piece of code.

// 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];
 }

I am Sure It'll be helpful to you.

查看更多
登录 后发表回答