setAudioFocus method
Future<void>
setAudioFocus({
- AudioFocus focus = AudioFocus.requestFocusAndKeepOthers,
- SessionCategory category = SessionCategory.playback,
- SessionMode mode = SessionMode.modeDefault,
- AudioDevice device = AudioDevice.speaker,
- int audioFlags = outputToSpeaker | allowBlueTooth | allowBlueToothA2DP | allowEarPiece,
Set or unset the Audio Focus.
This verb is very similar to openAudioSession and allow to change the parameters during an open Session Example:
myPlayer.setAudioFocus(focus: AudioFocus.requestFocusAndDuckOthers);
Implementation
Future<void> setAudioFocus({
AudioFocus focus = AudioFocus.requestFocusAndKeepOthers,
SessionCategory category = SessionCategory.playback,
SessionMode mode = SessionMode.modeDefault,
AudioDevice device = AudioDevice.speaker,
int audioFlags =
outputToSpeaker | allowBlueTooth | allowBlueToothA2DP | allowEarPiece,
}) async {
await _lock.synchronized(() async {
await _setAudioFocus(
focus: focus,
category: category,
mode: mode,
device: device,
audioFlags: audioFlags,
);
});
}