所以我创建了一个 View ,其中有一个可以播放电影的按钮。
这是该按钮的操作:
- (IBAction)playMovie {
NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"sample_iPod" ofType:@"m4v"];
NSURL *movieURL = [NSURL fileURLWithPath:moviePath];
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
theMovie.scalingMode = MPMovieScalingModeAspectFill;
[theMovie play];
}
然而,当我测试应用程序并尝试播放视频时,屏幕保持空白,并且在日志中显示如下:
[切换到进程9333线程0x13c03]
知道怎么回事吗?
谢谢
最佳答案
需要设置播放器的bounds,并将播放器的 View 添加到self.view:
[theMovie.view setFrame: self.view.bounds]; // player's frame must match parent's
[self.view addSubview: theMovie.view];
关于ios - 如何在 iOS 上播放电影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9089075/