How to determine if other applications are playing background sound?

I am making a game for iphone / ipad and do not want my background music to interfere with music that the user can already play.

I know that I can get the status of an iPod application using MPPlayerController, but how will my application find out that something else, like Pandora, is playing background sound on iOS4?

+3
source share
2 answers

I finally figured it out. I saw many examples, but could not get them to work.

Most of the examples there do not indicate that for something like:

    UInt32   propertySize, audioIsAlreadyPlaying;

propertySize = sizeof(UInt32);
AudioSessionGetProperty(kAudioSessionProperty_OtherAudioIsPlaying, &propertySize, &audioIsAlreadyPlaying);

, AudioToolbox. .

( ), , audioIsAlreadyPlaying .

+9

AudioSessionGetProperty ( ) iOS 7.

, isOtherAudioPlaying:

BOOL isOtherAudioPlaying = [[AVAudioSession sharedInstance] isOtherAudioPlaying];

iOS 6 +.

0

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


All Articles