Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Script will pause at the beginning of each new subtitle for the amount of time that
- -- the subtitle would normally appear on the screen, multiplied by FACTOR.
- -- So if a sub was going to appear for 4 seconds and you have a FACTOR of 0.5 then
- -- then there will be a 2 second pause when that subtitle appears.
- local FACTOR = 0.9
- -- Set to true if you only want the subs displayed during the automatic pause
- local HIDE_SUB_AFTER_PAUSE = true
- -- Set to true if you want to anime to stay paused when you press spacebar or whatever
- -- during one of the auto-pauses. Normal behavior is that pressing space would unpause
- -- rather than switch into a permanently paused state that you must manually unpause.
- local ENABLE_PERMA_PAUSE = true
- local pause_disease = false
- local auto_paused = true
- local function unpause()
- if auto_paused then
- mp.set_property_native("pause", false)
- auto_paused = false
- if HIDE_SUB_AFTER_PAUSE then
- mp.set_property_bool("sub-visibility", false)
- end
- end
- end
- local function pause(_, subtxt)
- if not pause_disease or mp.get_property_number('sub-end') == nil or mp.get_property_bool("pause") then
- return
- end
- mp.set_property_bool("sub-visibility", true)
- if subtxt ~= "" then
- mp.set_property_native("pause", true)
- local pause_length = FACTOR * (mp.get_property_number('sub-end') - mp.get_property_number('sub-start'))
- auto_paused = true
- mp.add_timeout(pause_length, unpause)
- end
- end
- local function toggle_pause_disease()
- pause_disease = not pause_disease
- mp.osd_message("Pause disease " .. (pause_disease and "activated" or "deactived"), 3)
- end
- local function handle_pause_req(_, val)
- -- user is trying to "resume" during an auto-pause, switch modes to a regular pause
- if ENABLE_PERMA_PAUSE and val == false then
- if HIDE_SUB_AFTER_PAUSE and auto_paused == false then
- mp.set_property_bool("sub-visibility", false)
- end
- if auto_paused then
- auto_paused = false
- mp.set_property_native("pause", true)
- end
- end
- end
- mp.add_key_binding("ctrl+p", toggle_pause_disease)
- mp.observe_property("sub-text", 'string', pause)
- mp.observe_property("pause", "bool", handle_pause_req)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement