From 8b6ab6b037487a0e39e713bd6543da2e8387f82d Mon Sep 17 00:00:00 2001 From: ema Date: Mon, 2 Jun 2025 13:17:41 +0800 Subject: [PATCH] Fix old version volume exception #1653 --- .../QuickLook.Plugin.VideoViewer/Converters.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Converters.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Converters.cs index 1f13b15..bab2ba9 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Converters.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Converters.cs @@ -53,16 +53,17 @@ public sealed class VolumeToIconConverter : DependencyObject, IValueConverter public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - if (value == null) - return Volumes[0]; + if (value is double v) + { + // Clump to range [0, 1] + v = Math.Max(0d, Math.Min(v, 1d)); - var v = (double)value; - if (Math.Abs(v) < 0.01) - return Volumes[0]; + if (v < 0.01d) return Volumes[0]; - v = Math.Min(v, 1); + return Volumes[1 + (int)(v / 0.34d)]; + } - return Volumes[1 + (int)(v / 0.34)]; + return Volumes[0]; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)