diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Plugin.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Plugin.cs
index 311c725c7..02014b085 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Plugin.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Plugin.cs
@@ -19,6 +19,7 @@
using QuickLook.MediaInfo;
using QuickLook.MediaInfo.Core;
using System;
+using System.Globalization;
using System.IO;
using System.Reflection;
using System.Windows;
@@ -83,6 +84,9 @@ public bool CanHandle(string path)
return false;
}
+ ///
+ /// Configures the preview window, accounting for video dimensions and rotation.
+ ///
public void Prepare(string path, ContextObject context)
{
string videoCodec = _mediaInfo.Get(StreamKind.Video, 0, "Format");
@@ -90,11 +94,8 @@ public void Prepare(string path, ContextObject context)
{
int.TryParse(_mediaInfo.Get(StreamKind.Video, 0, "Width"), out var width);
int.TryParse(_mediaInfo.Get(StreamKind.Video, 0, "Height"), out var height);
- double.TryParse(_mediaInfo.Get(StreamKind.Video, 0, "Rotation"), out var rotation);
-
- // Correct rotation: on some machine the value "90" becomes "90000" by some reason
- if (rotation > 360)
- rotation /= 1e3;
+ // Parse "90.000" as 90 in every culture, avoiding 90000 (de-DE) or 0 (ru-RU).
+ double.TryParse(_mediaInfo.Get(StreamKind.Video, 0, "Rotation"), NumberStyles.Float, CultureInfo.InvariantCulture, out var rotation);
var windowSize = new Size
{
diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs
index 6d7c5a489..d926e9152 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs
@@ -25,6 +25,7 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
+using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
@@ -455,6 +456,9 @@ private void HardwareAccelerationModeChanged(bool enable)
}
}
+ ///
+ /// Loads media for playback and applies video rotation from its metadata.
+ ///
public void LoadAndPlay(string path, MediaInfoNative info)
{
// Detect whether it is other playback formats
@@ -473,10 +477,7 @@ public void LoadAndPlay(string path, MediaInfoNative info)
UpdateMeta(path, info);
// detect rotation
- _ = double.TryParse(info?.Get(StreamKind.Video, 0, "Rotation"), out var rotation);
- // Correct rotation: on some machine the value "90" becomes "90000" by some reason
- if (rotation > 360d)
- rotation /= 1e3;
+ _ = double.TryParse(info?.Get(StreamKind.Video, 0, "Rotation"), NumberStyles.Float, CultureInfo.InvariantCulture, out var rotation);
if (Math.Abs(rotation) > 0.1d)
mediaElement.LayoutTransform = new RotateTransform(rotation, 0.5d, 0.5d);