Search code examples
iosobjective-cmpmovieplayercontroller

Why does MPMoviePlayerController stutter when first playing?


After making some simple changes to an app, the MPMoviePlayerController has begun stuttering when playing videos. The problem only happens about 10% of the time, and so far I haven't discovered any repeatable pattern. The stutter just happens at the beginning: the video starts, and then after about a second, it restarts. That's it.

Here's my setup code, as called from viewDidLoad:

self.moviePlayerController=[[MPMoviePlayerController alloc] initWithContentURL:videoURL];    
[self.moviePlayerController setControlStyle:MPMovieControlStyleNone];
[self.moviePlayerController setShouldAutoplay:NO];
[self.moviePlayerController prepareToPlay];
[self.moviePlayerController.view setAlpha:0];
[self.moviePlayerController.backgroundView setBackgroundColor:[UIColor whiteColor]];

And then when the user taps a big play button:

[self.moviePlayerController play];

I've combed through all the code many times, setup up many NSLogs and breakpoints, and don't appear any closer to solving the problem. Why has this started happening? Has anyone else had this issue with MPMoviePlayerController? Thanks for reading.


Solution

  • I ended up swapping out MPMoviePlayerController for AVPlayerViewController. Pretty straight-forward to do, and the stutter is now gone.