From dbc8ddaf2b09daf69aab8eb7ae82ffed32f4ac6e Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Sat, 20 Jun 2020 03:35:27 +0200 Subject: [PATCH] misc --- Changelog.md | 2 +- mpv.net/Misc/Help.cs | 6 +++++- mpv.net/Misc/PowerShell.cs | 2 +- mpv.net/Resources/input.conf.txt | 2 +- mpv.net/Resources/mpv.conf.txt | 1 - mpv.net/Update.ps1 | 3 +++ mpv.net/WinForms/MainForm.cs | 9 --------- mpv.net/WinForms/Menu.cs | 3 +-- mpv.net/mpv/Core.cs | 21 +++++++++++++++------ 9 files changed, 27 insertions(+), 22 deletions(-) diff --git a/Changelog.md b/Changelog.md index 726b773..faaccf9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,7 +2,7 @@ 5.4.8.2 Beta (not yet released) ============ - +- CLI --shuffle issue fix 5.4.8.1 Beta diff --git a/mpv.net/Misc/Help.cs b/mpv.net/Misc/Help.cs index cd19bfa..63a8a6a 100644 --- a/mpv.net/Misc/Help.cs +++ b/mpv.net/Misc/Help.cs @@ -45,7 +45,11 @@ namespace mpvnet if (Padding > 0 && value.Length < Padding) value = value.PadRight(Padding); - Console.WriteLine(value); + if (color == ConsoleColor.Red) + Console.Error.WriteLine(value); + else + Console.WriteLine(value); + Console.ResetColor(); Trace.WriteLine(obj); } diff --git a/mpv.net/Misc/PowerShell.cs b/mpv.net/Misc/PowerShell.cs index 904d766..b693a68 100644 --- a/mpv.net/Misc/PowerShell.cs +++ b/mpv.net/Misc/PowerShell.cs @@ -26,7 +26,7 @@ namespace mpvnet public List> EventHandlers = new List>(); public List> PropChangedHandlers = new List>(); - public static List Instances { get; } = new List(); + public static List References { get; } = new List(); public object Invoke() => Invoke(null, null); diff --git a/mpv.net/Resources/input.conf.txt b/mpv.net/Resources/input.conf.txt index b5c69af..f84e5d8 100644 --- a/mpv.net/Resources/input.conf.txt +++ b/mpv.net/Resources/input.conf.txt @@ -164,7 +164,7 @@ h script-message mpv.net show-history #menu: Tools > Show History l ab-loop #menu: Tools > Set/clear A-B loop points L cycle-values loop-file "inf" "no" #menu: Tools > Toggle infinite file looping - _ cycle shuffle #menu: Tools > Toggle Shuffle + _ playlist-shuffle #menu: Tools > Shuffle Playlist Ctrl+h cycle-values hwdec "auto" "no" #menu: Tools > Toggle Hardware Decoding _ script-message mpv.net show-setup-dialog #menu: Tools > Setup... diff --git a/mpv.net/Resources/mpv.conf.txt b/mpv.net/Resources/mpv.conf.txt index 84ac8d5..a22a874 100644 --- a/mpv.net/Resources/mpv.conf.txt +++ b/mpv.net/Resources/mpv.conf.txt @@ -8,7 +8,6 @@ osd-duration = 2000 osd-playing-msg = '${filename}' script-opts = osc-scalewindowed=1.5,osc-hidetimeout=2000,console-scale=1 screenshot-directory = '~~desktop/' -hwdec = yes [protocol.https] osd-playing-msg = '${media-title}' diff --git a/mpv.net/Update.ps1 b/mpv.net/Update.ps1 index c195df7..8d475fe 100644 --- a/mpv.net/Update.ps1 +++ b/mpv.net/Update.ps1 @@ -3,16 +3,19 @@ $ErrorActionPreference = 'Stop' if ($args.Length -ne 2) { Write-Host 'Invalid arguments' -ForegroundColor Red + pause exit } if (-not (Get-Command curl.exe)) { Write-Host 'Error using curl.exe' -ForegroundColor Red + pause exit } if ($PSVersionTable.PSVersion.Major -lt 5) { Write-Host 'PowerShell 5.1 not found' -ForegroundColor Red + pause exit } diff --git a/mpv.net/WinForms/MainForm.cs b/mpv.net/WinForms/MainForm.cs index 7960635..7b40e14 100644 --- a/mpv.net/WinForms/MainForm.cs +++ b/mpv.net/WinForms/MainForm.cs @@ -582,15 +582,6 @@ namespace mpvnet int d_w = (int)(c_h * aspect - c_w); int d_h = (int)(c_w / aspect - c_h); - Debug.WriteLine(d_w); - Debug.WriteLine(d_h); - - int d_w2 = (int)(c_h * aspect - c_w); - int d_h2 = (int)(c_w / aspect - c_h); - - Debug.WriteLine(d_w2); - Debug.WriteLine(d_h2); - int[] d_corners = { d_w, d_h, -d_w, -d_h }; int[] corners = { rc.Left, rc.Top, rc.Right, rc.Bottom }; int corner = NativeHelp.GetResizeBorder(m.WParam.ToInt32()); diff --git a/mpv.net/WinForms/Menu.cs b/mpv.net/WinForms/Menu.cs index c374cd2..7adb070 100644 --- a/mpv.net/WinForms/Menu.cs +++ b/mpv.net/WinForms/Menu.cs @@ -237,8 +237,7 @@ public class ToolStripRendererEx : ToolStripSystemRenderer RectangleF rectF = new RectangleF(rect.X + rect.Height / 2f - ellipseWidth / 2f, rect.Y + rect.Height / 2f - ellipseWidth / 2f, - ellipseWidth, - ellipseWidth); + ellipseWidth, ellipseWidth); using (Brush brush = new SolidBrush(ForegroundColor)) e.Graphics.FillEllipse(brush, rectF); diff --git a/mpv.net/mpv/Core.cs b/mpv.net/mpv/Core.cs index b34e15a..b97d005 100644 --- a/mpv.net/mpv/Core.cs +++ b/mpv.net/mpv/Core.cs @@ -366,8 +366,8 @@ namespace mpvnet ps.Module = Path.GetFileName(file); ps.Print = true; - lock (PowerShell.Instances) - PowerShell.Instances.Add(ps); + lock (PowerShell.References) + PowerShell.References.Add(ps); ps.Invoke(); } @@ -874,6 +874,7 @@ namespace mpvnet public void ProcessCommandLine(bool preInit) { + bool shuffle = false; var args = Environment.GetCommandLineArgs().Skip(1); string[] preInitProperties = { "input-terminal", "terminal", "input-file", "config", @@ -919,7 +920,12 @@ namespace mpvnet core.ProcessProperty(left, right); if (!App.ProcessProperty(left, right)) + { set_property_string(left, right, true); + + if (left == "shuffle" && right == "yes") + shuffle = true; + } } } catch (Exception e) @@ -935,16 +941,19 @@ namespace mpvnet List files = new List(); foreach (string i in args) - { if (!i.StartsWith("--") && (i == "-" || i.Contains("://") || i.Contains(":\\") || i.StartsWith("\\\\") || File.Exists(i))) - { + files.Add(i); - } - } LoadFiles(files.ToArray(), !App.Queue, Control.ModifierKeys.HasFlag(Keys.Control) || App.Queue); + if (shuffle) + { + core.command("playlist-shuffle"); + set_property_int("playlist-pos", 0); + } + if (files.Count == 0 || files[0].Contains("://")) { VideoSizeChanged?.Invoke();