Domanda

I'm using this code to try and play a video. However the video is never played, the call back is never made to say it's finished. I can't see anything that I'm missing or have where it shouldn't be. I've checked the path and that's fine. The video playback view does appear. It just doesn't play at that point.

Any suggestions?

NSURL *movieURL = [[NSBundle mainBundle] URLForResource:@"IntroMovie" withExtension:@"mov"];

NSLog(@"%@", movieURL);

MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController];

[moviePlayerController prepareToPlay];

[moviePlayerController.view setFrame:self.view.bounds];
[self.view addSubview:moviePlayerController.view];

[moviePlayerController play];
È stato utile?

Soluzione

The problem lies within the fact, that your moviePlayerController is being cleaned up due to ARC.

Try if it helps to introduce a strong property for the MPMoviePlayerController.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top