Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add option to display milliseconds #33

Merged
merged 1 commit into from
Jan 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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