【发布时间】:2010-11-19 00:00:33
【问题描述】:
我正在尝试在 UIView 中播放视频,所以我的第一步是为该视图添加一个类并开始使用以下代码在其中播放电影:
- (IBAction)movie:(id)sender{
NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"Movie" ofType:@"m4v"];
NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain];
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
theMovie.scalingMode = MPMovieScalingModeAspectFill;
[theMovie play];
}
但这只会在应用程序自己的类中使用此方法时崩溃,但在其他地方很好。有谁知道如何在视图中播放视频?并避免它全屏显示?
【问题讨论】:
-
将各种解决方案放在一个地方使用 iOS 4.2 播放视频codevelle.wordpress.com/2011/01/07/videoplayer-for-ios-4-2
标签: ios objective-c media-player mpmovieplayer