From fee13353ecb1813f1efd41c9188af7823624b6a3 Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Sun, 19 Apr 2020 18:51:54 +0200 Subject: [PATCH] seek-show-position script removed --- mpv.net/Resources/input.conf.txt | 14 +++++------ mpv.net/mpv/mp.cs | 2 +- scripts/excluded/seek-show-position.js | 35 ++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 scripts/excluded/seek-show-position.js diff --git a/mpv.net/Resources/input.conf.txt b/mpv.net/Resources/input.conf.txt index 45f5ba3..fcde0b0 100644 --- a/mpv.net/Resources/input.conf.txt +++ b/mpv.net/Resources/input.conf.txt @@ -16,8 +16,6 @@ # mpv input commands: https://mpv.io/manual/master/#list-of-input-commands - # mpv input keys: https://github.com/stax76/mpv.net/wiki/mpv-input-keys - # run mpv.net in input test mode with: mpvnet --input-test o script-message mpv.net open-files #menu: Open > Open Files... @@ -50,14 +48,14 @@ . frame-step #menu: Navigate > Jump Next Frame , frame-back-step #menu: Navigate > Jump Previous Frame _ ignore #menu: Navigate > - - Right no-osd seek 7 #menu: Navigate > Jump 7 sec forward - Left no-osd seek -7 #menu: Navigate > Jump 7 sec backward + Right seek 7 #menu: Navigate > Jump 7 sec forward + Left seek -7 #menu: Navigate > Jump 7 sec backward _ ignore #menu: Navigate > - - Up no-osd seek 40 #menu: Navigate > Jump 40 sec forward - Down no-osd seek -40 #menu: Navigate > Jump 40 sec backward + Up seek 40 #menu: Navigate > Jump 40 sec forward + Down seek -40 #menu: Navigate > Jump 40 sec backward _ ignore #menu: Navigate > - - Ctrl+Right no-osd seek 300 #menu: Navigate > Jump 5 min forward - Ctrl+Left no-osd seek -300 #menu: Navigate > Jump 5 min backward + Ctrl+Right seek 300 #menu: Navigate > Jump 5 min forward + Ctrl+Left seek -300 #menu: Navigate > Jump 5 min backward _ ignore #menu: Navigate > - _ ignore #menu: Navigate > Chapters diff --git a/mpv.net/mpv/mp.cs b/mpv.net/mpv/mp.cs index bf99a86..71b0701 100644 --- a/mpv.net/mpv/mp.cs +++ b/mpv.net/mpv/mp.cs @@ -267,7 +267,7 @@ namespace mpvnet commandv("load-script", $"{path}"); } - public static string[] KnownScripts { get; } = { "show-playlist.js", "seek-show-position.js" }; + public static string[] KnownScripts { get; } = { "show-playlist.js"}; public static void LoadScripts() { diff --git a/scripts/excluded/seek-show-position.js b/scripts/excluded/seek-show-position.js new file mode 100644 index 0000000..e3a0e96 --- /dev/null +++ b/scripts/excluded/seek-show-position.js @@ -0,0 +1,35 @@ + +// When seeking displays position and duration like so: 70:00 / 80:00 +// Which is different from most players which use: 01:10:00 / 01:20:00 +// In input.conf set the input command prefix no-osd infront of the seek command. + +function add_zero(val) +{ + val = Math.round(val); + return val > 9 ? "" + val : "0" + val; +} + +function format(val) +{ + var sec = Math.round(val); + + if (sec < 0) + sec = 0; + + pos_min_floor = Math.floor(sec / 60); + sec_rest = sec - pos_min_floor * 60; + return add_zero(pos_min_floor) + ":" + add_zero(sec_rest); +} + +function on_seek(_) +{ + pos = mp.get_property_number("time-pos"); + dur = mp.get_property_number("duration"); + + if (pos > dur) + pos = dur; + + mp.commandv("show-text", format(pos) + " / " + format(dur)); +} + +mp.register_event("seek", on_seek);