From 819b026ec7752c29214a1133339e2a1189667ae8 Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Thu, 23 Sep 2021 19:46:38 +0200 Subject: [PATCH] Window size flicker issue fix when changing files --- docs/Changelog.md | 3 +++ src/Misc/CorePlayer.cs | 19 +++++++++++-------- src/Misc/ExtensionMethods.cs | 2 +- src/Misc/MainForm.cs | 5 +---- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index c6bdd25..ace75e3 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -1,6 +1,9 @@ 5.5.0.4 Beta (202?-??-??) +- Window size flicker issue fix when changing files. + + 5.5.0.3 Beta (2021-09-23) - New mpv.net option auto-play which sets pause=no on file load and diff --git a/src/Misc/CorePlayer.cs b/src/Misc/CorePlayer.cs index 2f66d7c..7b1f779 100644 --- a/src/Misc/CorePlayer.cs +++ b/src/Misc/CorePlayer.cs @@ -94,7 +94,7 @@ namespace mpvnet public string ConfPath { get => ConfigFolder + "mpv.conf"; } public string GPUAPI { get; set; } = "auto"; public string InputConfPath { get => ConfigFolder + "input.conf"; } - + public string VID { get; set; } = ""; public string AID { get; set; } = ""; public string SID { get; set; } = ""; @@ -324,16 +324,17 @@ namespace mpvnet { Size size = new Size(GetPropertyInt(w), GetPropertyInt(h)); + if (size.Width == 0 || size.Height == 0) + return; + if (VideoRotate == 90 || VideoRotate == 270) size = new Size(size.Height, size.Width); - if (size.Width == 0 || size.Height == 0) - size = new Size(16, 9); - if (VideoSize != size) { VideoSize = size; InvokeEvent(VideoSizeChanged, VideoSizeChangedAsync); + VideoSizeAutoResetEvent.Set(); } } @@ -425,15 +426,17 @@ namespace mpvnet if (App.StartSize == "video") WasInitialSizeSet = false; - UpdateVideoSize("width", "height"); + string path = GetPropertyString("path"); - VideoSizeAutoResetEvent.Set(); + if (!VideoTypes.Contains(path.Ext()) || AudioTypes.Contains(path.Ext())) + { + UpdateVideoSize("width", "height"); + VideoSizeAutoResetEvent.Set(); + } App.RunTask(new Action(() => ReadMetaData())); App.RunTask(new Action(() => { - string path = GetPropertyString("path"); - if (path.Contains("://")) path = GetPropertyString("media-title"); diff --git a/src/Misc/ExtensionMethods.cs b/src/Misc/ExtensionMethods.cs index 6c43cc6..94024bc 100644 --- a/src/Misc/ExtensionMethods.cs +++ b/src/Misc/ExtensionMethods.cs @@ -68,7 +68,7 @@ public static class ConvertStringExtension public static class PathStringExtension { - // return extension with lower case and without dot. + // returns the extension with lower case and without preceding dot. public static string Ext(this string instance) { if (instance == null) diff --git a/src/Misc/MainForm.cs b/src/Misc/MainForm.cs index 5b1c29b..72d0377 100644 --- a/src/Misc/MainForm.cs +++ b/src/Misc/MainForm.cs @@ -1000,10 +1000,7 @@ namespace mpvnet protected override void OnLoad(EventArgs e) { base.OnLoad(e); - - if (Core.GPUAPI != "vulkan") - Core.VideoSizeAutoResetEvent.WaitOne(App.StartThreshold); - + Core.VideoSizeAutoResetEvent.WaitOne(App.StartThreshold); LastCycleFullscreen = Environment.TickCount; SetFormPosAndSize(); }