Search code examples
iosmpmusicplayercontroller

control background music from 3rd party apps ios


Is there a way to control music currently playing in the background? I am able to control the native ipod application with the MPMusicPlayerController iPodMusicPlayer, but what i basically want is the functionality of the ipod controller in the task switcher. I want to be able to control the app currently playing (next/prev). The controls in the task switcher controls spotify, pandora or any other app currently playing.

Any ideas?


Solution

  • You can do this. Make sure you are using the AVAudioSessionCategoryPlayback audio session, first off. After you activate the audio session, call:

      [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
    

    See here for more details http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/RemoteControl/RemoteControl.html