feat(audio): Set audio context AudioContextConfigFocus.mixWithOthers by default (#3483)

# Description

AudioPlayers used to mix their sounds with other audio on the device,
which is not the proposed experience on Mobile devices. So this behavior
was changed in AudioPlayers, but it wasn't enforced due to a bug.
Obviously this behavior is not wanted for Games as multiple sounds
should play simultaneously, so this recovers the old functionality
again.

## Checklist
<!--
Before you create this PR confirm that it meets all requirements listed
below by checking the
relevant checkboxes with `[x]`. If some checkbox is not applicable, mark
it as `[-]`.
-->

- [x] I have followed the [Contributor Guide] when preparing my PR.
- [ ] I have updated/added tests for ALL new/updated/fixed
functionality.
- [ ] I have updated/added relevant documentation in `docs` and added
dartdoc comments with `///`.
- [x] I have updated/added relevant examples in `examples` or `docs`.

Not sure, if I can test this properly, as it's on a system level. I
could ensure the values are set though (?)

## Breaking Change?
I'm actually not sure, if this is breaking, I think it's not, as
`audioplayers` used to work like `mixWithOthers` due to a bug, but is
not anymore.

- [ ] Yes, this PR is a breaking change.
- [x] No, this PR is not a breaking change.

<!--
### Migration instructions

If the PR is breaking, uncomment this header and add instructions for
how to migrate from the
currently released version in-between the two following tags:
-->
<!-- End of exclude from commit message -->

---------

Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
This commit is contained in:
August
2025-02-10 09:46:54 +01:00
committed by GitHub
parent 1dbb4433ca
commit 762e0ad842
5 changed files with 54 additions and 15 deletions

View File

@ -39,9 +39,9 @@ class AudioGame extends FlameGame with TapDetector {
Rect get button => Rect.fromLTWH(20, size.y - 300, size.x - 40, 200);
void startBgmMusic() {
FlameAudio.bgm.initialize();
FlameAudio.bgm.play('music/bg_music.ogg');
Future<void> startBgmMusic() async {
await FlameAudio.bgm.initialize();
await FlameAudio.bgm.play('music/bg_music.ogg');
}
void fireOne() {