From 2c3e1bfefa270260a12fc3383dcfa8e703f37fee Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Mon, 20 May 2024 22:36:24 +0800 Subject: [PATCH] Move WMP check to app startup --- Flow.Launcher.Infrastructure/UserSettings/Settings.cs | 3 +++ Flow.Launcher/App.xaml.cs | 1 + Flow.Launcher/MainWindow.xaml.cs | 7 ++----- Flow.Launcher/SettingWindow.xaml.cs | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 7bb8fe200..18abd4adf 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -271,6 +271,9 @@ namespace Flow.Launcher.Infrastructure.UserSettings public AnimationSpeeds AnimationSpeed { get; set; } = AnimationSpeeds.Medium; public int CustomAnimationLength { get; set; } = 360; + [JsonIgnore] + public bool WMPInstalled { get; set; } = true; + // This needs to be loaded last by staying at the bottom public PluginsSettings PluginSettings { get; set; } = new PluginsSettings(); diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index f4a17761f..9fa5af7e3 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -62,6 +62,7 @@ namespace Flow.Launcher _settingsVM = new SettingWindowViewModel(_updater, _portable); _settings = _settingsVM.Settings; + _settings.WMPInstalled = WindowsMediaPlayerHelper.IsWindowsMediaPlayerInstalled(); AbstractPluginEnvironment.PreStartPluginExecutablePathUpdate(_settings); diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 2733413e7..0f96b88de 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -46,7 +46,6 @@ namespace Flow.Launcher private bool _animating; private bool isArrowKeyPressed = false; - private bool isWMPInstalled = true; private MediaPlayer animationSoundWMP; private SoundPlayer animationSoundWPF; @@ -509,8 +508,7 @@ namespace Flow.Launcher private void InitSoundEffects() { - isWMPInstalled = WindowsMediaPlayerHelper.IsWindowsMediaPlayerInstalled(); - if (isWMPInstalled) + if (_settings.WMPInstalled) { animationSoundWMP = new MediaPlayer(); animationSoundWMP.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav")); @@ -523,8 +521,7 @@ namespace Flow.Launcher private void SoundPlay() { - - if (isWMPInstalled) + if (_settings.WMPInstalled) { animationSoundWMP.Position = TimeSpan.Zero; animationSoundWMP.Volume = _settings.SoundVolume / 100.0; diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index 7f1ee0078..48491564e 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -67,7 +67,7 @@ namespace Flow.Launcher private void CheckMediaPlayer() { - if (!WindowsMediaPlayerHelper.IsWindowsMediaPlayerInstalled()) + if (settings.WMPInstalled) { WMPWarning.Visibility = Visibility.Visible; VolumeAdjustCard.Visibility = Visibility.Collapsed;