iOSCategory

TODO this section needs reviewing as I don't think it is correct it also breaks our stated purpose of being OS agnostic.

The android documentation states that requestFocus should be called on the play() callback which we do by default.

Before controlling the focus with requestFocs() you must call iosSetCategory() on iOS or androidAudioFocusRequest() on Android. requesFocus() and androidAudioFocusRequest() are useful if you want to hush others (in android terminology duck others). Those functions are probably called just once when the app starts. After calling this function, the caller is calling requestFocus()/abandonFocus() as required.
You can refer to iOS documentation to understand the parameters needed for iosSetCategory() and to the Android documentation to understand the parameter needed for androidAudioFocusRequest().
Remark : those three functions do NOT work on Android before SDK 26.
Note: these platform specific methods are under review with the intent to remove any/all platform specific elements to the api.
1
if (_hushOthers)
2
{
3
if (Platform.isIOS)
4
await player.iosSetCategory( t_IOS_SESSION_CATEGORY.PLAY_AND_RECORD, t_IOS_SESSION_MODE.DEFAULT, IOS_DUCK_OTHERS | IOS_DEFAULT_TO_SPEAKER );
5
else if (Platform.isAndroid)
6
await player.androidAudioFocusRequest( ANDROID_AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK );
7
} else
8
{
9
if (Platform.isIOS)
10
await player.iosSetCategory( t_IOS_SESSION_CATEGORY.PLAY_AND_RECORD, t_IOS_SESSION_MODE.DEFAULT, IOS_DEFAULT_TO_SPEAKER );
11
else if (Platform.isAndroid)
12
await player.androidAudioFocusRequest( ANDROID_AUDIOFOCUS_GAIN );
13
}
14
...
Copied!
Last modified 1yr ago