6

Is there any way to detect if music or media from another source other than the iPod app is playing?

I know that I can detect music playing from ipod with:

[[MPMusicPlayerController iPodMusicPlayer] playbackState] == MPMusicPlaybackStatePlaying

But this returns incorrect if the music being played is from another app such as Pandora Radio, Spotify, Plex, etc... Am I doing something wrong or is this even possible?

It seems this might be possible due to these other apps being able to register with the system to receive system control events with

-(void)remoteControlReceivedWithEvent:(UIEvent *)theEvent

However, I have so far been unable to find any way of querying this value other than for ipod media. Any help would be appreciated. Thanks!

Matthieu Brucher
  • 21,634
  • 7
  • 38
  • 62
Krejko
  • 901
  • 1
  • 9
  • 23

1 Answers1

0
static bool isOtherAudioIsPlaying(void)
{
    UInt32 OtherAudioIsPlaying = 0;
    UInt32 size = sizeof(OtherAudioIsPlaying);

    AudioSessionGetProperty(kAudioSessionProperty_OtherAudioIsPlaying,
                 &size,
                 &OtherAudioIsPlaying);
    return (bool)OtherAudioIsPlaying;
}
Maxim Kholyavkin
  • 4,463
  • 2
  • 37
  • 82