Skip to content

Commit

Permalink
Added options to display time down to milliseconds
Browse files Browse the repository at this point in the history
Time in milliseconds can now be invoked by left-clicking the playback time, or can be enabled by default in user_opts.
  • Loading branch information
cyl0 authored Sep 1, 2021
1 parent 56fe3a3 commit 3d5396b
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions mordenx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'] =
Expand Down

0 comments on commit 3d5396b

Please sign in to comment.