MPMoviePlayerController searches in full screen until the end gets stuck

It seems that the problem is with MPMoviePlayerController when you are in full screen mode and you hold the fast forward button, allowing it to move forward (playing at high speed) until the end of the video.

After that, you just get a black screen and are stuck. In other words, he does not respond to any taps of the taps, and you cannot get out of this situation. Has anyone else encountered this problem?

Is there any way around it in code?

+6
source share
4 answers

This seems to be an iOS bug, since a quick rollback to the very beginning will not lead to a black screen, but will speed it up to the end, and after that the call "play" / "pause" to the video player will never work. I temporarily fixed this by adding secure logic to the scrubber update callback: suppose that monitorPlaybackTime will be called during the "PLAY_BACK_TIME_MONITOR_INTERVAL" period to update the scrubber, and in it I add the verification logic:

NSTimeInterval duration = self.moviePlayer.duration; NSTimeInterval current = self.moviePlayer.currentPlaybackTime; if (isnan(current) || current > duration) { current = duration; } else if (self.moviePlayer.playbackState == MPMoviePlaybackStateSeekingForward) { if (current + self.moviePlayer.currentPlaybackRate*PLAY_BACK_TIME_MONITOR_INTERVAL > duration) { [self.moviePlayer endSeeking]; } } 

A workaround for solving the black screen, and not perfect, hope it can help.

+1
source

I assume that you are not processing MPMoviePlayerPlaybackDidFinishNotification . You really must, if it is not.

And yet, it was unexpected for me that the movie player would go into a β€œstuck” state, as you describe. I would readily expect it to stop playing automatically and reset when it reaches the end. Anyway, I think your problem will go away if you notice MPMoviePlayerPlaybackDidFinishNotification and process the movie controller accordingly.

0
source

Go to the same issue on iOS6. I managed to fix it by registering for MPMoviePlayerPlaybackDidFinishNotification (as suggested by Leuguimerius) with the following implementation:

 - (void)playbackDidFisnish:(NSNotification *)notif { if (self.player.currentPlaybackTime <= 0.1) { dispatch_async(dispatch_get_main_queue(), ^{ [self.player stop]; [self.player play]; [self.player pause]; }); } } 

Where self.player is the associated instance of MPMoviePlayerController. The check against currentPlaybackTime serves to distinguish the more standard DidFinish playback calls (where the movie is allowed to play at normal speed to the very end) from those scenarios where the user quickly progresses to the end. Stop, then play and pause the results in a convenient, visually consistent interface, even with fast transfer to the end.

0
source

None of the above solutions worked for me, so here is what I did:

 NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("moviePlayerLoadStateDidChange"), name: MPMoviePlayerLoadStateDidChangeNotification, object: nil) func moviePlayerLoadStateDidChange() { let loadState = moviePlayerController?.loadState if loadState == MPMovieLoadState.Unknown { moviePlayerController?.contentURL = currentmovieURL moviePlayerController?.prepareToPlay() } } 

I think the problem is that when the foraward search button is pressed, it wants to go to the next video, so the download indicator appears. By listening to the download status change event, you can specify what should be for the next video, and if you don’t have one, you can just give it the same URL.

0
source

Source: https://habr.com/ru/post/894540/


All Articles