我正在iPad上播放一部电影。如果我只是加载一个mp4文件,播放器不会自动启动 - 但是使用示例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;
}
答案 0 :(得分:0)
在这里你可以做[moviePlayer pause];而不是[moviePlayer停止];并删除行[moviePlayer prepareToPlay];从代码,它将工作。如果有任何问题,请告诉我。