TOOLS/lua/status-line: improve and update

Updates the line once per second rather than once per frame, saving
quite a bit of CPU. Also completely stops the script while paused.
That aside, fixes the swapped checks for video and audio-only files and
adds bitrate printing.
This commit is contained in:
Rostislav Pehlivanov 2017-08-04 09:07:37 +01:00
parent 779031ad8f
commit 5ea390c07f
1 changed files with 27 additions and 6 deletions

View File

@ -18,10 +18,10 @@ function update_status_line()
atsl("(Buffering) ") atsl("(Buffering) ")
end end
if mp.get_property("vid") ~= "no" then if mp.get_property("aid") ~= "no" then
atsl("A") atsl("A")
end end
if mp.get_property("aid") ~= "no" then if mp.get_property("vid") ~= "no" then
atsl("V") atsl("V")
end end
@ -43,7 +43,7 @@ function update_status_line()
r = mp.get_property_number("avsync", nil) r = mp.get_property_number("avsync", nil)
if r ~= nil then if r ~= nil then
atsl(string.format(" A-V: %7.3f", r)) atsl(string.format(" A-V: %f", r))
end end
r = mp.get_property("total-avsync-change", 0) r = mp.get_property("total-avsync-change", 0)
@ -51,12 +51,24 @@ function update_status_line()
atsl(string.format(" ct:%7.3f", r)) atsl(string.format(" ct:%7.3f", r))
end end
r = mp.get_property_number("drop-frame-count", -1) r = mp.get_property_number("decoder-drop-frame-count", -1)
if r > 0 then if r > 0 then
atsl(" Late: ") atsl(" Late: ")
atsl(r) atsl(r)
end end
r = mp.get_property_osd("video-bitrate")
if r ~= nil and r ~= "" then
atsl(" Vb: ")
atsl(r)
end
r = mp.get_property_osd("audio-bitrate")
if r ~= nil and r ~= "" then
atsl(" Ab: ")
atsl(r)
end
r = mp.get_property_number("cache", 0) r = mp.get_property_number("cache", 0)
if r > 0 then if r > 0 then
atsl(string.format(" Cache: %d%% ", r)) atsl(string.format(" Cache: %d%% ", r))
@ -66,6 +78,15 @@ function update_status_line()
mp.set_property("options/term-status-msg", newStatus) mp.set_property("options/term-status-msg", newStatus)
end end
-- Register the event timer = mp.add_periodic_timer(1, update_status_line)
mp.register_event("tick", update_status_line)
function on_pause_change(name, value)
if value == false then
timer:resume()
else
timer:stop()
end
mp.add_timeout(0.1, update_status_line)
end
mp.observe_property("pause", "bool", on_pause_change)
mp.register_event("seek", update_status_line)