From 97ce08c4c7d74bbe44340b6a850ced19d5d8463c Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Sat, 7 Mar 2020 14:12:02 +0100 Subject: [PATCH] script-message mpv.net playlist-first --- Changelog.md | 2 ++ mpv.net/Misc/Command.cs | 18 +++++++++++++++++- mpv.net/Resources/inputConf.txt | 4 ++-- mpv.net/mpv/mp.cs | 2 +- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Changelog.md b/Changelog.md index ff60eab..614c0b9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,8 @@ ### - new: menu item 'View > Show Progress' (p key) to show progress bar +- new: `script-message mpv.net playlist-first`, unlike mpv does not + restart if the first file is already active - fix: update routine did only work when mpv.net was located in 'Program Files' - fix: errors were just ignored and only seen printed in the terminal in case mpv.net diff --git a/mpv.net/Misc/Command.cs b/mpv.net/Misc/Command.cs index 7d81937..70c0c4f 100644 --- a/mpv.net/Misc/Command.cs +++ b/mpv.net/Misc/Command.cs @@ -36,6 +36,7 @@ namespace mpvnet case "open-conf-folder": Process.Start(mp.ConfigFolder); break; case "shell-execute": Process.Start(args[0]); break; case "show-info": ShowInfo(); break; + case "playlist-first": PlaylistFirst(); break; case "playlist-last": PlaylistLast(); break; case "add-files-to-playlist": OpenFiles("append"); break; // deprecated 2019 default: Msg.ShowError($"No command '{id}' found."); break; @@ -101,7 +102,22 @@ namespace mpvnet })); } - public static void PlaylistLast() => mp.set_property_int("playlist-pos", mp.get_property_int("playlist-count") - 1); + public static void PlaylistFirst() + { + int pos = mp.get_property_int("playlist-pos"); + + if (pos != 0) + mp.set_property_int("playlist-pos", 0); + } + + public static void PlaylistLast() + { + int pos = mp.get_property_int("playlist-pos"); + int count = mp.get_property_int("playlist-count"); + + if (pos < count - 1) + mp.set_property_int("playlist-pos", count - 1); + } public static void ShowHistory() { diff --git a/mpv.net/Resources/inputConf.txt b/mpv.net/Resources/inputConf.txt index 30f6406..e599cd2 100644 --- a/mpv.net/Resources/inputConf.txt +++ b/mpv.net/Resources/inputConf.txt @@ -41,8 +41,8 @@ F11 playlist-prev #menu: Navigate > Previous File F12 playlist-next #menu: Navigate > Next File _ ignore #menu: Navigate > - - Home set playlist-pos 0 #menu: Navigate > First File - End script-message mpv.net playlist-last #menu: Navigate > Last File + Home script-message mpv.net playlist-first #menu: Navigate > First File + End script-message mpv.net playlist-last #menu: Navigate > Last File _ ignore #menu: Navigate > - PGUP add chapter 1 #menu: Navigate > Next Chapter PGDWN add chapter -1 #menu: Navigate > Previous Chapter diff --git a/mpv.net/mpv/mp.cs b/mpv.net/mpv/mp.cs index 6db59b2..d0f4c48 100644 --- a/mpv.net/mpv/mp.cs +++ b/mpv.net/mpv/mp.cs @@ -97,7 +97,7 @@ namespace mpvnet if (Handle == IntPtr.Zero) throw new Exception("error mpv_create"); - mpv_request_log_messages(Handle, "error"); + mpv_request_log_messages(Handle, "fatal"); Task.Run(() => EventLoop()); if (App.IsStartedFromTerminal)