Jörn Zaefferer created CB-11966:
-----------------------------------
Summary: Make durationHint parameter for requestAudioContext
configurable
Key: CB-11966
URL: https://issues.apache.org/jira/browse/CB-11966
Project: Apache Cordova
Issue Type: New Feature
Components: Android, Plugin Media
Reporter: Jörn Zaefferer
Android supports playback of so-called transient audio, like instructions from
navigation software or a beep from a timer or messenger, via the
AudioManager#requestAudioFocus method's `durationHint` parameter. Currently
this is hardcoded to AUDIOFOCUS_GAIN:
https://github.com/apache/cordova-plugin-media/blob/0a5a72df42ddd91c50f2a36d0c58408c3b43a9fd/src/android/AudioHandler.java#L445
That causes all other audio, like music or a podcast, to be stopped. Setting it
instead to AUDIOFOCUS_GAIN_TRANSIENT would only pause other audio while the
sound is playing. AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK allows other audio to only
lower volume, without pausing. There's also
AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE, but I don't understand what that does.
For more background, see
https://developer.android.com/training/managing-audio/audio-focus.html
I suggest adding a (Android specific) option to override the default to one of
the transient values.
Since the caller is itself called by `startPlayingAudio()` (
https://github.com/apache/cordova-plugin-media/blob/0a5a72df42ddd91c50f2a36d0c58408c3b43a9fd/src/android/AudioHandler.java#L318
), it might make sense to make this a parameter of the `media.play()` method.
I'm not sure what a good format would be. Passing an `int` is kinda bad.
Apparently none of the existing methods have any configuration.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]