mirror of https://github.com/mpv-player/mpv
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:
parent
779031ad8f
commit
5ea390c07f
|
@ -18,10 +18,10 @@ function update_status_line()
|
|||
atsl("(Buffering) ")
|
||||
end
|
||||
|
||||
if mp.get_property("vid") ~= "no" then
|
||||
if mp.get_property("aid") ~= "no" then
|
||||
atsl("A")
|
||||
end
|
||||
if mp.get_property("aid") ~= "no" then
|
||||
if mp.get_property("vid") ~= "no" then
|
||||
atsl("V")
|
||||
end
|
||||
|
||||
|
@ -43,7 +43,7 @@ function update_status_line()
|
|||
|
||||
r = mp.get_property_number("avsync", nil)
|
||||
if r ~= nil then
|
||||
atsl(string.format(" A-V: %7.3f", r))
|
||||
atsl(string.format(" A-V: %f", r))
|
||||
end
|
||||
|
||||
r = mp.get_property("total-avsync-change", 0)
|
||||
|
@ -51,12 +51,24 @@ function update_status_line()
|
|||
atsl(string.format(" ct:%7.3f", r))
|
||||
end
|
||||
|
||||
r = mp.get_property_number("drop-frame-count", -1)
|
||||
r = mp.get_property_number("decoder-drop-frame-count", -1)
|
||||
if r > 0 then
|
||||
atsl(" Late: ")
|
||||
atsl(r)
|
||||
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)
|
||||
if r > 0 then
|
||||
atsl(string.format(" Cache: %d%% ", r))
|
||||
|
@ -66,6 +78,15 @@ function update_status_line()
|
|||
mp.set_property("options/term-status-msg", newStatus)
|
||||
end
|
||||
|
||||
-- Register the event
|
||||
mp.register_event("tick", update_status_line)
|
||||
timer = mp.add_periodic_timer(1, 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)
|
||||
|
|
Loading…
Reference in New Issue