我试图在UIView中播放视频,因此我的第一步是为该视图添加一个类,并使用以下代码开始在其中播放电影:
-(iAction)电影:(id)发件人{
NSBundle*bundle=[NSBundle mainBundle];
NSString*moviePath=[bundle pathForResource:@“Movie”类型:@“m4v”];
NSURL*movieURL=[[NSURL fileURLWithPath:moviePath]retain];
MPMoviePlayerController*theMovie=[[MPMoviePlayerController alloc]initWithContentURL:movieURL];
movie.scalingMode=MPMovieScalingModeAspectFill;
[电影剧];
}
但当在自己的类中使用此方法时,这只会使应用程序崩溃,但在其他地方也可以。有人知道如何在视图中播放视频吗?避免全屏播放
从3.2 SDK开始,您可以访问MPMoviePlayerController的view属性,修改其框架并将其添加到视图层次结构中
MPMoviePlayerController*player=[[MPMoviePlayerController alloc]initWithContentURL:[NSURL fileURLWithPath:url]];
player.view.frame=CGRectMake(184200400300);
[self.view addSubview:player.view];
[玩家游戏];
这里有一个例子:http://www.devx.com/wireless/Article/44642/1954