我一直试图在iOS 4.1中运行我的应用中的视频,但没有成功。各地的材料都为iOS 3.2提供代码,但不提供更高版本的代码。请帮助,我将不胜感激。这是我的代码:
-(IBAction)pressButton:(id)sender {
NSString *urlString =
[NSString stringWithFormat:@"http://www.itc.virginia.edu/network/videotest/when-sm.mov"];
MPMoviePlayerController *moviePlayer =
[[MPMoviePlayerController alloc]initWithContentURL:urlString];
moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
[moviePlayer play];
MPMoviePlayerViewController *movieViewPlayer =
[[MPMoviePlayerViewController alloc]initWithContentURL:urlString];
[self presentMoviePlayerViewControllerAnimated:movieViewPlayer];
}
答案 0 :(得分:2)
字符串不会自动将自身转换为URL,您必须这样做
NSURL *urlString =
[NSURL URLWithString:@"http://www.itc.virginia.edu/network/videotest/when-sm.mov"];
还有一个moviePlayerViewController包含一个moviePlayer,因此您不需要一个单独的
MPMoviePlayerViewController *movieViewPlayer =
[[MPMoviePlayerViewController alloc]initWithContentURL:urlString];
[self presentMoviePlayerViewControllerAnimated:movieViewPlayer];
就是所需要的。
答案 1 :(得分:1)
你可以通过传递url.by默认它在快速tym电影播放器中打开来简单地在webview中播放那个视频 感谢