0

I've applications like - spotify, youtube, netflix ect. I've my application.

When I run spotify -> and then switch to "my application" I want to mute spotify sound while I'm watching/listening on my application.

How can this be done? I tried to look into "AudioManager", but it is not a good option always, because you mute all the system...

I want to make sure that when I try to listen something on my application, then all the background app sounds are muted.

Can someone show me atleast direction? Thanks.

PeterPakla
  • 169
  • 1
  • 2
  • 13

2 Answers2

1

In addition to @Ozan's answer, when an app acquires audio focus it must be able to release it when another app requests audio focus for itself. When this happens your app receives a call to the onAudioFocusChange() method in the AudioFocusChangeListener that you specified when the app called requestAudioFocus().

The focusChange parameter passed to onAudioFocusChange() indicates the kind of change that's happening. It corresponds to the duration hint used by the app that's aquiring focus. Your app should respond appropriately.

You may also check this related thread: Android - can I mute currently playing audio applications?

abielita
  • 13,147
  • 2
  • 17
  • 59
0

Have you tried requestAudioFocus from AudioManager Documentation

If you be able to take correct Stream from Spotify, it will be muted.Probably you should call him with AudioManager.STREAM_MUSIC

Ozan
  • 36
  • 1
  • 5