From 76e45969de7a6b45ad71cf24c1fdf950605e5ac0 Mon Sep 17 00:00:00 2001 From: Baka632 Date: Sat, 1 Jun 2024 22:57:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A6=82=E8=A7=88=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E7=9A=84=E6=92=AD=E6=94=BE=E7=8A=B6=E6=80=81=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=8F=8A=E8=B0=83=E4=BD=8E=E4=BA=AE=E5=BA=A6=E8=BF=87?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MonsterSiren.Uwp/Package.appxmanifest | 2 +- src/MonsterSiren.Uwp/Services/MusicService.cs | 2 +- .../ViewModels/GlanceViewViewModel.cs | 4 +-- .../Views/GlanceViewPage.xaml | 6 ++-- .../Views/GlanceViewPage.xaml.cs | 29 +++++++++---------- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/MonsterSiren.Uwp/Package.appxmanifest b/src/MonsterSiren.Uwp/Package.appxmanifest index 2798426..81f7b7c 100644 --- a/src/MonsterSiren.Uwp/Package.appxmanifest +++ b/src/MonsterSiren.Uwp/Package.appxmanifest @@ -10,7 +10,7 @@ + Version="1.1.2.0" /> diff --git a/src/MonsterSiren.Uwp/Services/MusicService.cs b/src/MonsterSiren.Uwp/Services/MusicService.cs index 80db5e2..e7fd57b 100644 --- a/src/MonsterSiren.Uwp/Services/MusicService.cs +++ b/src/MonsterSiren.Uwp/Services/MusicService.cs @@ -209,7 +209,7 @@ static MusicService() mediaPlayer.Source = mediaPlaybackList; CurrentMediaPlaybackList = new NowPlayingList(mediaPlaybackList.Items); - //下面的事件处理器在 UI 线程引发事件,这样可以让与 UI 相关的代码在处理这些事件时不会出错 + // 下面的事件处理器在 UI 线程引发事件,这样可以让与 UI 相关的代码在处理这些事件时不会出错 mediaPlayer.VolumeChanged += async (sender, arg) => { double volume = sender.Volume; diff --git a/src/MonsterSiren.Uwp/ViewModels/GlanceViewViewModel.cs b/src/MonsterSiren.Uwp/ViewModels/GlanceViewViewModel.cs index b4b047e..fd8e7f7 100644 --- a/src/MonsterSiren.Uwp/ViewModels/GlanceViewViewModel.cs +++ b/src/MonsterSiren.Uwp/ViewModels/GlanceViewViewModel.cs @@ -15,7 +15,7 @@ public sealed partial class GlanceViewViewModel : ObservableObject [ObservableProperty] private double _contentOffset; [ObservableProperty] - private bool showPausedState = MusicService.PlayerPlayBackState == MediaPlaybackState.Paused; + private bool showPlayState = MusicService.PlayerPlayBackState is MediaPlaybackState.Paused or MediaPlaybackState.Buffering or MediaPlaybackState.Opening; [ObservableProperty] private bool showMuteState = MusicService.IsPlayerMuted; [ObservableProperty] @@ -40,7 +40,7 @@ private void OnMusicServicePlayerMuteStateChanged(bool state) private void OnMusicServicePlayerPlaybackStateChanged(MediaPlaybackState state) { - ShowPausedState = state == MediaPlaybackState.Paused; + ShowPlayState = state is MediaPlaybackState.Paused or MediaPlaybackState.Buffering or MediaPlaybackState.Opening; } ~GlanceViewViewModel() diff --git a/src/MonsterSiren.Uwp/Views/GlanceViewPage.xaml b/src/MonsterSiren.Uwp/Views/GlanceViewPage.xaml index a476f04..10c363b 100644 --- a/src/MonsterSiren.Uwp/Views/GlanceViewPage.xaml +++ b/src/MonsterSiren.Uwp/Views/GlanceViewPage.xaml @@ -66,11 +66,11 @@ x:Load="{x:Bind ViewModel.ShowMeteredInternet, Mode=OneWay}" Symbol="FourBars" /> + Glyph="{x:Bind ViewModel.MusicInfo.PlayIconGlyph, Mode=OneWay}" /> - { - _brightnessOverride = BrightnessOverride.GetForCurrentView(); - if (_brightnessOverride.IsSupported) - { - _brightnessOverride.SetBrightnessLevel(0.1, DisplayBrightnessOverrideOptions.UseDimmedPolicyWhenBatteryIsLow); - _brightnessOverride.StartOverride(); - } - }); - brightnessTask.Wait(300); - } } private void OnPageSizeChanged(object sender, SizeChangedEventArgs e) @@ -92,7 +78,7 @@ private void AdjustContentPosition() } } - protected override void OnNavigatedTo(NavigationEventArgs e) + protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); @@ -101,6 +87,19 @@ protected override void OnNavigatedTo(NavigationEventArgs e) { view.TryEnterFullScreenMode(); } + + if (SettingsHelper.TryGet(CommonValues.AppGlanceModeUseLowerBrightnessSettingsKey, out bool useLowerBrightness) && useLowerBrightness) + { + await UIThreadHelper.RunOnUIThread(() => + { + _brightnessOverride = BrightnessOverride.GetForCurrentView(); + if (_brightnessOverride.IsSupported) + { + _brightnessOverride.SetBrightnessLevel(0.1, DisplayBrightnessOverrideOptions.UseDimmedPolicyWhenBatteryIsLow); + _brightnessOverride.StartOverride(); + } + }); + } } protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)