Is it possible to detect non-ipod music?

Is there a way to determine if music or media is playing from a source other than the iPod application?

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

[[MPMusicPlayerController iPodMusicPlayer] playbackState] == MPMusicPlaybackStatePlaying 

But this is not true if music is being played from another application, such as Pandora Radio, Spotify, Plex, etc. Am I doing something wrong or is it possible?

It seems that this may be possible because these other applications can register in the system to receive system control events using

 -(void)remoteControlReceivedWithEvent:(UIEvent *)theEvent 

However, I still could not find a way to request this value other than ipod media. Any help would be greatly appreciated. Thanks!

+6
source share
1 answer
 static bool isOtherAudioIsPlaying(void) { UInt32 OtherAudioIsPlaying = 0; UInt32 size = sizeof(OtherAudioIsPlaying); AudioSessionGetProperty(kAudioSessionProperty_OtherAudioIsPlaying, &size, &OtherAudioIsPlaying); return (bool)OtherAudioIsPlaying; } 
0
source

Source: https://habr.com/ru/post/924063/


All Articles