2012-12-15 108 views
0

我使用此代码回放上IOS 6的视频(在Xcode和设备仿真器)IOS问题具有视频播放

- (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

MPMoviePlayerController变量在5秒后被释放。我在实现级别引入了变量声明,并在playMovie方法中引入了定义。现在它工作了!