I have some code that sets up an MPMoviePlayerController to play back a video stored in the app.
I follow the example code in Apple's documentation. However, the video plays even if I don't call -play on it as long as I have called -prepareToPlay.
NSURL *movieURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:_videoName ofType:@"mp4"]];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
[player setMovieSourceType:MPMovieSourceTypeFile];
[player setScalingMode:MPMovieScalingModeAspectFit];
[[player view] setFrame:[[self view] bounds]];
[[self view] addSubview:[player view]];
[player prepareToPlay];
//[player play];
Will play the video. I uncomment the -play and the same thing happens. It does not matter if I have -play in or not. And I had -prepareToPlay earlier in the code as well (before the view setup) and it did not make a difference.
This is on iOS8 of some sort. I have not tried other versions of iOS.
Why does it work like this? The Apple docs make it sound like it should not play until -play is called.
Try adding this line of code
player.shouldAutoplay = NO;
By default it is set to YES.