Issue description
I'm trying to get AudioFocus behavior: duck (lower volume) on notifications and pause on incoming call (and play after call end). When i look at the code https://github.com/google/ExoPlayer/blob/release-v2/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioFocusManager.java#L419 default ExoPlayer implementation should be working like this (or maybe i don't understand it well). But unfortunetely - on incoming call volume is down to 0, but playback doesn't stop.
Interestingly enough. CONTENT_TYPE_SPEECH is not working either. Playback isn't stopped on both - notifications and incoming call.
Reproduction steps
I set audio attributes like this
setAudioAttributes(AudioAttributes.Builder()
.setContentType(C.CONTENT_TYPE_MUSIC)
.setUsage(C.USAGE_MEDIA)
.build(), true)
In logs i can see that AUDIOFOCUS_LOSS_TRANSIENT was dispatched. It seems like PLAYER_COMMAND_WAIT_FOR_CALLBACK wasn't handled properly.
D/AudioManager: dispatching onAudioFocusChange(-2) to android.media.AudioManager@1420c8com.google.android.exoplayer2.audio.AudioFocusManager$AudioFocusListener@d3f1561
D/AudioManager: dispatching onAudioFocusChange(1) to android.media.AudioManager@1420c8com.google.android.exoplayer2.audio.AudioFocusManager$AudioFocusListener@d3f1561
EDIT: when i digged deeper i found that on SimpleExoPlayer ComponentListener to PlayerCommand is ignoring PLAYER_COMMAND_WAIT_FOR_CALLBACK completely
private void updatePlayWhenReady(
boolean playWhenReady, @AudioFocusManager.PlayerCommand int playerCommand) {
player.setPlayWhenReady(
playWhenReady && playerCommand != AudioFocusManager.PLAYER_COMMAND_DO_NOT_PLAY,
playerCommand != AudioFocusManager.PLAYER_COMMAND_PLAY_WHEN_READY);
}
Version of ExoPlayer being used
2.10.3
Device(s) and version(s) of Android being used
Samsung Galaxy S7 Edge, Android 8.0; Huawei Mate 20 lite, Android 8.1; Samsung Galaxy A7 (2018), Android 9
Also emulators of Pixel 2 devices using Android 8, 9 and Q (9+)
Issue description
I'm trying to get AudioFocus behavior: duck (lower volume) on notifications and pause on incoming call (and play after call end). When i look at the code https://github.com/google/ExoPlayer/blob/release-v2/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioFocusManager.java#L419 default ExoPlayer implementation should be working like this (or maybe i don't understand it well). But unfortunetely - on incoming call volume is down to 0, but playback doesn't stop.
Interestingly enough.
CONTENT_TYPE_SPEECHis not working either. Playback isn't stopped on both - notifications and incoming call.Reproduction steps
I set audio attributes like this
In logs i can see that
AUDIOFOCUS_LOSS_TRANSIENTwas dispatched. It seems likePLAYER_COMMAND_WAIT_FOR_CALLBACKwasn't handled properly.EDIT: when i digged deeper i found that on
SimpleExoPlayerComponentListenertoPlayerCommandis ignoringPLAYER_COMMAND_WAIT_FOR_CALLBACKcompletelyVersion of ExoPlayer being used
2.10.3
Device(s) and version(s) of Android being used
Samsung Galaxy S7 Edge, Android 8.0; Huawei Mate 20 lite, Android 8.1; Samsung Galaxy A7 (2018), Android 9
Also emulators of Pixel 2 devices using Android 8, 9 and Q (9+)