I found a great solution for this. In the .h file, you must create a BOOL named wasPlaying. Before playing a video, you ask your iPod if it is playing.
if ([[MPMusicPlayerController iPodMusicPlayer] playbackState] == MPMusicPlaybackStatePlaying)
{
NSLog(@"Music was playing, lets put YES to the bool");
wasPlaying = YES;
}
Then, after you tell the movie player, you call the following:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(finishedPlaying) name:MPMoviePlayerPlaybackDidFinishNotification object: moviePlayer];
And after that, in the finishedPlaying method:
if (wasPlaying ==YES)
{
NSLog(@"Music was playing, lets play music again");
[[MPMusicPlayerController iPodMusicPlayer] play];
}
It worked great for me!
source
share