Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prevent MPMoviePlayerController from automatically playing in iOS 4.2.1

Tags:

ios

ipad

ios4

I have an MPMoviePlayerController where I load a video from a URL. In iOS 3.2.2 the video started downloading when I added it to a view, but it didn't play until I hit the play button (which is what I want). However, since iOS 4.2.1 came out, it started behaving differently; the video starts downloading and plays automatically.

Here's how I load my MPMoviePlayerController:

MPMoviePlayerController *player = [[MPMoviePlayerController alloc]
    initWithContentURL:[NSURL URLWithString:theVideo.fileUrl]];
player.view.frame = articleVideoFrame;

[mainView addSubview:player.view];

I even tried to perform a [player pause]; after the addSubview part, but it still plays automatically. Could you guys help me with this one?

like image 344
The WebMacheter Avatar asked Nov 27 '10 23:11

The WebMacheter


2 Answers

Got it! I used player.shouldAutoplay = NO; and that did the trick. Documentation says it is by default YES, which explains it all. Probably in 3.2 default was NO, but has been switched in 4.2.

like image 75
The WebMacheter Avatar answered Oct 24 '22 07:10

The WebMacheter


I have noticed some other behavior changes in video playback in 4.2.1...namely the video player does not become visible until it starts receiving the data for the movie...

In the previous versions it used to come up instantaneously with "Loading movie..." text on top.

Sometimes, the player gets stuck in when not in full screen mode, with no Done button available or not responding to touches on Pause and Zoom...

I am having other more subtle issues with the playback but I can't isolate the issue just yet...

like image 45
Moonwalker Avatar answered Oct 24 '22 08:10

Moonwalker