2
votes

I embedded a MPMoviePlayerController on my mail view. I can play/pause the movie and seek forward/backward. But when I touch the "fullscreen button" the movie stops and the playback state is set to MPMoviePlaybackStateStopped... Should the movie be played in full screen?

Here is my code:

MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:videoUrl];

player.shouldAutoplay = NO;
player.movieSourceType = MPMovieSourceTypeFile;
player.controlStyle = MPMovieControlStyleEmbedded;
player.allowsAirPlay = YES;

player.view.frame = CGRectMake(xPos, yPos, width, height);

[self.view addSubview:player.view];
2

2 Answers

0
votes

I found my bug: when pressing the full screen toggle button in MPMoviePlayerController's view, the method "viewWillLayoutSubviews" is invoked. I could never imagine this behavior...

I hope my experience can be useful to other developers.

0
votes

Remember that any containing ViewController will have its viewWillDisappear, viewDidDisappear methods invoked when the MPMoviePlayerController goes full screen. Also, viewWillAppear and viewWillDisappear get called when it comes back from full screen.

If you have any logic in there that affects video playback behavior, it'll get called unless you use some conditional logic to see if the video is still playing.