From a148c88435c4519117777b916b8ffc44c73e5733 Mon Sep 17 00:00:00 2001 From: stax76 Date: Sun, 19 Jun 2022 18:06:08 +0200 Subject: [PATCH] new option minimum-aspect-ratio-audio --- docs/Changelog.md | 3 ++- docs/Manual.md | 11 +++++++---- src/Misc/App.cs | 4 +++- src/Resources/editor_conf.txt | 10 ++++++++-- src/WinForms/MainForm.cs | 9 ++++++--- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index f85099e..f56b5bd 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -2,10 +2,11 @@ # 6.0.0.1 Beta (not yet released) - New tutorial: [Extending mpv and mpv.net via Lua scripting](https://github.com/stax76/mpv.net/wiki/Extending-mpv-and-mpv.net-via-Lua-scripting) -- New options `autofit-image` and `autofit-audio`, like autofit but used for image and audio files. Default 80. +- New options `autofit-image` and `autofit-audio`, like autofit but used for image and audio files. - New [auto-mode](https://github.com/stax76/mpv-scripts) script to use mpv and mpv.net as image viewer and audio player. - New support of the mpv option `snap-window`. - New feature to show chapters in the command palette, see binding and menu definition below. +- New option minimum-aspect-ratio-audio, same as minimum-aspect-ratio but used for audio files. - Fix long commands causing key bindings not visible in the command palette. - Fix script compatibility with mordenx and mpv-osc-tethys. - Fix borderless window not resizable with mouse. diff --git a/docs/Manual.md b/docs/Manual.md index e837343..69b2b5b 100644 --- a/docs/Manual.md +++ b/docs/Manual.md @@ -388,7 +388,7 @@ mpv.net specific options can be found in the conf editor searching for 'mpv.net' The options are saved in the mpvnet.conf file. #### --autofit-audio \ -Initial window height in percent for audio files. Default: 80 +Initial window height in percent for audio files. Default: 70 #### --autofit-image \ Initial window height in percent for image files. Default: 80 @@ -439,9 +439,12 @@ Window size is always remembered. #### --minimum-aspect-ratio=\ -Minimum aspect ratio, if the AR is smaller than the defined value then -the window AR is set to 16/9. This avoids a square window for Music -with cover art. Default: 0 +Minimum aspect ratio of the window. Useful to force +a wider window and therefore a larger OSC. + +#### --minimum-aspect-ratio-audio=\ + +Same as minimum-aspect-ratio but used for audio files. #### --remember-window-position=\ diff --git a/src/Misc/App.cs b/src/Misc/App.cs index 847d640..6600b2e 100644 --- a/src/Misc/App.cs +++ b/src/Misc/App.cs @@ -36,9 +36,10 @@ namespace mpvnet public static int StartThreshold { get; set; } = 1500; public static int RecentCount { get; set; } = 15; - public static float AutofitAudio { get; set; } = 0.8f; + public static float AutofitAudio { get; set; } = 0.7f; public static float AutofitImage { get; set; } = 0.8f; public static float MinimumAspectRatio { get; set; } + public static float MinimumAspectRatioAudio { get; set; } public static float QuickBookmark { get; set; } public static Extension Extension { get; set; } @@ -252,6 +253,7 @@ namespace mpvnet case "light-theme": LightTheme = value.Trim('\'', '"'); return true; case "media-info": MediaInfo = value == "yes"; return true; case "minimum-aspect-ratio": MinimumAspectRatio = value.ToFloat(); return true; + case "minimum-aspect-ratio-audio": MinimumAspectRatioAudio = value.ToFloat(); return true; case "process-instance": ProcessInstance = value; return true; case "queue": Queue = value == "yes"; return true; case "recent-count": RecentCount = value.ToInt(); return true; diff --git a/src/Resources/editor_conf.txt b/src/Resources/editor_conf.txt index 6ea1064..8677a7d 100644 --- a/src/Resources/editor_conf.txt +++ b/src/Resources/editor_conf.txt @@ -420,7 +420,7 @@ help = Initial window height in percent for image files. Default: 80 name = autofit-audio file = mpvnet filter = Screen -help = Initial window height in percent for audio files. Default: 80 +help = Initial window height in percent for audio files. Default: 70 [setting] name = autofit-smaller @@ -463,7 +463,13 @@ option = no name = minimum-aspect-ratio file = mpvnet filter = Screen -help = Minimum aspect ratio, if the AR is smaller than the defined value then the window AR is set to 16/9. This avoids a square window for Music with cover art. Default: 0 (mpv.net specific option) +help = Minimum aspect ratio of the window. Useful to force a wider window and therefore a larger OSC. (mpv.net specific option) + +[setting] +name = minimum-aspect-ratio-audio +file = mpvnet +filter = Screen +help = Same as minimum-aspect-ratio but used for audio files. [setting] name = remember-window-position diff --git a/src/WinForms/MainForm.cs b/src/WinForms/MainForm.cs index 70c72b6..9dc8008 100644 --- a/src/WinForms/MainForm.cs +++ b/src/WinForms/MainForm.cs @@ -437,11 +437,14 @@ namespace mpvnet if (Core.IsAudio) autoFitHeight = Convert.ToInt32(workingArea.Height * App.AutofitAudio); if (Core.IsImage) autoFitHeight = Convert.ToInt32(workingArea.Height * App.AutofitImage); - if (Core.VideoSize.Height == 0 || Core.VideoSize.Width == 0 || - Core.VideoSize.Width / (float)Core.VideoSize.Height < App.MinimumAspectRatio) - + if (Core.VideoSize.Height == 0 || Core.VideoSize.Width == 0) Core.VideoSize = new Size((int)(autoFitHeight * (16 / 9f)), autoFitHeight); + float minAspectRatio = Core.IsAudio ? App.MinimumAspectRatioAudio : App.MinimumAspectRatio; + + if (minAspectRatio != 0 && Core.VideoSize.Width / (float)Core.VideoSize.Height < minAspectRatio) + Core.VideoSize = new Size((int)(autoFitHeight * minAspectRatio), autoFitHeight); + Size videoSize = Core.VideoSize; int height = videoSize.Height;