Can I mute other apps using SoundPool in Android Studio / Kotlin

75 views Asked by At

I’m playing a small audio clip in my Android app developed with Android Studio and Kotlin. I use SoundPool to play the app using

soundPool.play()

This has the following parameters (I’ve copied this from developer.android.com): play(soundId: Int, leftVolume: Float, rightVolume: Float, priority: Int, loop: int, rate: Float)

It’s straightforward to use and I just define the audio clip using soundPool.load()

This all works fine, but I’d like to have the option to mute other apps, such as Spotify, while my clip plays, which is just for a few seconds. I’m converting the app from iOS (XCode/Swift) and there it is possible to do this using AVAudioSession by using the [.mixWithOthers] option. I’ve spent some time searching for this and, based on some old discussions, I suspect it is not possible in Android. However, I thought I’d ask as things do change!

I hope I’ve given enough information here.

Thanks in advance for any help or suggestions.

Ian

0

There are 0 answers