Skip to content

Commit

Permalink
Merge pull request #33 from Yutsuten/add-option-timems
Browse files Browse the repository at this point in the history
Add option to display milliseconds
  • Loading branch information
maoiscat committed Jan 2, 2023
2 parents d0fc2ba + 638743a commit fbbef10
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions modern.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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 timecodes with milliseconds
visibility = 'auto', -- only used at init to set visibility_mode(...)
windowcontrols = 'auto', -- whether to show window controls
volumecontrol = true, -- whether to show mute button and volumne slider
Expand Down Expand Up @@ -115,6 +116,7 @@ local state = {
active_element = nil, -- nil = none, 0 = background, 1+ = see elements[]
active_event_source = nil, -- the 'button' that issued the current event
rightTC_trem = not user_opts.timetotal, -- if the right timecode should display total or remaining time
tc_ms = user_opts.timems, -- should the timecodes display their time with milliseconds
mp_screen_sizeX, mp_screen_sizeY, -- last screen-resolution, to detect resolution changes to issue reINITs
initREQ = false, -- is a re-init request pending?
last_mouseX, last_mouseY, -- last mouse position, to detect significant mouse movement
Expand Down Expand Up @@ -1536,16 +1538,34 @@ function osc_init()
end
-- 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.tc_ms) 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.tc_ms = not state.tc_ms
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
return ('-'..mp.get_property_osd('playtime-remaining'))
if (state.tc_ms) then
return ('-'..mp.get_property_osd('playtime-remaining/full'))
else
return ('-'..mp.get_property_osd('playtime-remaining'))
end
else
return (mp.get_property_osd('duration'))
if (state.tc_ms) 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 fbbef10

Please # to comment.