Audio Feature Equivalent to Androids “audio focus “

I have yet to see proliferation of the apps such as media players that allow for this particular feature - to ignore other audio feeds and continue playing, regardless. So for example,If the media players playing the music station and I use your opens any audio source, Purpose sample YouTube video, the media player would not stop streaming at the radio station.


I know for sure that this feature is available because I’ve seen this in one particular app that I will not mention just yet. Anyhow the app allows for an audio stream to continue sleep laying on top of any other audio without stopping.

How could this be integrated into an app?

thnx

ed


Looks like I have found the






basics :

Down vote
Here's what I am using for Swift 2.0:

let sess = AVAudioSession.sharedInstance()
if sess.otherAudioPlaying {
     = try? sess.setCategory(AVAudioSessionCategoryAmbient, withOptions: .DuckOthers)
    
= try? sess.setActive(true, withOptions: [])
}
Please note that you can replace .DuckOthers with [] if you don't want to lower background music and instead play on top to it.


Enumeration Case
AVAudioSessionCategoryOptionDuckOthers
An option that reduces the volume of other audio session while audio from this session plays.
Availability

iOS 6.0+
macOS 10.15+
Mac Catalyst 13.0+
tvOS 9.0+
watchOS 7.0+
Framework

AVFoundation
On This Page

Declaration 
Discussion 
See Also 
Declaration
AVAudioSessionCategoryOptionDuckOthers = 0x2
Discussion
You can set this option only if the audio session category is AVAudioSessionCategoryPlayAndRecord, AVAudioSessionCategoryPlayback, or AVAudioSessionCategoryMultiRoute. Setting it implicitly sets the AVAudioSessionCategoryOptionMixWithOthers option.
Use this option to mix your app’s audio with that of others. While your app plays its audio, the system reduces the volume of other audio sessions to make yours more prominent. If your app provides occasional spoken audio, such as in a turn-by-turn navigation app or an exercise app, you should also set the AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers option.
Note that ducking begins when you activate your app’s audio session and ends when you deactivate the session. If you clear this option, activating your session interrupts other audio sessions.
See Also




Audio Feature Equivalent to Androids “audio focus “
 
 
Q