所以我创建了一个视图,里面有一个可以播放电影的按钮。
以下是该按钮的操作:
- (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]
任何想法是什么?
由于
答案 0 :(得分:4)
您需要设置播放器的界限,并将播放器的视图添加到self.view:
[theMovie.view setFrame: self.view.bounds]; // player's frame must match parent's
[self.view addSubview: theMovie.view];