From 2f5217dd0519616b842a158bc0a59b92b4740f7c Mon Sep 17 00:00:00 2001 From: David Weber Date: Sat, 12 Apr 2014 19:29:47 +0200 Subject: lua: add example to rebuild the status line This can be used to easily extent the status line for one's own needs. I'm not experienced with lua so a few things could probably be done a better way. --- DOCS/lua_examples/status-line.lua | 69 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 DOCS/lua_examples/status-line.lua (limited to 'DOCS') diff --git a/DOCS/lua_examples/status-line.lua b/DOCS/lua_examples/status-line.lua new file mode 100644 index 0000000000..be3374a7cf --- /dev/null +++ b/DOCS/lua_examples/status-line.lua @@ -0,0 +1,69 @@ +-- Rebuild the status line as a lua script +-- Be aware that this will require more cpu power! + +-- 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 + + if mp.get_property("vid") ~= "no" then + atsl("A") + end + if mp.get_property("aid") ~= "no" then + atsl("V") + end + + atsl(": ") + + atsl(mp.get_property_osd("time-pos")) + + atsl(" / "); + atsl(mp.get_property_osd("length")); + + atsl(" (") + atsl(mp.get_property_osd("percent-pos", -1)) + atsl("%)") + + local r = mp.get_property_number("speed", -1) + if r ~= 1 then + atsl(string.format(" x%4.2f", r)) + end + + r = mp.get_property_number("avsync", nil) + if r ~= nil then + atsl(string.format(" A-V: %7.3f", r)) + end + + r = mp.get_property("total-avsync-change", 0) + if math.abs(r) > 0.05 then + atsl(string.format(" ct:%7.3f", r)) + end + + r = mp.get_property_number("drop-frame-count", -1) + if r > 0 then + atsl(" Late: ") + atsl(r) + end + + r = mp.get_property_number("cache", 0) + if r > 0 then + atsl(string.format(" Cache: %d%% ", r)) + end + + -- Set the new status line + mp.set_property("options/status-msg", newStatus) +end + +-- Register the event +mp.register_event("tick", update_status_line) + -- cgit v1.2.3