我使用此代码在 iphone 中播放视频
-(IBAction)btnNew_clicked:(id)sender {
NSURL *url = [NSURL URLWithString:@"http://www.businessfactors.de/bfcms/images/stories/videos/defaultscreenvideos.mp4"];
MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[[mp moviePlayer] prepareToPlay];
[[mp moviePlayer] setShouldAutoplay:YES];
[[mp moviePlayer] setControlStyle:2];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoPlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
[self presentMoviePlayerViewControllerAnimated:mp];}
-(void)videoPlayBackDidFinish:(NSNotification*)notification {
[self dismissMoviePlayerViewControllerAnimated]; }
通过使用此代码,电影播放器会打开 1 秒钟,然后自动关闭,而不播放文件。
我检查了视频文件,它是正确的,但它没有在 iphone sdk 4.0 中播放。
提前致谢。