2010-08-03 76 views
4

我在iPad上播放电影。如果我只是加载一个mp4文件,播放器不会自动启动 - 但以m3u8为例,它坚持自动启动。有没有人遇到过这个?难道我做错了什么?MPMoviePlayerController在流式传输时自动播放 - 我如何阻止它?

- (id)initWithVideo:(VideoDO*)video frame:(CGRect)rect { 
NSURL* videoURL = [NSURL  URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"]; // With this URL, player starts automatically 
self.moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL]; 

moviePlayer.shouldAutoplay = NO; 
moviePlayer.controlStyle = MPMovieControlStyleEmbedded; 
moviePlayer.view.frame = rect; 
moviePlayer.view.backgroundColor = [UIColor blackColor]; 
[moviePlayer prepareToPlay]; 

self.view = moviePlayer.view; 
[moviePlayer stop]; 

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer]; 
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieChangedLoadState:) name:MPMoviePlayerLoadStateDidChangeNotification object:moviePlayer]; 


return self; 
} 
+0

看来这只是它的方式 - 对于流式视频,“shouldAutoplay”不起作用。该解决方案可能首先加载视频缩略图,然后在用户单击缩略图后开始流式传输。 – Matz 2010-08-09 09:52:39

+0

在这里你可以做[moviePlayer pause];而不是[moviePlayer停止];并删除该行[moviePlayer prepareToPlay];从代码,它会工作。让我知道是否有问题。 – AppAspect 2011-06-20 17:53:08

回答

0

在这里你可以做[moviePlayer pause];而不是[moviePlayer停止];并删除该行[moviePlayer prepareToPlay];从代码,它会工作。让我知道是否有问题。

相关问题