Question

I'm playing iTunes music in the background. I started my app which plays "Video" using the following code:

NSString* videoPath = [[NSBundle mainBundle] pathForResource:@"video" ofType:@"m4v"];
    if (player) {
        [player release];
        player = nil;
    }
    player = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:videoPath]];
    [self presentModalViewController:player animated:YES];

I'm setting the audio session as follows:

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive: YES error:nil];

When my video starts playing, iPod music playing in the background will be stopped. How can I resume the background music when my video completes?

Was it helpful?

Solution

This kind of option to continue must from ipod is not possible.

OTHER TIPS

Use notifications

[[NSNotificationCenter defaultCenter]
 addObserver:self
    selector:@selector(moviePlayBackDidFinish:)
        name:MPMoviePlayerPlaybackDidFinishNotification
      object:nil];

- (void) moviePlayBackDidFinish {
  // resume your AVAudioSession
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top