Reputation: 602
I have a 3 Movie players added to three different views. When I switch randomly between the views when the movie is only played for a few seconds, out of the blue the player vanishes on all subsequent views.
I am not releasing my view any where so, I cannot figure out why my player disappears
here is the code I use in my View id Load method along with the notification method.
movieUrl =[[NSBundle mainBundle] pathForResource:@"Old Spice-Ad" ofType:@"mp4"];
player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:movieUrl]];
player.view.frame =CGRectMake(38,380,211,122);
[self.view addSubview:player.view];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:player] ;
- (void)moviePlayBackDidFinish:(NSNotification *)notification {
MPMoviePlayerController *theMovie = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:theMovie];
[theMovie stop];
[theMovie release];
}
Upvotes: 0
Views: 511
Reputation: 414
In the MPMoviePlayerController class reference:
Note: Although you may create multiple MPMoviePlayerController objects and present their views in your interface, only one movie player at a time may play its movie.
Upvotes: 1