iOS: How do I detect if music is playing in any background music app?

后端 未结 4 747
南笙
南笙 2020-12-15 21:32

I currently have my game correctly handling disabling its own BGM when music is playing in the built-in iPod app, but it does not detect when an app such as Pandora is playi

4条回答
  •  旧巷少年郎
    2020-12-15 22:02

    AudioSessionGetProperty (as mentioned in jake_hetfield's answer) is deprecated as of iOS 7.

    Instead, try this one-liner that uses isOtherAudioPlaying:

    BOOL isOtherAudioPlaying = [[AVAudioSession sharedInstance] isOtherAudioPlaying];
    

    Works on iOS 6+.

提交回复
热议问题