无法在iOS 4中播放视频 [英] unable to play video in iOS 4
本文介绍了无法在iOS 4中播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已编写代码在iPhone OS 3.1.3中播放视频,视频播放正常。
I have written code to play video in iPhone OS 3.1.3 and video is playing fine.
但是当我尝试使用相同代码播放视频时视频无法在iOS 4中播放。
but when i am trying to play video with the same code then video is not playing in iOS 4.
我知道iOS 4的媒体播放器框架已更改。有没有办法在不准备单独的操作系统上播放视频二进制??
I know that Media player framework is changed for iOS 4. Is there any way i can play the video on different OS without preparing separate binary??
推荐答案
首先检查您是否在OS 3.2或更高版本。如果是,请以新方式创建电影播放器:
First check if you are on OS 3.2 or above. If yes, create a movie player the new way:
if (NSClassFromString(@"UISplitViewController") != nil) {
MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc] initWithContentURL:yourURL];
[[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];
} else {
moviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:yourURL];
[self playMovieTheOldWay:moviePlayer];
}
您可以关闭这样的新电影播放器:
You can close the new movie player like this:
-(void)videoPlayBackDidFinish:(NSNotification*)notification
{
[self dismissMoviePlayerViewControllerAnimated];
}
这篇关于无法在iOS 4中播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文