diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs
index 61a9da40050..d83c767dd44 100644
--- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs
+++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs
@@ -273,6 +273,9 @@ public bool HideNotifyIcon
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 f4a17761f00..9fa5af7e310 100644
--- a/Flow.Launcher/App.xaml.cs
+++ b/Flow.Launcher/App.xaml.cs
@@ -62,6 +62,7 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
_settingsVM = new SettingWindowViewModel(_updater, _portable);
_settings = _settingsVM.Settings;
+ _settings.WMPInstalled = WindowsMediaPlayerHelper.IsWindowsMediaPlayerInstalled();
AbstractPluginEnvironment.PreStartPluginExecutablePathUpdate(_settings);
diff --git a/Flow.Launcher/Helper/WindowsMediaPlayerHelper.cs b/Flow.Launcher/Helper/WindowsMediaPlayerHelper.cs
new file mode 100644
index 00000000000..2eec6c89b08
--- /dev/null
+++ b/Flow.Launcher/Helper/WindowsMediaPlayerHelper.cs
@@ -0,0 +1,11 @@
+using Microsoft.Win32;
+
+namespace Flow.Launcher.Helper;
+internal static class WindowsMediaPlayerHelper
+{
+ internal static bool IsWindowsMediaPlayerInstalled()
+ {
+ using var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\MediaPlayer");
+ return key.GetValue("Installation Directory") != null;
+ }
+}
diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml
index 9ab05555c1e..633b84b1963 100644
--- a/Flow.Launcher/Languages/en.xaml
+++ b/Flow.Launcher/Languages/en.xaml
@@ -158,6 +158,7 @@
Play a small sound when the search window opens
Sound Effect Volume
Adjust the volume of the sound effect
+ Windows Media Player is unavailable and is required for Flow's volume adjustment. Please check your installation if you need to adjust volume.
Animation
Use Animation in UI
Animation Speed
diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs
index 9c5ed46c0cc..0f96b88de4c 100644
--- a/Flow.Launcher/MainWindow.xaml.cs
+++ b/Flow.Launcher/MainWindow.xaml.cs
@@ -12,7 +12,6 @@
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.ViewModel;
using Screen = System.Windows.Forms.Screen;
-using ContextMenuStrip = System.Windows.Forms.ContextMenuStrip;
using DragEventArgs = System.Windows.DragEventArgs;
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
using NotifyIcon = System.Windows.Forms.NotifyIcon;
@@ -24,7 +23,6 @@
using ModernWpf.Controls;
using Key = System.Windows.Input.Key;
using System.Media;
-using static Flow.Launcher.ViewModel.SettingWindowViewModel;
using DataObject = System.Windows.DataObject;
using System.Windows.Media;
using System.Windows.Interop;
@@ -46,9 +44,11 @@ public partial class MainWindow
private ContextMenu contextMenu = new ContextMenu();
private MainViewModel _viewModel;
private bool _animating;
- MediaPlayer animationSound = new MediaPlayer();
private bool isArrowKeyPressed = false;
+ private MediaPlayer animationSoundWMP;
+ private SoundPlayer animationSoundWPF;
+
#endregion
public MainWindow(Settings settings, MainViewModel mainVM)
@@ -60,7 +60,7 @@ public MainWindow(Settings settings, MainViewModel mainVM)
InitializeComponent();
InitializePosition();
- animationSound.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav"));
+ InitSoundEffects();
DataObject.AddPastingHandler(QueryTextBox, OnPaste);
}
@@ -140,9 +140,7 @@ private void OnLoaded(object sender, RoutedEventArgs _)
{
if (_settings.UseSound)
{
- animationSound.Position = TimeSpan.Zero;
- animationSound.Volume = _settings.SoundVolume / 100.0;
- animationSound.Play();
+ SoundPlay();
}
UpdatePosition();
PreviewReset();
@@ -508,6 +506,33 @@ public void WindowAnimator()
windowsb.Begin(FlowMainWindow);
}
+ private void InitSoundEffects()
+ {
+ if (_settings.WMPInstalled)
+ {
+ animationSoundWMP = new MediaPlayer();
+ animationSoundWMP.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav"));
+ }
+ else
+ {
+ animationSoundWPF = new SoundPlayer(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav");
+ }
+ }
+
+ private void SoundPlay()
+ {
+ if (_settings.WMPInstalled)
+ {
+ animationSoundWMP.Position = TimeSpan.Zero;
+ animationSoundWMP.Volume = _settings.SoundVolume / 100.0;
+ animationSoundWMP.Play();
+ }
+ else
+ {
+ animationSoundWPF.Play();
+ }
+ }
+
private void OnMouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left) DragMove();
diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs
index 89f4fe15c5d..bcdd94e1ca9 100644
--- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs
+++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs
@@ -181,13 +181,22 @@ public List AnimationSpeeds
return speeds;
}
}
-
public bool UseSound
{
get => Settings.UseSound;
set => Settings.UseSound = value;
}
+ public bool ShowWMPWarning
+ {
+ get => !Settings.WMPInstalled && UseSound;
+ }
+
+ public bool EnableVolumeAdjustment
+ {
+ get => Settings.WMPInstalled;
+ }
+
public double SoundEffectVolume
{
get => Settings.SoundVolume;
diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml
index 3b581767c10..c864d5e7dd1 100644
--- a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml
+++ b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml
@@ -4,12 +4,12 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cc="clr-namespace:Flow.Launcher.Resources.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:ext="clr-namespace:Flow.Launcher.Resources.MarkupExtensions"
xmlns:flowlauncher="clr-namespace:Flow.Launcher"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="http://schemas.modernwpf.com/2019"
xmlns:userSettings="clr-namespace:Flow.Launcher.Infrastructure.UserSettings;assembly=Flow.Launcher.Infrastructure"
xmlns:viewModels="clr-namespace:Flow.Launcher.SettingPages.ViewModels"
- xmlns:ext="clr-namespace:Flow.Launcher.Resources.MarkupExtensions"
Title="Theme"
d:DataContext="{d:DesignInstance viewModels:SettingsPaneThemeViewModel}"
d:DesignHeight="450"
@@ -25,22 +25,22 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+ Margin="0,4,0,0"
+ Icon=""
+ Sub="{DynamicResource shadowEffectCPUUsage}">
-
+
-
+
@@ -179,7 +179,7 @@
Margin="0"
Padding="0"
HorizontalAlignment="Stretch"
- BorderThickness="1 0 1 1"
+ BorderThickness="1,0,1,1"
CornerRadius="0 0 5 5"
Style="{DynamicResource SettingGroupBox}">