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"Sample" ofType"mp4"];
movieURL = [NSURL fileURLWithPathath];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
moviePlayer.controlStyle = MPMovieControlStyleDefault;
[[NSNotificationCenter defaultCenter]
addObserver:self
selectorselector(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
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"Sample" ofType"mp4"];
movieURL = [NSURL fileURLWithPathath];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
moviePlayer.controlStyle = MPMovieControlStyleDefault;
[[NSNotificationCenter defaultCenter]
addObserver:self
selectorselector(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