attempts to add my optional leadin (#2)

* attempts to add my optional leadin

speed will return to normal an optional number of seconds before the subs appear. Has worked for me so far, would you mind testing?

* Update speed-transition.lua

* Update speed-transition.lua
This commit is contained in:
bitingsock 2017-09-24 12:40:41 -07:00 committed by zenyd
parent ee31ae58b6
commit 883859f91c
1 changed files with 4 additions and 3 deletions

View File

@ -1,6 +1,7 @@
lookahead=5 --if nextsub >= lookahead then speedup
normalspeed=mp.get_property_native("speed")
speedup=2.5
leadin=1
-------------------
state=0
@ -41,8 +42,8 @@ function add_timers(nextsub)
if nextsub ~= 0 then
--make sure we reset the speed on the unlikely case when a timer fires
--within one second of the next sub
if nextsub - 1 > 0 then
mp.add_timeout((nextsub-1)/speedup, reset_early)
if nextsub - leadin > 0 then
mp.add_timeout((nextsub-leadin)/speedup, reset_early)
else
restore_normalspeed()
end
@ -50,7 +51,7 @@ function add_timers(nextsub)
elseif nextsub == 0 then
--search for next sub after time_out seconds, when its position might be known
if not mp.get_property_native("pause") and set_timeout() - 1 > 0 then
mp.add_timeout((time_out-1)/speedup, search_next_sub)
mp.add_timeout((time_out-leadin)/speedup, search_next_sub)
end
end
end