Ipad MPMoviePlayerController在流媒体播放时自动播放-如何停止?
我正在iPad上播放一部电影。如果我只是加载一个mp4文件,播放器不会自动启动——但在示例m3u8中,它坚持自动启动。有人遇到过这种情况吗?我做错什么了吗Ipad MPMoviePlayerController在流媒体播放时自动播放-如何停止?,ipad,streaming,mpmovieplayercontroller,autoplay,Ipad,Streaming,Mpmovieplayercontroller,Autoplay,我正在iPad上播放一部电影。如果我只是加载一个mp4文件,播放器不会自动启动——但在示例m3u8中,它坚持自动启动。有人遇到过这种情况吗?我做错什么了吗 - (id)initWithVideo:(VideoDO*)video frame:(CGRect)rect { NSURL* videoURL = [NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"]; //
- (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;
}
在这里你可以做[电影播放器暂停];而不是[电影播放器停止];并删除行[moviePlayer prepareToPlay];从代码,它将工作。如果有任何问题,请告诉我。似乎就是这样-对于流式视频,“shoulldautoplay”没有任何效果。解决方案可能是首先加载视频缩略图,然后在用户单击缩略图后开始流媒体;而不是[电影播放器停止];并删除行[moviePlayer prepareToPlay];从代码,它将工作。如果有任何问题,请告诉我。