-(void)playVideo:(NSURL *)url{
if (videoPlayer) {
[videoPlayer release];
videoPlayer = nil;
}
videoPlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
url = nil;
videoPlayer.moviePlayer.controlStyle=MPMovieControlStyleFullscreen;
videoPlayer.view.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
videoPlayer.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
videoPlayer.view.backgroundColor = [UIColor blackColor];
[[UIApplication sharedApplication]
setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO];
[videoPlayer.moviePlayer prepareToPlay];
videoPlayer.moviePlayer.shouldAutoplay = YES;
videoPlayer.hidesBottomBarWhenPushed = YES;
self.navigationController.navigationBarHidden=NO;
videoPlayer.navigationItem.hidesBackButton = YES;
[self.navigationController pushViewController:videoPlayer animated:YES];
[self addObservers];
}
任何人都可以說這個代碼有什麼問題嗎?該網址是流式HTTP鏈接。視頻播放器正在出現,但過了一段時間它消失了。它是工作在3G網絡,但沒有wifi的MPMoviePlayerViewController不在iPod和iPhone
您是否只開發4.0及以上版本? – shannoga 2011-03-27 10:55:39
是的,它適用於4.o及以上..有趣的因素是3G網絡中的視頻播放,但Wi-Fi無法播放。 – Raj 2011-03-27 11:05:10