From 0efc3352327e3033578016661f90dd5b50c3f3f4 Mon Sep 17 00:00:00 2001 From: stax76 Date: Sat, 21 May 2022 08:31:06 +0200 Subject: [PATCH] new quick bookmark feature --- docs/Changelog.md | 1 + docs/Manual.md | 6 ++++++ src/Misc/App.cs | 1 + src/Misc/Commands.cs | 18 +++++++++++++++++- src/Misc/Player.cs | 4 ++-- src/Resources/input.conf.txt | 3 ++- 6 files changed, 29 insertions(+), 4 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index 0604909..dc07e32 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -1,4 +1,5 @@ +- New quick bookmark feature, see manual. - Fix crash choosing Matroska edition in the menu. - Fix auto-play not working with user scripts. - When input.conf is created on the very first start and a diff --git a/docs/Manual.md b/docs/Manual.md index cb52b8d..7c0e27a 100644 --- a/docs/Manual.md +++ b/docs/Manual.md @@ -271,6 +271,12 @@ already the first entry, nothing happens. Jumps to the last playlist entry, if the loaded file is already the last entry, nothing happens. +### quick-bookmark + +On the first press a bookmark is saved, on the second +press it is restored and removed. When a new file is +loaded the bookmark is removed. + ### reg-file-assoc \ Registers the file associations. diff --git a/src/Misc/App.cs b/src/Misc/App.cs index 4f16ad1..d710d84 100644 --- a/src/Misc/App.cs +++ b/src/Misc/App.cs @@ -36,6 +36,7 @@ namespace mpvnet public static int RecentCount { get; set; } = 15; public static float MinimumAspectRatio { get; set; } = 1.2f; + public static float QuickBookmark { get; set; } public static Extension Extension { get; set; } diff --git a/src/Misc/Commands.cs b/src/Misc/Commands.cs index bb19338..50beed3 100644 --- a/src/Misc/Commands.cs +++ b/src/Misc/Commands.cs @@ -38,6 +38,7 @@ namespace mpvnet case "playlist-add": PlaylistAdd(Convert.ToInt32(args[0])); break; case "playlist-first": PlaylistFirst(); break; case "playlist-last": PlaylistLast(); break; + case "quick-bookmark": QuickBookmark(); break; case "reg-file-assoc": RegisterFileAssociations(args[0]); break; case "scale-window": ScaleWindow(float.Parse(args[0], CultureInfo.InvariantCulture)); break; case "shell-execute": ProcessHelp.ShellExecute(args[0]); break; @@ -241,7 +242,8 @@ namespace mpvnet string text = FormatTime(position.TotalMinutes) + ":" + FormatTime(position.Seconds) + " / " + FormatTime(duration.TotalMinutes) + ":" + - FormatTime(duration.Seconds); + FormatTime(duration.Seconds) + " " + + DateTime.Now.ToString("H:mm dddd d MMMM", CultureInfo.InvariantCulture); Core.CommandV("show-text", text, "5000"); } @@ -670,5 +672,19 @@ namespace mpvnet Core.SetPropertyInt("playlist-pos", pos); } + + public static void QuickBookmark() + { + if (App.QuickBookmark == 0) + { + App.QuickBookmark = (float)Core.GetPropertyDouble("time-pos"); + Core.Command("show-text 'Bookmark Saved'"); + } + else + { + Core.SetPropertyDouble("time-pos", App.QuickBookmark); + App.QuickBookmark = 0; + } + } } } diff --git a/src/Misc/Player.cs b/src/Misc/Player.cs index a21e672..e2dcc67 100644 --- a/src/Misc/Player.cs +++ b/src/Misc/Player.cs @@ -479,9 +479,9 @@ namespace mpvnet { if (App.AutoPlay && Paused) SetPropertyBool("pause", false); - - HideLogo(); + App.QuickBookmark = 0; + HideLogo(); Duration = TimeSpan.FromSeconds(GetPropertyDouble("duration")); if (App.StartSize == "video") diff --git a/src/Resources/input.conf.txt b/src/Resources/input.conf.txt index 9dfff0f..5610df2 100644 --- a/src/Resources/input.conf.txt +++ b/src/Resources/input.conf.txt @@ -175,6 +175,7 @@ KP9 ab-loop 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 +Alt+q script-message mpv.net quick-bookmark 8 cycle sub j cycle sub q quit @@ -209,4 +210,4 @@ Shift+Ctrl+BS revert-seek mark # mark the position for revert-seek Ctrl+Shift+Left no-osd sub-seek -1 # seek to the previous subtitle Ctrl+Shift+Right no-osd sub-seek 1 # seek to the next subtitle Ctrl+Wheel_Up no-osd seek 7 -Ctrl+Wheel_Down no-osd seek -7 +Ctrl+Wheel_Down no-osd seek -7 \ No newline at end of file