From a15d2cdbbe44e0f7572f1ded24f3fdee4c1a4d12 Mon Sep 17 00:00:00 2001 From: stax76 Date: Sun, 1 May 2022 01:01:51 +0200 Subject: [PATCH] playlist-add command added --- docs/Changelog.md | 3 +++ docs/Manual.md | 4 ++++ src/Misc/Commands.cs | 20 ++++++++++++++++++++ src/Resources/input.conf.txt | 6 ++++-- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index f0928e0..3e6654c 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -1,6 +1,9 @@ - Fix keyboard layout change not working. - Fix multi monitor setup with different DPI values. +- New playlist-add command added to change the playlist position. + Ctrl+F11 goes 10 positions backward. + Ctrl+F12 goes 10 positions forward. 5.8.0.0 Beta (2022-04-02) diff --git a/docs/Manual.md b/docs/Manual.md index b95b2c9..334f965 100644 --- a/docs/Manual.md +++ b/docs/Manual.md @@ -255,6 +255,10 @@ or multiple files in the file clipboard format. Cycles the pause property. In case the playlist is empty, the most recent file from the recent files list is loaded. +### playlist-add \ +Changes the playlist position by adding the supplied integer value. +If the position goes out of range, it jumpes to the opposite end. + ### playlist-first Jumps to the first playlist entry, if the loaded file is already the first entry, nothing happens. diff --git a/src/Misc/Commands.cs b/src/Misc/Commands.cs index 2993443..c6d6d95 100644 --- a/src/Misc/Commands.cs +++ b/src/Misc/Commands.cs @@ -35,6 +35,7 @@ namespace mpvnet case "open-optical-media": Open_DVD_Or_BD_Folder(); break; case "open-url": OpenFromClipboard(); break; // deprecated 2022 case "play-pause": PlayPause(); break; + case "playlist-add": PlaylistAdd(Convert.ToInt32(args[0])); break; case "playlist-first": PlaylistFirst(); break; case "playlist-last": PlaylistLast(); break; case "reg-file-assoc": RegisterFileAssociations(args[0]); break; @@ -662,5 +663,24 @@ namespace mpvnet }); public static void ShowMenu() => Core.RaiseShowMenu(); + + public static void PlaylistAdd(int value) + { + int pos = Core.GetPropertyInt("playlist-pos"); + int count = Core.GetPropertyInt("playlist-count"); + + if (count < 2) + return; + + pos = pos + value; + + if (pos < 0) + pos = count - 1; + + if (pos > count - 1) + pos = 0; + + Core.SetPropertyInt("playlist-pos", pos); + } } } diff --git a/src/Resources/input.conf.txt b/src/Resources/input.conf.txt index 453eec1..e224e91 100644 --- a/src/Resources/input.conf.txt +++ b/src/Resources/input.conf.txt @@ -18,8 +18,8 @@ Ctrl+s stop #menu: Stop _ ignore #menu: - Enter cycle fullscreen #menu: Toggle Fullscreen -F11 playlist-prev; set pause no #menu: Navigate > Previous File -F12 playlist-next; set pause no #menu: Navigate > Next File +F11 script-message mpv.net playlist-add -1; set pause no #menu: Navigate > Previous File +F12 script-message mpv.net playlist-add 1; set pause no #menu: Navigate > Next File _ ignore #menu: Navigate > - Home script-message mpv.net playlist-first #menu: Navigate > First File End script-message mpv.net playlist-last #menu: Navigate > Last File @@ -171,6 +171,8 @@ MBTN_Right script-message mpv.net show-menu KP6 script-message mpv.net show-progress 7 script-message mpv.net cycle-audio Sharp script-message mpv.net cycle-audio +Ctrl+F11 script-message mpv.net playlist-add -10 +Ctrl+F12 script-message mpv.net playlist-add 10 8 cycle sub j cycle sub q quit