fix(player): preserve volume when toggling mute (#1532)

* fix(player): preserve volume when toggling mute

Muting now keeps the last volume level memorized. Unmuting restores that level, including amplified values allowed by the configured maximum.

* fix(player): preserve volume for companion remote mute

Route the companion remote through the shared mute transition so it no longer overwrites the persisted volume or restores to 100%. Also correct the Dartdoc formatting for the transition record fields.
This commit is contained in:
Ryan Ernest
2026-07-11 12:46:58 +02:00
committed by GitHub
parent d86e328169
commit c86d40f8dd
7 changed files with 192 additions and 10 deletions
+15
View File
@@ -614,6 +614,21 @@ class SettingsService extends BaseSharedPreferencesService {
_cachedInstance = null;
}
/// Resolves a video mute toggle without replacing the saved volume with 0.
///
/// `persistedVolume` is the non-zero value callers should keep in [volume],
/// while `playerVolume` is the value to apply to the active player.
({double playerVolume, double persistedVolume}) resolveMuteToggle(double currentVolume) {
if (currentVolume.isFinite && currentVolume > 0) {
return (playerVolume: 0, persistedVolume: currentVolume);
}
final previousVolume = read(volume);
final candidate = previousVolume.isFinite && previousVolume > 0 ? previousVolume : volume.defaultValue;
final restoredVolume = candidate.clamp(0.0, read(maxVolume).toDouble()).toDouble();
return (playerVolume: restoredVolume, persistedVolume: restoredVolume);
}
static Map<String, String> defaultKeyboardShortcuts() => _defaultKeyboardShortcuts();
static Map<String, HotKey> defaultKeyboardHotkeys() => _defaultKeyboardHotkeys();