From 3d5396b3306b3d69c0687527119fc821dbd95180 Mon Sep 17 00:00:00 2001 From: cyl0 <83499175+cyl0@users.noreply.github.com> Date: Wed, 1 Sep 2021 21:46:07 +0800 Subject: [PATCH] Added options to display time down to milliseconds Time in milliseconds can now be invoked by left-clicking the playback time, or can be enabled by default in user_opts. --- mordenx.lua | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/mordenx.lua b/mordenx.lua index bd0b64a..73c9d80 100644 --- a/mordenx.lua +++ b/mordenx.lua @@ -40,6 +40,7 @@ local user_opts = { -- to be shown as OSC title showtitle = true, -- show title and no hide timeout on pause timetotal = true, -- display total time instead of remaining time? + timems = false, -- Display time down to millliseconds by default visibility = 'auto', -- only used at init to set visibility_mode(...) windowcontrols = 'auto', -- whether to show window controls language = 'eng', -- eng=English, chs=Chinese @@ -135,6 +136,7 @@ local state = { maximized = false, osd = mp.create_osd_overlay('ass-events'), lastvisibility = user_opts.visibility, -- save last visibility on pause if showtitle + fulltime = user_opts.timems, } local window_control_box_width = 138 @@ -1432,16 +1434,34 @@ function osc_init() -- tc_left (current pos) ne = new_element('tc_left', 'button') - ne.content = function () return (mp.get_property_osd('playback-time')) end - + ne.content = function () + if (state.fulltime) then + return (mp.get_property_osd('playback-time/full')) + else + return (mp.get_property_osd('playback-time')) + end + end + ne.eventresponder["mbtn_left_up"] = function () + state.fulltime = not state.fulltime + request_init() + end -- tc_right (total/remaining time) ne = new_element('tc_right', 'button') ne.content = function () if (mp.get_property_number('duration', 0) <= 0) then return '--:--:--' end if (state.rightTC_trem) then + if (state.fulltime) then + return ('-'..mp.get_property_osd('playtime-remaining/full')) + else return ('-'..mp.get_property_osd('playtime-remaining')) + end else + if (state.fulltime) then + return (mp.get_property_osd('duration/full')) + else return (mp.get_property_osd('duration')) + end + end end ne.eventresponder['mbtn_left_up'] =