[mpv] more control in catch_up

This commit is contained in:
odrling 2021-03-26 21:41:28 +01:00
parent 88584be158
commit d27380cf4b
2 changed files with 27 additions and 6 deletions

View file

@ -209,6 +209,8 @@ Y cycle sub-font-provider
y run /bin/sh -c "echo ${path} | clipboard" ; show-text "path copied to clipboard"
² script-binding repl-enable
P script-binding catch_up
Ctrl+p script-binding increase_catch_up
Ctrl+P script-binding decrease_catch_up
Ctrl+a cycle-values ao null jack
Ctrl+v cycle-values video-aspect "16:9" "4:3" "2.35:1" "-1"
C script-binding add_chapter
@ -231,8 +233,8 @@ u cycle-values sub-ass-override no yes force
# hardware decoding
Ctrl+h cycle-values hwdec "no" "auto" "auto-copy"
# i am speed
k add speed 0.1
K add speed -0.1
k add speed 0.05
K add speed -0.05
Ctrl+k multiply speed 2.0
Ctrl+K multiply speed 0.5
BS set speed 1.0

View file

@ -11,16 +11,18 @@ opts.read_options(settings, "catch_up")
local catch_up = false
local catch_up_timeout = 1
local catchup_until = settings.catchup_until
function stop_catchup()
local remaining = mp.get_property("demuxer-cache-time") - mp.get_property("playback-time")
local remaining = mp.get_property_number("demuxer-cache-duration")
if remaining < settings.catchup_until then
if remaining < catchup_until then
mp.set_property("speed", 1.00)
catch_up = false
else
mp.add_timeout(2, stop_catchup)
mp.add_timeout(catch_up_timeout, stop_catchup)
end
end
@ -31,11 +33,28 @@ function catchup()
if catch_up then
mp.set_property("speed", settings.speed_up)
mp.set_property("pause", "no")
mp.add_timeout(2, stop_catchup)
mp.add_timeout(catch_up_timeout, stop_catchup)
else
mp.set_property("speed", 1.00)
end
end
local UPDATE_AMOUNT = 1
function update_catch_up_until(amount)
catchup_until = catchup_until + amount
mp.osd_message(("catch up until: %d"):format(catchup_until))
end
function increase_catch_up()
update_catch_up_until(1)
end
function decrease_catch_up()
update_catch_up_until(-1)
end
mp.add_key_binding("P", "catch_up", catchup)
mp.add_key_binding("Ctrl+p", "increase_catch_up", increase_catch_up)
mp.add_key_binding("Ctrl+P", "decrease_catch_up", decrease_catch_up)