我正在使用此代码在ios 6上播放视频(在Xcode和设备模拟器中)
- (void) playMovie {
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"flying" ofType:@"m4v"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[moviePlayerController prepareToPlay];
[moviePlayerController.view setFrame: self.view.bounds];
[self.view addSubview:moviePlayerController.view];
moviePlayerController.scalingMode = MPMovieScalingModeAspectFit;
moviePlayerController.movieSourceType = MPMovieSourceTypeFile;
[moviePlayerController play];
}
播放开始,但视频在5秒后中止。它只是消失了,我看到一个黑色的窗口,Xcode中没有错误信息。
任何线索? 感谢
答案 0 :(得分:0)
MPMoviePlayerController变量在5秒后被释放。我在实现级别引入了变量声明,并在playMovie方法中引入了定义。现在它有效!