cache desktop volume

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-10-02 10:50:56 +08:00
parent 8c7db34e5a
commit 5d5adbc73f
3 changed files with 14 additions and 2 deletions

View File

@@ -94,7 +94,9 @@ class PlPlayerController {
late double lastPlaybackSpeed = 1.0; late double lastPlaybackSpeed = 1.0;
final RxDouble _playbackSpeed = Pref.playSpeedDefault.obs; final RxDouble _playbackSpeed = Pref.playSpeedDefault.obs;
late final RxDouble _longPressSpeed = Pref.longPressSpeedDefault.obs; late final RxDouble _longPressSpeed = Pref.longPressSpeedDefault.obs;
final RxDouble _currentVolume = 1.0.obs; final RxDouble _currentVolume = RxDouble(
Utils.isDesktop ? Pref.desktopVolume : 1.0,
);
final RxDouble _currentBrightness = (-1.0).obs; final RxDouble _currentBrightness = (-1.0).obs;
final RxBool _showControls = false.obs; final RxBool _showControls = false.obs;
@@ -779,6 +781,9 @@ class PlPlayerController {
); );
final pp = player.platform!; final pp = player.platform!;
if (_videoPlayerController == null) { if (_videoPlayerController == null) {
if (Utils.isDesktop) {
pp.setVolume(this.volume.value * 100);
}
if (isAnim) { if (isAnim) {
setShader(superResolutionType.value, pp); setShader(superResolutionType.value, pp);
} }
@@ -1330,6 +1335,9 @@ class PlPlayerController {
volumeTimer = Timer(const Duration(milliseconds: 200), () { volumeTimer = Timer(const Duration(milliseconds: 200), () {
volumeIndicator.value = false; volumeIndicator.value = false;
volumeInterceptEventStream.value = false; volumeInterceptEventStream.value = false;
if (Utils.isDesktop) {
setting.put(SettingBoxKey.desktopVolume, volume.toPrecision(3));
}
}); });
} }

View File

@@ -144,7 +144,8 @@ abstract class SettingBoxKey {
windowSize = 'windowSize', windowSize = 'windowSize',
windowPosition = 'windowPosition', windowPosition = 'windowPosition',
isWindowMaximized = 'isWindowMaximized', isWindowMaximized = 'isWindowMaximized',
showWindowTitleBar = 'showWindowTitleBar'; showWindowTitleBar = 'showWindowTitleBar',
desktopVolume = 'desktopVolume';
static const String subtitlePreferenceV2 = 'subtitlePreferenceV2', static const String subtitlePreferenceV2 = 'subtitlePreferenceV2',
enableDragSubtitle = 'enableDragSubtitle', enableDragSubtitle = 'enableDragSubtitle',

View File

@@ -844,4 +844,7 @@ abstract class Pref {
static bool get showWindowTitleBar => static bool get showWindowTitleBar =>
_setting.get(SettingBoxKey.showWindowTitleBar, defaultValue: true); _setting.get(SettingBoxKey.showWindowTitleBar, defaultValue: true);
static double get desktopVolume =>
_setting.get(SettingBoxKey.desktopVolume, defaultValue: 1.0);
} }