Move WMP check to app startup

This commit is contained in:
VictoriousRaptor 2024-05-20 22:36:24 +08:00
parent 490bf59024
commit 2c3e1bfefa
4 changed files with 7 additions and 6 deletions

View file

@ -271,6 +271,9 @@ namespace Flow.Launcher.Infrastructure.UserSettings
public AnimationSpeeds AnimationSpeed { get; set; } = AnimationSpeeds.Medium; public AnimationSpeeds AnimationSpeed { get; set; } = AnimationSpeeds.Medium;
public int CustomAnimationLength { get; set; } = 360; public int CustomAnimationLength { get; set; } = 360;
[JsonIgnore]
public bool WMPInstalled { get; set; } = true;
// This needs to be loaded last by staying at the bottom // This needs to be loaded last by staying at the bottom
public PluginsSettings PluginSettings { get; set; } = new PluginsSettings(); public PluginsSettings PluginSettings { get; set; } = new PluginsSettings();

View file

@ -62,6 +62,7 @@ namespace Flow.Launcher
_settingsVM = new SettingWindowViewModel(_updater, _portable); _settingsVM = new SettingWindowViewModel(_updater, _portable);
_settings = _settingsVM.Settings; _settings = _settingsVM.Settings;
_settings.WMPInstalled = WindowsMediaPlayerHelper.IsWindowsMediaPlayerInstalled();
AbstractPluginEnvironment.PreStartPluginExecutablePathUpdate(_settings); AbstractPluginEnvironment.PreStartPluginExecutablePathUpdate(_settings);

View file

@ -46,7 +46,6 @@ namespace Flow.Launcher
private bool _animating; private bool _animating;
private bool isArrowKeyPressed = false; private bool isArrowKeyPressed = false;
private bool isWMPInstalled = true;
private MediaPlayer animationSoundWMP; private MediaPlayer animationSoundWMP;
private SoundPlayer animationSoundWPF; private SoundPlayer animationSoundWPF;
@ -509,8 +508,7 @@ namespace Flow.Launcher
private void InitSoundEffects() private void InitSoundEffects()
{ {
isWMPInstalled = WindowsMediaPlayerHelper.IsWindowsMediaPlayerInstalled(); if (_settings.WMPInstalled)
if (isWMPInstalled)
{ {
animationSoundWMP = new MediaPlayer(); animationSoundWMP = new MediaPlayer();
animationSoundWMP.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav")); animationSoundWMP.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav"));
@ -523,8 +521,7 @@ namespace Flow.Launcher
private void SoundPlay() private void SoundPlay()
{ {
if (_settings.WMPInstalled)
if (isWMPInstalled)
{ {
animationSoundWMP.Position = TimeSpan.Zero; animationSoundWMP.Position = TimeSpan.Zero;
animationSoundWMP.Volume = _settings.SoundVolume / 100.0; animationSoundWMP.Volume = _settings.SoundVolume / 100.0;

View file

@ -67,7 +67,7 @@ namespace Flow.Launcher
private void CheckMediaPlayer() private void CheckMediaPlayer()
{ {
if (!WindowsMediaPlayerHelper.IsWindowsMediaPlayerInstalled()) if (settings.WMPInstalled)
{ {
WMPWarning.Visibility = Visibility.Visible; WMPWarning.Visibility = Visibility.Visible;
VolumeAdjustCard.Visibility = Visibility.Collapsed; VolumeAdjustCard.Visibility = Visibility.Collapsed;