What's new
Apple iPad Forum 🍎

Welcome to the Apple iPad Forum, your one stop source for all things iPad. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

MPMoviePlayerPlaybackDidFinishNotification not working on UITabBar tap

julianb

iPF Noob
Joined
Dec 29, 2010
Messages
1
Reaction score
0
Hi

Noobie I'm afraid (but with some programming experience). I have a UITabBar where one of the the views (view 4) plays a video.

I create a listener:

-(void)viewDidLoad {
NSString *path = [[NSBundle mainBundle] pathForResource:mad:"Sample" ofType:mad:"mp4"];
movieURL = [NSURL fileURLWithPathath];

moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];

moviePlayer.controlStyle = MPMovieControlStyleDefault;

[[NSNotificationCenter defaultCenter]
addObserver:self
selector:mad:selector(moviePlayBackDidFinish
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];

[moviePlayer.view setFrame:CGRectMake(0, 0, 1024 , 739)];
moviePlayer.view.backgroundColor = [UIColor grayColor];
[self.view addSubview:moviePlayer.view];
[moviePlayer prepareToPlay];
[moviePlayer play];
}

Here's the function:


- (void) moviePlayBackDidFinishNSNotification*)notification
{
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];

moviePlayer.initialPlaybackTime = -1;
[moviePlayer stop];
[movieURL release];
[moviePlayer autorelease];
}

If I press another view UITabBar item the video continues playing in the background (as in I can hear the audio still). I f I return to the video view the app crashes.

How do I get the other UITabBar items to stop remove the MPMoviePlayerController instance if it's active?

TIA
JB
 

Most reactions

Latest posts

Top