From e8baa21d42f3bac243bb5db3e6ff172e04fd03e8 Mon Sep 17 00:00:00 2001 From: stax76 Date: Sun, 22 May 2022 14:35:43 +0200 Subject: [PATCH] Fix auto-load-folder not working with user scripts --- docs/Changelog.md | 3 ++- src/Misc/Commands.cs | 10 +++++++--- src/Misc/Player.cs | 6 +++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index f6d79f3..113d749 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -8,7 +8,8 @@ is created with defaults for osc and console. - Support mpv idle property, see manual for remarks. - Fix crash choosing Matroska edition in the menu. -- Fix auto-play not working with user scripts. +- Fix auto-play and auto-load-folder not working + with user scripts. - Fix slow startup using osd-scale-by-window=no. - Fix chapter time display in menu. - libmpv shinchiro 2022-05-17 with idle fix diff --git a/src/Misc/Commands.cs b/src/Misc/Commands.cs index 6475c53..d4f2cd9 100644 --- a/src/Misc/Commands.cs +++ b/src/Misc/Commands.cs @@ -259,15 +259,19 @@ namespace mpvnet else { string clipboard = WinForms.Clipboard.GetText(); + List files = new List(); - if (string.IsNullOrEmpty(clipboard) || (!clipboard.Contains("://") && !File.Exists(clipboard)) || - clipboard.Contains("\n")) + foreach (string i in clipboard.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)) + if (i.Contains("://") || File.Exists(i)) + files.Add(i); + + if (files.Count == 0) { App.ShowError("The clipboard does not contain a valid URL or file."); return; } - Core.LoadFiles(new [] { clipboard }, false, Control.ModifierKeys.HasFlag(Keys.Control)); + Core.LoadFiles(files.ToArray(), false, Control.ModifierKeys.HasFlag(Keys.Control)); } }); diff --git a/src/Misc/Player.cs b/src/Misc/Player.cs index 334ec55..f7c5fd1 100644 --- a/src/Misc/Player.cs +++ b/src/Misc/Player.cs @@ -583,6 +583,7 @@ namespace mpvnet break; case mpv_event_id.MPV_EVENT_START_FILE: InvokeEvent(StartFile, StartFileAsync); + App.RunTask(() => LoadFolder()); break; case mpv_event_id.MPV_EVENT_AUDIO_RECONFIG: InvokeEvent(AudioReconfig, AudioReconfigAsync); @@ -1225,7 +1226,10 @@ namespace mpvnet string dir = Environment.CurrentDirectory; - if (path.Contains(Path.DirectorySeparatorChar)) + if (path.Contains(":/") && !path.Contains("://")) + path = path.Replace("/", "\\"); + + if (path.Contains("\\")) dir = Path.GetDirectoryName(path); List files = Directory.GetFiles(dir).ToList();