iPhone - Resuming background music after playing movie
-
13-04-2021 - |
質問
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?
解決
This kind of option to continue must from ipod is not possible.
他のヒント
Use notifications
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
- (void) moviePlayBackDidFinish {
// resume your AVAudioSession
}
所属していません StackOverflow