TheWidlarzGroup / react-native-video

A <Video /> component for react-native
https://thewidlarzgroup.github.io/react-native-video/
MIT License
7.2k stars 2.9k forks source link

[Feature]: Duck option for audio from other apps on Android #4144

Open kehuang805 opened 2 months ago

kehuang805 commented 2 months ago

Description

Android currently only offers two options with disableFocus for either overriding or mixing outside audio and I did not see a way to duck with react-native-video.

Why it is needed ?

iOS has the option to duck with the mixWithOthers property but it is not present for Android so it is not possible to have consistent behavior between operating systems currently.

Possible implementation

Technical POV how to do it

Code sample

Code sample

github-actions[bot] commented 2 months ago

Thank you for your feature request. We will review it and get back to you if we need more information.

paulrinaldi commented 2 months ago

Apparently android has ducking built in somehow, we'd need to look at the code to see what we might need to do. https://developer.android.com/media/optimize/audio-focus#automatic_ducking

freeboub commented 1 month ago

@kehuang805 I am currently working around audio focus. Can you please describe exactly the behavior you want to have ?

There are 3 props to handle audio: ignoreSilentSwitch is purely an ios feature mixWithOthers and disableFocus nearly have the same behavior (in fact they should be merged)

"inherit" (default) --> pause playback when when other app use audio (same as disableFocus=false) "mix" - Audio from this video mixes with audio from other apps. (same as disableFocus=true) "duck" - Reduces the volume of other apps while audio from this video plays. (Not available, but can be implemented)

kehuang805 commented 1 month ago

@freeboub We would like disableFocus to have the "duck" option which is currently not available like you mentioned. I guess it does not necessarily have to be coupled to the disableFocus prop, but that is where the control for this behavior currently lives for android.