MPMoviePlayer standard playback mode for play / pause

One of my components makes heavy use of MPMoviePlayerController and recently showed a strange error; when using the standard user interface (for example, MPMoviePlayerController.controlStyle = MPMovieControlStyleFullscreen; ) the player never changes the state of the play / pause button (this is really in the middle of my screenshot).

enter image description here

The functionality remains intact, but the state of the player is not reflected in the user interface.

When you raise the controls by tapping the screen during movie playback, I see the play symbol. What I expect will be a pause symbol when the player is playing at the moment. When you click on the play symbol, the player goes into pause mode. The symbol, however, does not change. When you click this play symbol again, the player continues to play, as expected.

The problem was introduced with iOS5 and did not occur in previous versions of iOS.

To check for iOS5 problems, I created a minimalist player who does not use my own framework, and, of course, the problem did not arise, so this should be my code causing this quirk. Unfortunately, my code is pretty damn big (about 3k lines), so I can't post it here.

I know that someone can answer this question without source code, rather subtle, as it seems to be directly related to my code. Being desperate as I am at the moment, I just took a chance and hope for a little surprise, someone actually had such a problem and he knows how to call / delete it.

+2
source share
2 answers

Well, it looks like I found the answer (and what I would call an iOS5 error) ...

The reason that MPMoviePlayerController annoyed the status of the play button was just the order of my initialization code.

To run this problem all you have to do is run this code;

 moviePlayer = [[MPMoviePlayerController alloc] init]; moviePlayer.shouldAutoplay = YES; moviePlayer.fullscreen = NO; moviePlayer.view.frame = self.view.bounds; moviePlayer.currentPlaybackTime = 0.0; moviePlayer.initialPlaybackTime = 0.0; [moviePlayer setContentURL:[NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"]]; [self.view addSubview:moviePlayer.view]; 

You will see the player’s user interface, which will not change his Pay / Pause status.

To work correctly again, you need to move the setContentURL call before setting the play time.

 moviePlayer = [[MPMoviePlayerController alloc] init]; moviePlayer.shouldAutoplay = YES; moviePlayer.fullscreen = NO; moviePlayer.view.frame = self.view.bounds; [moviePlayer setContentURL:[NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"]]; moviePlayer.currentPlaybackTime = 0.0; moviePlayer.initialPlaybackTime = 0.0; [self.view addSubview:moviePlayer.view]; 

I sent an error to Apple (Radar Bug ID # 10484668) - will keep you posted on the answer.

OpenRadar Bug Report

+1
source

I also often saw this behavior, but, unfortunately, I simply switched the order of the calls to setContentURL, and setting the start and playback time did not matter.

I found that I was wrong. I set the play time to -1 to indicate the start of the stream when I was supposed to indicate zero. Changing this fixed the problem for me.

+1
source

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


All Articles