Search code examples
iosmpmovieplayercontrollerfullscreen

MPMoviePlayerController stops and resets the movie when user tries to play fullscreen [iOS]


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

Solution

  • 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.