4

我正在 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;
} 
4

1 回答 1

0

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

于 2011-06-20T18:12:02.833 回答