是否有可能检测到非ipod音乐?

Kre*_*jko 6 background-music mpmusicplayercontroller ios

有没有办法检测来自iPod应用程序以外的其他来源的音乐或媒体是否正在播放?

我知道我可以通过以下方式检测从ipod播放的音乐:

[[MPMusicPlayerController iPodMusicPlayer] playbackState] == MPMusicPlaybackStatePlaying
Run Code Online (Sandbox Code Playgroud)

但是如果正在播放的音乐来自Pandora Radio,Spotify,Plex等其他应用程序,则返回不正确...我做错了什么或者这是否可能?

看起来这可能是可能的,因为这些其他应用程序能够向系统注册以接收系统控制事件

-(void)remoteControlReceivedWithEvent:(UIEvent *)theEvent
Run Code Online (Sandbox Code Playgroud)

但是,到目前为止,除了ipod媒体之外,我还没有找到任何查询这个值的方法.任何帮助,将不胜感激.谢谢!

Max*_*kin 0

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

    AudioSessionGetProperty(kAudioSessionProperty_OtherAudioIsPlaying,
                 &size,
                 &OtherAudioIsPlaying);
    return (bool)OtherAudioIsPlaying;
}
Run Code Online (Sandbox Code Playgroud)