I need to play background music in my app when no other (iPod) music is playing. I can determine it when initializing my audio session:
AudioSessionGetProperty (kAudioSessionProperty_OtherAudioIsPlaying, &varSize, &isPlaying);
But I want also to start my background music when user stops iPod player (pressing home button twice and pausing the music). How can I catch this event?
I have found:
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector (onIPodPlayerPlaybackStateChanged:)
name: MPMusicPlayerControllerPlaybackStateDidChangeNotification
object: [MPMusicPlayerController iPodMusicPlayer]];
[[MPMusicPlayerController iPodMusicPlayer] beginGeneratingPlaybackNotifications];