2012-12-15 111 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方法中引入了定義。現在它工作了!