@@ -188,7 +188,7 @@ local user_opts = {
188
188
time_codes_centered_height = 57 , -- time codes height position with portrait window
189
189
tooltip_height_offset = 2 , -- tooltip height position offset
190
190
tooltip_left_offset = 5 , -- if tooltip contains many characters, it is moved to the left by offset
191
- portrait_window_trigger = 930 , -- portrait window width trigger to move some elements
191
+ portrait_window_trigger = 1000 , -- portrait window width trigger to move some elements
192
192
hide_volume_bar_trigger = 1150 , -- hide volume bar trigger window width
193
193
notitle_osc_h_offset = 25 , -- osc height offset if title above seekbar is disabled
194
194
nochapter_osc_h_offset = 10 , -- osc height offset if chapter title is disabled or doesn't exist
@@ -506,6 +506,8 @@ local state = {
506
506
sliderpos = 0 ,
507
507
touchingprogressbar = false , -- if the mouse is touching the progress bar
508
508
initialborder = mp .get_property (" border" ),
509
+ playtime_hour_force_init = false , -- used to force request_init() once
510
+ playtime_nohour_force_init = false , -- used to force request_init() once
509
511
playingWhilstSeeking = false ,
510
512
playingWhilstSeekingWaitingForEnd = false ,
511
513
persistentprogresstoggle = user_opts .persistentprogress ,
@@ -1828,22 +1830,30 @@ layouts["modern"] = function ()
1828
1830
1829
1831
-- Time codes
1830
1832
local remsec = mp .get_property_number (" playtime-remaining" , 0 )
1831
- local possec = mp .get_property_number (" playback-time" , 0 )
1832
1833
local dur = mp .get_property_number (" duration" , 0 )
1833
- local show_hours = possec >= 3600 or user_opts .time_format ~= " dynamic"
1834
+ local show_hours = mp . get_property_number ( " playback-time " , 0 ) >= 3600 or user_opts .time_format ~= " dynamic"
1834
1835
local show_remhours = (state .tc_right_rem and remsec >= 3600 ) or (not state .tc_right_rem and dur >= 3600 ) or user_opts .time_format ~= " dynamic"
1835
- local tc_w_offset = (state .tc_ms and 60 or 0 ) + (show_hours and 20 or 0 ) + (show_remhours and 20 or 0 )
1836
1836
local auto_hide_volbar = (audio_track and user_opts .volume_control ) and osc_param .playresx < (user_opts .hide_volume_bar_trigger - outeroffset )
1837
- local narrow_vid_tc_y = osc_param .playresx < (user_opts .portrait_window_trigger - outeroffset - (playlist_button and 0 or 100 ) - (subtitle_track and 0 or 100 ) - (audio_track and 0 or 100 ))
1838
1837
local time_codes_x = 275
1839
1838
- (auto_hide_volbar and 75 or 0 ) -- window width with audio track and elements
1840
1839
- (audio_track and not user_opts .volume_control and 115 or 0 ) -- audio track with no elements
1841
1840
- (not audio_track and 160 or 0 ) -- no audio track or elements
1842
1841
- (subtitle_track and 0 or 45 )
1843
1842
- (playlist_button and 0 or 45 )
1844
-
1843
+ local time_codes_width = 80
1844
+ + (state .tc_ms and 50 or 0 )
1845
+ + (state .tc_right_rem and 15 or 0 )
1846
+ + (show_hours and 20 or 0 )
1847
+ + (show_remhours and 20 or 0 )
1848
+ local narrow_win = osc_param .playresx < (
1849
+ user_opts .portrait_window_trigger
1850
+ - outeroffset
1851
+ - (playlist_button and 0 or 100 )
1852
+ - (subtitle_track and 0 or 100 )
1853
+ - (audio_track and 0 or 100 )
1854
+ )
1845
1855
lo = add_layout (" time_codes" )
1846
- lo .geometry = {x = (narrow_vid_tc_y and refX or time_codes_x ), y = refY - (narrow_vid_tc_y and user_opts .time_codes_centered_height or user_opts .time_codes_height ), an = (narrow_vid_tc_y and 5 or 4 ), w = 90 + tc_w_offset , h = 15 }
1856
+ lo .geometry = {x = (narrow_win and refX or time_codes_x ), y = refY - (narrow_win and user_opts .time_codes_centered_height or user_opts .time_codes_height ), an = (narrow_win and 5 or 4 ), w = time_codes_width , h = user_opts . time_font_size }
1847
1857
lo .style = osc_styles .time
1848
1858
1849
1859
-- Fullscreen/Info/Pin/Screenshot/Loop/Speed
@@ -2786,6 +2796,21 @@ local function osc_init()
2786
2796
ne .content = function ()
2787
2797
local playback_time = mp .get_property_number (" playback-time" , 0 )
2788
2798
2799
+ -- force request_init() once to update time codes width hitbox
2800
+ -- run once when less than hour, once again if hour or more
2801
+ -- since request_init() is expensive, this is a measure to call it when needed only
2802
+ if user_opts .time_format ~= " fixed" and playback_time then
2803
+ if playback_time >= 3600 and not state .playtime_hour_force_init then
2804
+ request_init ()
2805
+ state .playtime_hour_force_init = true
2806
+ state .playtime_nohour_force_init = false
2807
+ elseif playback_time < 3600 and not state .playtime_nohour_force_init then
2808
+ request_init ()
2809
+ state .playtime_hour_force_init = false
2810
+ state .playtime_nohour_force_init = true
2811
+ end
2812
+ end
2813
+
2789
2814
local duration = mp .get_property_number (" duration" , 0 )
2790
2815
if duration <= 0 then return " --:--" end
2791
2816
@@ -3316,10 +3341,6 @@ mp.observe_property("chapter-list", "native", function(_, list)
3316
3341
update_duration_watch ()
3317
3342
request_init ()
3318
3343
end )
3319
-
3320
- mp .observe_property (" playback-time" , " native" , function (_ , time )
3321
- request_tick ()
3322
- end )
3323
3344
mp .observe_property (" seeking" , " native" , function (_ , seeking )
3324
3345
if user_opts .seek_resets_hidetimeout then
3325
3346
reset_timeout ()
@@ -3330,7 +3351,6 @@ mp.observe_property("seeking", "native", function(_, seeking)
3330
3351
state .new_file_flag = false
3331
3352
end
3332
3353
end )
3333
-
3334
3354
mp .observe_property (" fullscreen" , " bool" , function (_ , val )
3335
3355
state .fullscreen = val
3336
3356
state .marginsREQ = true
@@ -3353,10 +3373,10 @@ mp.observe_property("idle-active", "bool", function(_, val)
3353
3373
state .idle = val
3354
3374
request_tick ()
3355
3375
end )
3356
-
3357
3376
mp .observe_property (" display-fps" , " number" , set_tick_delay )
3358
3377
mp .observe_property (" demuxer-cache-state" , " native" , cache_state )
3359
3378
mp .observe_property (" vo-configured" , " bool" , request_tick )
3379
+ mp .observe_property (" playback-time" , " number" , request_tick )
3360
3380
mp .observe_property (" osd-dimensions" , " native" , function ()
3361
3381
-- (we could use the value instead of re-querying it all the time, but then
3362
3382
-- we might have to worry about property update ordering)
0 commit comments