AudioContext
Cross-platform configuration for native audio session and focus behavior.
Unset fields (None) are filled in when the context is applied on mobile:
route as SYSTEM, focus as
GAIN, and respect_silence /
stay_awake as False.
On iOS, audio context cannot be handled for each player individually,
so setting this property on an Audio instance
applies the context globally for the app.
Meaningful mainly on Android and iOS; desktop and web ignore it.
Properties
focus- The audio focus mode (GAIN,DUCK_OTHERS, orMIX_WITH_OTHERS).respect_silence- Whether the audio should be muted when the device is in silent/ringer mode.route- The audio output route (SYSTEM,SPEAKER, orEARPIECE).stay_awake- Whether to keep the device awake (acquire a wake lock) while playing audio.
Properties
focusclass-attributeinstance-attribute
focus: AudioContextFocus | None = NoneThe audio focus mode (GAIN,
DUCK_OTHERS, or
MIX_WITH_OTHERS).
If unset (None), mobile platforms behave as
GAIN.
respect_silenceclass-attributeinstance-attribute
respect_silence: bool | None = NoneWhether the audio should be muted when the device is in silent/ringer mode.
If unset (None), mobile platforms behave as False
(audio can play while the device is silenced).
Due to iOS platform limitations, setting this to True cannot be
combined with DUCK_OTHERS,
MIX_WITH_OTHERS, or
SPEAKER.
routeclass-attributeinstance-attribute
route: AudioContextRoute | None = NoneThe audio output route (SYSTEM,
SPEAKER, or
EARPIECE).
If unset (None), mobile platforms behave as
SYSTEM.
stay_awakeclass-attributeinstance-attribute
stay_awake: bool | None = NoneWhether to keep the device awake (acquire a wake lock) while playing audio.
If unset (None), mobile platforms behave as False.