setBgmVolume method
Sets the player's chosen BGM volume (ENH-95), clamped to [0, 1] and
persisted via StorageKeys.bgmVolume. Applies immediately if bgm is
currently playing and not ducked; if a duck is in progress, the new
level takes effect once _unduckBgm restores it (ducking is always
relative to this value, never a stale snapshot).
Implementation
Future<void> setBgmVolume(double value) async {
final clamped = value.clamp(0.0, 1.0);
bgmVolume.value = clamped;
if (_bgmPlaying && _duckCount == 0) {
_ignoreAudio(_bgm.audioPlayer.setVolume(clamped));
}
await StorageService.to.setDouble(StorageKeys.bgmVolume, clamped);
}