开发者

prevent MPMoviePlayerController from automatically playing in iOS 4.2.1

开发者 https://www.devze.com 2023-01-27 01:10 出处:网络
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 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 ou开发者_StackOverflow中文版t, 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?


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消