setAudioContext method

Future<void> setAudioContext(
  1. AudioContext audioContext
)
inherited

Apply Platform Audio Context

Applies an AudioContext (focus, usage, category, etc.) to the underlying player. Call early (before playback) for deterministic behavior.

The underlying setAudioContext is async; we forward the Future so callers can await when they need strict ordering.

await channel.setAudioContext(myContext);
await channel.play('assets/bgm/theme.mp3');

Implementation

Future<void> setAudioContext(AudioContext audioContext) {
  _ctx = audioContext;
  return _player.setAudioContext(audioContext);
}