0

i am using this code to playback a video on ios 6 (in Xcode and device simulator)

- (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];
}

playback starts, but the video aborts after 5 seconds. It simply disappears and i see a black window and no error messages in Xcode.

any clues? Thanks

user1089363
  • 673
  • 1
  • 6
  • 8

1 Answers1

0

The MPMoviePlayerController variable is being released after 5 seconds. I introduced the variable declaration at the implementation level and the definition in the playMovie method. Now it works!

user1089363
  • 673
  • 1
  • 6
  • 8