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];
有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top