Skip to content

Automatic ducking not working on Android #874

@dlebrun

Description

@dlebrun

Description

According to Android documentation (https://developer.android.com/media/optimize/audio-focus#automatic-ducking), audio playback should be automatically ducked when another app requests audio focus with AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK, but this does not seem to be the case.

A workaround could have been to explicitly reduce the volume in response to a AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK event, but from what I see in https://github.com/software-mansion/react-native-audio-api/blob/1f342f3d3c23aec2357b0bd714bd17cb09f39426/packages/react-native-audio-api/android/src/main/java/com/swmansion/audioapi/system/AudioFocusListener.kt, this type of event is ignored.

Steps to reproduce

  1. Play audio in an app using react-native-audio-api
  2. Open another app that you know will request audio focus with AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK (best bet is a navigation app) and do whatever is needed to make it play a sound.
  3. The first app continues to play audio at normal volume (expected behavior: continues to play but at reduced volume)

Snack or a link to a repository

https://snack.expo.dev/@dominique.lebrun/graceful-blue-croissant

React Native Audio API version

0.10.0

React Native version

0.81.5

Platforms

Android

JavaScript runtime

Hermes

Workflow

Expo Dev Client

Architecture

Fabric (New Architecture)

Build type

Release app & dev bundle

Device

Real device

Device model

No response

Acknowledgements

Yes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions