MPMoviePlayerController seek forward in fullscreen mode until end is stuck

前端 未结 4 2067
无人共我
无人共我 2021-01-18 10:52

There seems to be a problem with the MPMoviePlayerController where once you\'re in fullscreen mode and you hold down the fast forward button, letting it seek forward (playin

4条回答
  •  梦谈多话
    2021-01-18 11:16

    It seems it's an iOS bug since fast backward to the very beginning won't cause the black screen but fast forward to the end will, and after that the 'play'/'pause' call to the video player never works. I temporarily fix this by adding protected logic into the scrubber refresh callback: let's assume that monitorPlaybackTime will be called in 'PLAY_BACK_TIME_MONITOR_INTERVAL' seconds period to refresh the scrubber, and in it I add a check 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 to solve the black screen, not perfect, hope it can help.

提交回复
热议问题