Open wujek-srujek opened 1 year ago
Answer: it depends
On ios, you can only set the context for all players of your app. For convenience this is also done when calling it on a single player: https://github.com/bluefireteam/audioplayers/blob/main/getting_started.md#audio-context
On Android, some of the options are global, some are only player specific, (everywhere it is stated globally, only can be set globally): https://pub.dev/documentation/audioplayers_platform_interface/latest/audioplayers_platform_interface/AudioContextAndroid-class.html
In principal, the option 1 "The global context needs to be set first, any AudioPlayer created afterwards 'inherits' this configuration" should be correct, at least for Android.
Yes, we should make that more clear on the docs of the individual methods:
Yes, my tests show exactly what you say - on Android, the players created after the 'set global context' call inherit these values. In all fairness, the behavior for iOS is documented in the tutorial, no issues here.
Checklist
Use case / Problem
I think the documentation about
AudioContext
could be improved:Global
AudioContext
From the tutorial and documentation (
AudioPlayer.global.setAudioContext
has none) it isn't clear which one is true:AudioPlayer
created afterwards 'inherits' this configuration unless it is overridden with a player-specificsetAudioContext
- basically: if the global context applies to all players created after this call. This has been my assumption but now I feel it's wrong.OR
OR
Per-player
AudioContext
interaction with the global oneIt is also not clear how the global context interacts with the per-player context. I think that it will also depend on how the global one works, e.g.: if a player with its own context is created, and then set the global context is set - does this player keep it own or does it get overridden by the global one? (If the global context applies to all previously created players, option 2 above).
Explain defaults
It would also be very helpful to explain what the defaults are, i.e. when no context is set whatsoever.
I think explaining these two issues in the documentation / tutorial would be very helpful. I think I have made a lot of mistakes in my code based on false assumptions and got a lot of unexpected results.
Proposal / Solution
Improve documentation and/or the getting started tutorial.
Affected platforms
other (I think the documentation would help developers for any supported platform)
Working on PR
yeah (I can help write the docs, I just need to have the definitive information about the behavior)