2014-08-11 15:08:32 +00:00
|
|
|
-- Rebuild the terminal status line as a lua script
|
2014-04-12 17:29:47 +00:00
|
|
|
-- Be aware that this will require more cpu power!
|
2015-05-25 20:01:34 +00:00
|
|
|
-- Also, this is based on a rather old version of the
|
|
|
|
-- builtin mpv status line.
|
2014-04-12 17:29:47 +00:00
|
|
|
|
|
|
|
-- Add a string to the status line
|
|
|
|
function atsl(s)
|
|
|
|
newStatus = newStatus .. s
|
|
|
|
end
|
|
|
|
|
|
|
|
function update_status_line()
|
|
|
|
-- Reset the status line
|
|
|
|
newStatus = ""
|
|
|
|
|
|
|
|
if mp.get_property_bool("pause") then
|
|
|
|
atsl("(Paused) ")
|
|
|
|
elseif mp.get_property_bool("paused-for-cache") then
|
|
|
|
atsl("(Buffering) ")
|
|
|
|
end
|
|
|
|
|
2017-08-04 08:07:37 +00:00
|
|
|
if mp.get_property("aid") ~= "no" then
|
2014-04-12 17:29:47 +00:00
|
|
|
atsl("A")
|
|
|
|
end
|
2017-08-04 08:07:37 +00:00
|
|
|
if mp.get_property("vid") ~= "no" then
|
2014-04-12 17:29:47 +00:00
|
|
|
atsl("V")
|
|
|
|
end
|
|
|
|
|
|
|
|
atsl(": ")
|
|
|
|
|
|
|
|
atsl(mp.get_property_osd("time-pos"))
|
|
|
|
|
|
|
|
atsl(" / ");
|
2015-05-25 20:01:34 +00:00
|
|
|
atsl(mp.get_property_osd("duration"));
|
2014-04-12 17:29:47 +00:00
|
|
|
|
|
|
|
atsl(" (")
|
|
|
|
atsl(mp.get_property_osd("percent-pos", -1))
|
|
|
|
atsl("%)")
|
|
|
|
|
2014-04-24 16:16:47 +00:00
|
|
|
local r = mp.get_property_number("speed", -1)
|
2014-04-12 17:29:47 +00:00
|
|
|
if r ~= 1 then
|
|
|
|
atsl(string.format(" x%4.2f", r))
|
|
|
|
end
|
|
|
|
|
|
|
|
r = mp.get_property_number("avsync", nil)
|
|
|
|
if r ~= nil then
|
2017-08-04 08:07:37 +00:00
|
|
|
atsl(string.format(" A-V: %f", r))
|
2014-04-12 17:29:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
r = mp.get_property("total-avsync-change", 0)
|
|
|
|
if math.abs(r) > 0.05 then
|
|
|
|
atsl(string.format(" ct:%7.3f", r))
|
|
|
|
end
|
|
|
|
|
2017-08-04 08:07:37 +00:00
|
|
|
r = mp.get_property_number("decoder-drop-frame-count", -1)
|
2014-04-12 17:29:47 +00:00
|
|
|
if r > 0 then
|
|
|
|
atsl(" Late: ")
|
|
|
|
atsl(r)
|
|
|
|
end
|
2014-04-24 16:16:47 +00:00
|
|
|
|
2017-08-04 08:07:37 +00:00
|
|
|
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
|
|
|
|
|
2014-04-12 17:29:47 +00:00
|
|
|
r = mp.get_property_number("cache", 0)
|
|
|
|
if r > 0 then
|
|
|
|
atsl(string.format(" Cache: %d%% ", r))
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Set the new status line
|
2014-04-24 16:16:47 +00:00
|
|
|
mp.set_property("options/term-status-msg", newStatus)
|
2014-04-12 17:29:47 +00:00
|
|
|
end
|
|
|
|
|
2017-08-04 08:07:37 +00:00
|
|
|
timer = mp.add_periodic_timer(1, update_status_line)
|
2014-04-12 17:29:47 +00:00
|
|
|
|
2017-08-04 08:07:37 +00:00
|
|
|
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)
|