0
我在iphone通过使用此代码的电影播放器打开1秒钟,然后自动关闭,没有播放文件播放的视频通过使用此代码如何在iPhone SDK 4.0中播放视频?
-(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]; }
。
我检查了视频文件是正确的,但它不是在iphone SDK 4.0中播放。
在此先感谢。
这个职位显示如何在WebView中播放视频文件我的问题是改变。请提供足够的建议。 – Apekshit 2011-02-25 06:06:36
@安德森 - 它在我的测试项目中工作,尝试更新的答案! – 2011-02-25 06:29:07
您的代码在我的设备中无法使用。你能不能把你的测试项目以zip格式发给我,所以我可以在我的设备上测试它。目前我正在使用ios 4.0上的iphone 3gs。感谢您提供建议。 – Apekshit 2011-02-25 07:01:35