修复osc问题

This commit is contained in:
liyp 2024-04-19 21:40:33 +08:00
parent 6c8c5ed661
commit 6772324bef

View file

@ -38,10 +38,13 @@ local user_opts = {
seekrangeseparate = true, -- whether the seekranges overlay on the bar-style seekbar seekrangeseparate = true, -- whether the seekranges overlay on the bar-style seekbar
seekrangealpha = 200, -- transparency of seekranges seekrangealpha = 200, -- transparency of seekranges
seekbarkeyframes = true, -- use keyframes when dragging the seekbar seekbarkeyframes = true, -- use keyframes when dragging the seekbar
scrollcontrols = true, -- allow scrolling when hovering certain OSC elements
title = "${media-title}", -- string compatible with property-expansion title = "${media-title}", -- string compatible with property-expansion
-- to be shown as OSC title -- to be shown as OSC title
tooltipborder = 1, -- border of tooltip in bottom/topbar tooltipborder = 1, -- border of tooltip in bottom/topbar
timetotal = false, -- display total time instead of remaining time? timetotal = false, -- display total time instead of remaining time?
remaining_playtime = true, -- display the remaining time in playtime or video-time mode
-- playtime takes speed into account, whereas video-time doesn't
timems = false, -- display timecodes with milliseconds? timems = false, -- display timecodes with milliseconds?
tcspace = 100, -- timecode spacing (compensate font size estimation) tcspace = 100, -- timecode spacing (compensate font size estimation)
visibility = "auto", -- only used at init to set visibility_mode(...) visibility = "auto", -- only used at init to set visibility_mode(...)
@ -49,10 +52,12 @@ local user_opts = {
boxvideo = false, -- apply osc_param.video_margins to video boxvideo = false, -- apply osc_param.video_margins to video
windowcontrols = "auto", -- whether to show window controls windowcontrols = "auto", -- whether to show window controls
windowcontrols_alignment = "right", -- which side to show window controls on windowcontrols_alignment = "right", -- which side to show window controls on
windowcontrols_title = "${media-title}", -- same as title but for windowcontrols
greenandgrumpy = false, -- disable santa hat greenandgrumpy = false, -- disable santa hat
livemarkers = true, -- update seekbar chapter markers on duration change livemarkers = true, -- update seekbar chapter markers on duration change
chapters_osd = true, -- whether to show chapters OSD on next/prev chapters_osd = true, -- whether to show chapters OSD on next/prev
playlist_osd = true, -- whether to show playlist OSD on next/prev playlist_osd = true, -- whether to show playlist OSD on next/prev
playlist_media_title = true, -- whether to use media titles as playlist entry names
chapter_fmt = "Chapter: %s", -- chapter print format for seekbar-hover. "no" to disable chapter_fmt = "Chapter: %s", -- chapter print format for seekbar-hover. "no" to disable
unicodeminus = false, -- whether to use the Unicode minus sign character unicodeminus = false, -- whether to use the Unicode minus sign character
} }
@ -122,6 +127,8 @@ local state = {
enabled = true, enabled = true,
input_enabled = true, input_enabled = true,
showhide_enabled = false, showhide_enabled = false,
windowcontrols_buttons = false,
windowcontrols_title = false,
dmx_cache = 0, dmx_cache = 0,
using_video_margins = false, using_video_margins = false,
border = true, border = true,
@ -130,12 +137,6 @@ local state = {
chapter_list = {}, -- sorted by time chapter_list = {}, -- sorted by time
} }
local thumbfast = {
width = 0,
height = 0,
disabled = false
}
local window_control_box_width = 80 local window_control_box_width = 80
local tick_delay = 0.03 local tick_delay = 0.03
@ -151,7 +152,7 @@ function kill_animation()
state.anitype = nil state.anitype = nil
end end
function set_osd(res_x, res_y, text) function set_osd(res_x, res_y, text, z)
if state.osd.res_x == res_x and if state.osd.res_x == res_x and
state.osd.res_y == res_y and state.osd.res_y == res_y and
state.osd.data == text then state.osd.data == text then
@ -160,7 +161,7 @@ function set_osd(res_x, res_y, text)
state.osd.res_x = res_x state.osd.res_x = res_x
state.osd.res_y = res_y state.osd.res_y = res_y
state.osd.data = text state.osd.data = text
state.osd.z = 1000 state.osd.z = z
state.osd:update() state.osd:update()
end end
@ -283,7 +284,7 @@ function get_slider_value(element)
end end
function countone(val) function countone(val)
if not (user_opts.iamaprogrammer) then if not user_opts.iamaprogrammer then
val = val + 1 val = val + 1
end end
return val return val
@ -304,7 +305,7 @@ end
function add_area(name, x1, y1, x2, y2) function add_area(name, x1, y1, x2, y2)
-- create area if needed -- create area if needed
if (osc_param.areas[name] == nil) then if osc_param.areas[name] == nil then
osc_param.areas[name] = {} osc_param.areas[name] = {}
end end
table.insert(osc_param.areas[name], {x1=x1, y1=y1, x2=x2, y2=y2}) table.insert(osc_param.areas[name], {x1=x1, y1=y1, x2=x2, y2=y2})
@ -359,7 +360,7 @@ function update_tracklist()
tracks_mpv = {} tracks_mpv = {}
tracks_mpv.video, tracks_mpv.audio, tracks_mpv.sub = {}, {}, {} tracks_mpv.video, tracks_mpv.audio, tracks_mpv.sub = {}, {}, {}
for n = 1, #tracktable do for n = 1, #tracktable do
if not (tracktable[n].type == "unknown") then if tracktable[n].type ~= "unknown" then
local type = tracktable[n].type local type = tracktable[n].type
local mpv_id = tonumber(tracktable[n].id) local mpv_id = tonumber(tracktable[n].id)
@ -382,9 +383,9 @@ function get_tracklist(type)
for n = 1, #tracks_osc[type] do for n = 1, #tracks_osc[type] do
local track = tracks_osc[type][n] local track = tracks_osc[type][n]
local lang, title, selected = "unknown", "", "" local lang, title, selected = "unknown", "", ""
if not(track.lang == nil) then lang = track.lang end if track.lang ~= nil then lang = track.lang end
if not(track.title == nil) then title = track.title end if track.title ~= nil then title = track.title end
if (track.id == tonumber(mp.get_property(type))) then if track.id == tonumber(mp.get_property(type)) then
selected = "" selected = ""
end end
msg = msg.."\n"..selected.." "..n..": ["..lang.."] "..title msg = msg.."\n"..selected.." "..n..": ["..lang.."] "..title
@ -397,7 +398,7 @@ end
--(+1 -> next, -1 -> previous) --(+1 -> next, -1 -> previous)
function set_track(type, next) function set_track(type, next)
local current_track_mpv, current_track_osc local current_track_mpv, current_track_osc
if (mp.get_property(type) == "no") then if mp.get_property(type) == "no" then
current_track_osc = 0 current_track_osc = 0
else else
current_track_mpv = tonumber(mp.get_property(type)) current_track_mpv = tonumber(mp.get_property(type))
@ -413,10 +414,10 @@ function set_track(type, next)
mp.commandv("set", type, new_track_mpv) mp.commandv("set", type, new_track_mpv)
if (new_track_osc == 0) then if new_track_osc == 0 then
show_message(nicetypes[type] .. " Track: none") show_message(nicetypes[type] .. " Track: none")
else else
show_message(nicetypes[type] .. " Track: " show_message(nicetypes[type] .. " Track: "
.. new_track_osc .. "/" .. #tracks_osc[type] .. new_track_osc .. "/" .. #tracks_osc[type]
.. " [".. (tracks_osc[type][new_track_osc].lang or "unknown") .."] " .. " [".. (tracks_osc[type][new_track_osc].lang or "unknown") .."] "
.. (tracks_osc[type][new_track_osc].title or "")) .. (tracks_osc[type][new_track_osc].title or ""))
@ -439,7 +440,7 @@ end
function window_controls_enabled() function window_controls_enabled()
val = user_opts.windowcontrols val = user_opts.windowcontrols
if val == "auto" then if val == "auto" then
return not state.border return not (state.border and state.title_bar)
else else
return val ~= "no" return val ~= "no"
end end
@ -457,10 +458,10 @@ local elements = {}
function prepare_elements() function prepare_elements()
-- remove elements without layout or invisble -- remove elements without layout or invisible
local elements2 = {} local elements2 = {}
for n, element in pairs(elements) do for n, element in pairs(elements) do
if not (element.layout == nil) and (element.visible) then if element.layout ~= nil and element.visible then
table.insert(elements2, element) table.insert(elements2, element)
end end
end end
@ -495,14 +496,14 @@ function prepare_elements()
local static_ass = assdraw.ass_new() local static_ass = assdraw.ass_new()
if (element.type == "box") then if element.type == "box" then
--draw box --draw box
static_ass:draw_start() static_ass:draw_start()
ass_draw_rr_h_cw(static_ass, 0, 0, elem_geo.w, elem_geo.h, ass_draw_rr_h_cw(static_ass, 0, 0, elem_geo.w, elem_geo.h,
element.layout.box.radius, element.layout.box.hexagon) element.layout.box.radius, element.layout.box.hexagon)
static_ass:draw_stop() static_ass:draw_stop()
elseif (element.type == "slider") then elseif element.type == "slider" then
--draw static slider parts --draw static slider parts
local r1 = 0 local r1 = 0
@ -512,13 +513,13 @@ function prepare_elements()
local foV = slider_lo.border + slider_lo.gap local foV = slider_lo.border + slider_lo.gap
-- calculate positions of min and max points -- calculate positions of min and max points
if (slider_lo.stype ~= "bar") then if slider_lo.stype ~= "bar" then
r1 = elem_geo.h / 2 r1 = elem_geo.h / 2
element.slider.min.ele_pos = elem_geo.h / 2 element.slider.min.ele_pos = elem_geo.h / 2
element.slider.max.ele_pos = elem_geo.w - (elem_geo.h / 2) element.slider.max.ele_pos = elem_geo.w - (elem_geo.h / 2)
if (slider_lo.stype == "diamond") then if slider_lo.stype == "diamond" then
r2 = (elem_geo.h - 2 * slider_lo.border) / 2 r2 = (elem_geo.h - 2 * slider_lo.border) / 2
elseif (slider_lo.stype == "knob") then elseif slider_lo.stype == "knob" then
r2 = r1 r2 = r1
end end
else else
@ -546,45 +547,45 @@ function prepare_elements()
r2, slider_lo.stype == "diamond") r2, slider_lo.stype == "diamond")
-- marker nibbles -- marker nibbles
if not (element.slider.markerF == nil) and (slider_lo.gap > 0) then if element.slider.markerF ~= nil and slider_lo.gap > 0 then
local markers = element.slider.markerF() local markers = element.slider.markerF()
for _,marker in pairs(markers) do for _,marker in pairs(markers) do
if (marker > element.slider.min.value) and if marker > element.slider.min.value and
(marker < element.slider.max.value) then marker < element.slider.max.value then
local s = get_slider_ele_pos_for(element, marker) local s = get_slider_ele_pos_for(element, marker)
if (slider_lo.gap > 1) then -- draw triangles if slider_lo.gap > 1 then -- draw triangles
local a = slider_lo.gap / 0.5 --0.866 local a = slider_lo.gap / 0.5 --0.866
--top --top
if (slider_lo.nibbles_top) then if slider_lo.nibbles_top then
static_ass:move_to(s - (a/2), slider_lo.border) static_ass:move_to(s - (a / 2), slider_lo.border)
static_ass:line_to(s + (a/2), slider_lo.border) static_ass:line_to(s + (a / 2), slider_lo.border)
static_ass:line_to(s, foV) static_ass:line_to(s, foV)
end end
--bottom --bottom
if (slider_lo.nibbles_bottom) then if slider_lo.nibbles_bottom then
static_ass:move_to(s - (a/2), static_ass:move_to(s - (a / 2),
elem_geo.h - slider_lo.border) elem_geo.h - slider_lo.border)
static_ass:line_to(s, static_ass:line_to(s,
elem_geo.h - foV) elem_geo.h - foV)
static_ass:line_to(s + (a/2), static_ass:line_to(s + (a / 2),
elem_geo.h - slider_lo.border) elem_geo.h - slider_lo.border)
end end
else -- draw 2x1px nibbles else -- draw 2x1px nibbles
--top --top
if (slider_lo.nibbles_top) then if slider_lo.nibbles_top then
static_ass:rect_cw(s - 1, slider_lo.border, static_ass:rect_cw(s - 1, slider_lo.border,
s + 1, slider_lo.border + slider_lo.gap); s + 1, slider_lo.border + slider_lo.gap);
end end
--bottom --bottom
if (slider_lo.nibbles_bottom) then if slider_lo.nibbles_bottom then
static_ass:rect_cw(s - 1, static_ass:rect_cw(s - 1,
elem_geo.h -slider_lo.border -slider_lo.gap, elem_geo.h -slider_lo.border -slider_lo.gap,
s + 1, elem_geo.h - slider_lo.border); s + 1, elem_geo.h - slider_lo.border);
@ -600,7 +601,7 @@ function prepare_elements()
-- if the element is supposed to be disabled, -- if the element is supposed to be disabled,
-- style it accordingly and kill the eventresponders -- style it accordingly and kill the eventresponders
if not (element.enabled) then if not element.enabled then
element.layout.alpha[1] = 136 element.layout.alpha[1] = 136
element.eventresponder = nil element.eventresponder = nil
end end
@ -651,18 +652,18 @@ function render_elements(master_ass)
if element.eventresponder and (state.active_element == n) then if element.eventresponder and (state.active_element == n) then
-- run render event functions -- run render event functions
if not (element.eventresponder.render == nil) then if element.eventresponder.render ~= nil then
element.eventresponder.render(element) element.eventresponder.render(element)
end end
if mouse_hit(element) then if mouse_hit(element) then
-- mouse down styling -- mouse down styling
if (element.styledown) then if element.styledown then
style_ass:append(osc_styles.elementDown) style_ass:append(osc_styles.elementDown)
end end
if (element.softrepeat) and (state.mouse_down_counter >= 15 if element.softrepeat and state.mouse_down_counter >= 15
and state.mouse_down_counter % 5 == 0) then and state.mouse_down_counter % 5 == 0 then
element.eventresponder[state.active_event_source.."_down"](element) element.eventresponder[state.active_event_source.."_down"](element)
end end
@ -675,11 +676,11 @@ function render_elements(master_ass)
elem_ass:merge(style_ass) elem_ass:merge(style_ass)
if not (element.type == "button") then if element.type ~= "button" then
elem_ass:merge(element.static_ass) elem_ass:merge(element.static_ass)
end end
if (element.type == "slider") then if element.type == "slider" then
local slider_lo = element.layout.slider local slider_lo = element.layout.slider
local elem_geo = element.layout.geometry local elem_geo = element.layout.geometry
@ -797,8 +798,7 @@ function render_elements(master_ass)
elem_ass:draw_stop() elem_ass:draw_stop()
-- add tooltip -- add tooltip
if not (element.slider.tooltipF == nil) then if element.slider.tooltipF ~= nil then
if mouse_hit(element) then if mouse_hit(element) then
local sliderpos = get_slider_value(element) local sliderpos = get_slider_value(element)
local tooltiplabel = element.slider.tooltipF(sliderpos) local tooltiplabel = element.slider.tooltipF(sliderpos)
@ -807,22 +807,21 @@ function render_elements(master_ass)
local ty local ty
if (an == 2) then if an == 2 then
ty = element.hitbox.y1 - slider_lo.border ty = element.hitbox.y1 - slider_lo.border
else else
ty = element.hitbox.y1 + elem_geo.h/2 ty = element.hitbox.y1 + elem_geo.h / 2
end end
local tx = get_virt_mouse_pos() local tx = get_virt_mouse_pos()
local thumb_tx = tx if slider_lo.adjust_tooltip then
if (slider_lo.adjust_tooltip) then if an == 2 then
if (an == 2) then if sliderpos < (s_min + 3) then
if (sliderpos < (s_min + 3)) then
an = an - 1 an = an - 1
elseif (sliderpos > (s_max - 3)) then elseif sliderpos > (s_max - 3) then
an = an + 1 an = an + 1
end end
elseif (sliderpos > (s_max-s_min)/2) then elseif sliderpos > (s_max+s_min) / 2 then
an = an + 1 an = an + 1
tx = tx - 5 tx = tx - 5
else else
@ -839,60 +838,23 @@ function render_elements(master_ass)
ass_append_alpha(elem_ass, slider_lo.alpha, 0) ass_append_alpha(elem_ass, slider_lo.alpha, 0)
elem_ass:append(tooltiplabel) elem_ass:append(tooltiplabel)
-- thumbnail
if not thumbfast.disabled and thumbfast.width ~= 0 and thumbfast.height ~= 0 then
local osd_w = mp.get_property_number("osd-width")
if osd_w then
local r_w, r_h = get_virt_scale_factor()
local tooltip_font_size = (user_opts.layout == "box" or user_opts.layout == "slimbox") and 2 or 12
local thumb_ty = user_opts.layout ~= "topbar" and element.hitbox.y1 - 8 or element.hitbox.y2 + tooltip_font_size + 8
local thumb_pad = 2
local thumb_margin_x = 20 / r_w
local thumb_margin_y = (4 + user_opts.tooltipborder) / r_h + thumb_pad
local thumb_x = math.min(osd_w - thumbfast.width - thumb_margin_x, math.max(thumb_margin_x, thumb_tx / r_w - thumbfast.width / 2))
local thumb_y = user_opts.layout ~= "topbar" and thumb_ty / r_h - thumbfast.height - tooltip_font_size / r_h - thumb_margin_y or thumb_ty / r_h + thumb_margin_y
thumb_x = math.floor(thumb_x + 0.5)
thumb_y = math.floor(thumb_y + 0.5)
elem_ass:new_event()
elem_ass:pos(thumb_x * r_w, thumb_y * r_h)
elem_ass:append(osc_styles.timePosBar)
elem_ass:append("{\\1a&H20&}")
elem_ass:draw_start()
elem_ass:rect_cw(-thumb_pad * r_w, -thumb_pad * r_h, (thumbfast.width + thumb_pad) * r_w, (thumbfast.height + thumb_pad) * r_h)
elem_ass:draw_stop()
mp.commandv("script-message-to", "thumbfast", "thumb",
mp.get_property_number("duration", 0) * (sliderpos / 100),
thumb_x,
thumb_y
)
end
end
else
if thumbfast.width ~= 0 and thumbfast.height ~= 0 then
mp.commandv("script-message-to", "thumbfast", "clear")
end
end end
end end
elseif (element.type == "button") then elseif element.type == "button" then
local buttontext local buttontext
if type(element.content) == "function" then if type(element.content) == "function" then
buttontext = element.content() -- function objects buttontext = element.content() -- function objects
elseif not (element.content == nil) then elseif element.content ~= nil then
buttontext = element.content -- text objects buttontext = element.content -- text objects
end end
local maxchars = element.layout.button.maxchars local maxchars = element.layout.button.maxchars
if not (maxchars == nil) and (#buttontext > maxchars) then if maxchars ~= nil and #buttontext > maxchars then
local max_ratio = 1.25 -- up to 25% more chars while shrinking local max_ratio = 1.25 -- up to 25% more chars while shrinking
local limit = math.max(0, math.floor(maxchars * max_ratio) - 3) local limit = math.max(0, math.floor(maxchars * max_ratio) - 3)
if (#buttontext > limit) then if #buttontext > limit then
while (#buttontext > limit) do while (#buttontext > limit) do
buttontext = buttontext:gsub(".[\128-\191]*$", "") buttontext = buttontext:gsub(".[\128-\191]*$", "")
end end
@ -952,7 +914,7 @@ function get_playlist()
for i, v in ipairs(limlist) do for i, v in ipairs(limlist) do
local title = v.title local title = v.title
local _, filename = utils.split_path(v.filename) local _, filename = utils.split_path(v.filename)
if title == nil then if not user_opts.playlist_media_title or title == nil then
title = filename title = filename
end end
message = string.format('%s %s %s\n', message, message = string.format('%s %s %s\n', message,
@ -994,10 +956,7 @@ function show_message(text, duration)
-- may slow down massively on huge input -- may slow down massively on huge input
text = string.sub(text, 0, 4000) text = string.sub(text, 0, 4000)
-- replace actual linebreaks with ASS linebreaks state.message_text = mp.command_native({"escape-ass", text})
text = string.gsub(text, "\n", "\\N")
state.message_text = text
if not state.message_hide_timer then if not state.message_hide_timer then
state.message_hide_timer = mp.add_timeout(0, request_tick) state.message_hide_timer = mp.add_timeout(0, request_tick)
@ -1048,7 +1007,7 @@ function new_element(name, type)
elements[name].styledown = (type == "button") elements[name].styledown = (type == "button")
elements[name].state = {} elements[name].state = {}
if (type == "slider") then if type == "slider" then
elements[name].slider = {min = {value = 0}, max = {value = 100}} elements[name].slider = {min = {value = 0}, max = {value = 100}}
end end
@ -1057,7 +1016,7 @@ function new_element(name, type)
end end
function add_layout(name) function add_layout(name)
if not (elements[name] == nil) then if elements[name] ~= nil then
-- new layout -- new layout
elements[name].layout = {} elements[name].layout = {}
@ -1065,11 +1024,11 @@ function add_layout(name)
elements[name].layout.layer = 50 elements[name].layout.layer = 50
elements[name].layout.alpha = {[1] = 0, [2] = 255, [3] = 255, [4] = 255} elements[name].layout.alpha = {[1] = 0, [2] = 255, [3] = 255, [4] = 255}
if (elements[name].type == "button") then if elements[name].type == "button" then
elements[name].layout.button = { elements[name].layout.button = {
maxchars = nil, maxchars = nil,
} }
elseif (elements[name].type == "slider") then elseif elements[name].type == "slider" then
-- slider defaults -- slider defaults
elements[name].layout.slider = { elements[name].layout.slider = {
border = 1, border = 1,
@ -1082,7 +1041,7 @@ function add_layout(name)
tooltip_an = 2, tooltip_an = 2,
alpha = {[1] = 0, [2] = 255, [3] = 88, [4] = 255}, alpha = {[1] = 0, [2] = 255, [3] = 88, [4] = 255},
} }
elseif (elements[name].type == "box") then elseif elements[name].type == "box" then
elements[name].layout.box = {radius = 0, hexagon = false} elements[name].layout.box = {radius = 0, hexagon = false}
end end
@ -1185,9 +1144,8 @@ function window_controls(topbar)
-- deadzone below window controls -- deadzone below window controls
local sh_area_y0, sh_area_y1 local sh_area_y0, sh_area_y1
sh_area_y0 = user_opts.barmargin sh_area_y0 = user_opts.barmargin
sh_area_y1 = (wc_geo.y + (wc_geo.h / 2)) + sh_area_y1 = wc_geo.y + get_align(1 - (2 * user_opts.deadzonesize),
get_align(1 - (2 * user_opts.deadzonesize), osc_param.playresy - wc_geo.y, 0, 0)
osc_param.playresy - (wc_geo.y + (wc_geo.h / 2)), 0, 0)
add_area("showhide_wc", wc_geo.x, sh_area_y0, wc_geo.w, sh_area_y1) add_area("showhide_wc", wc_geo.x, sh_area_y0, wc_geo.w, sh_area_y1)
if topbar then if topbar then
@ -1201,10 +1159,9 @@ function window_controls(topbar)
-- Window Title -- Window Title
ne = new_element("wctitle", "button") ne = new_element("wctitle", "button")
ne.content = function () ne.content = function ()
local title = mp.command_native({"expand-text", user_opts.title}) local title = mp.command_native({"expand-text", user_opts.windowcontrols_title})
-- escape ASS, and strip newlines and trailing slashes title = title:gsub("\n", " ")
title = title:gsub("\\n", " "):gsub("\\$", ""):gsub("{","\\{") return title ~= "" and mp.command_native({"escape-ass", title}) or "mpv"
return not (title == "") and title or "mpv"
end end
local left_pad = 5 local left_pad = 5
local right_pad = 10 local right_pad = 10
@ -1238,8 +1195,8 @@ layouts["box"] = function ()
} }
-- make sure the OSC actually fits into the video -- make sure the OSC actually fits into the video
if (osc_param.playresx < (osc_geo.w + (2 * osc_geo.p))) then if osc_param.playresx < (osc_geo.w + (2 * osc_geo.p)) then
osc_param.playresy = (osc_geo.w+(2*osc_geo.p))/osc_param.display_aspect osc_param.playresy = (osc_geo.w + (2 * osc_geo.p)) / osc_param.display_aspect
osc_param.playresx = osc_param.playresy * osc_param.display_aspect osc_param.playresx = osc_param.playresy * osc_param.display_aspect
end end
@ -1413,8 +1370,8 @@ layouts["slimbox"] = function ()
} }
-- make sure the OSC actually fits into the video -- make sure the OSC actually fits into the video
if (osc_param.playresx < (osc_geo.w)) then if osc_param.playresx < (osc_geo.w) then
osc_param.playresy = (osc_geo.w)/osc_param.display_aspect osc_param.playresy = (osc_geo.w) / osc_param.display_aspect
osc_param.playresx = osc_param.playresy * osc_param.display_aspect osc_param.playresx = osc_param.playresy * osc_param.display_aspect
end end
@ -1465,7 +1422,7 @@ layouts["slimbox"] = function ()
lo.style = osc_styles.box lo.style = osc_styles.box
lo.alpha[1] = user_opts.boxalpha lo.alpha[1] = user_opts.boxalpha
lo.alpha[3] = 0 lo.alpha[3] = 0
if not (user_opts["seekbarstyle"] == "bar") then if user_opts["seekbarstyle"] ~= "bar" then
lo.box.radius = osc_geo.r lo.box.radius = osc_geo.r
lo.box.hexagon = user_opts["seekbarstyle"] == "diamond" lo.box.hexagon = user_opts["seekbarstyle"] == "diamond"
end end
@ -1547,7 +1504,7 @@ function bar_layout(direction)
padwc_r = window_control_box_width padwc_r = window_control_box_width
end end
if ((osc_param.display_aspect > 0) and (osc_param.playresx < minW)) then if osc_param.display_aspect > 0 and osc_param.playresx < minW then
osc_param.playresy = minW / osc_param.display_aspect osc_param.playresy = minW / osc_param.display_aspect
osc_param.playresx = osc_param.playresy * osc_param.display_aspect osc_param.playresx = osc_param.playresy * osc_param.display_aspect
end end
@ -1570,13 +1527,11 @@ function bar_layout(direction)
if direction > 0 then if direction > 0 then
-- deadzone below OSC -- deadzone below OSC
sh_area_y0 = user_opts.barmargin sh_area_y0 = user_opts.barmargin
sh_area_y1 = (osc_geo.y + (osc_geo.h / 2)) + sh_area_y1 = osc_geo.y + get_align(1 - (2 * user_opts.deadzonesize),
get_align(1 - (2*user_opts.deadzonesize), osc_param.playresy - osc_geo.y, 0, 0)
osc_param.playresy - (osc_geo.y + (osc_geo.h / 2)), 0, 0)
else else
-- deadzone above OSC -- deadzone above OSC
sh_area_y0 = get_align(-1 + (2*user_opts.deadzonesize), sh_area_y0 = get_align(-1 + (2 * user_opts.deadzonesize), osc_geo.y, 0, 0)
osc_geo.y - (osc_geo.h / 2), 0, 0)
sh_area_y1 = osc_param.playresy - user_opts.barmargin sh_area_y1 = osc_param.playresy - user_opts.barmargin
end end
add_area("showhide", 0, sh_area_y0, osc_param.playresx, sh_area_y1) add_area("showhide", 0, sh_area_y0, osc_param.playresx, sh_area_y1)
@ -1698,7 +1653,7 @@ function bar_layout(direction)
lo.style = osc_styles.timecodesBar lo.style = osc_styles.timecodesBar
lo.alpha[1] = lo.alpha[1] =
math.min(255, user_opts.boxalpha + (255 - user_opts.boxalpha)*0.8) math.min(255, user_opts.boxalpha + (255 - user_opts.boxalpha)*0.8)
if not (user_opts["seekbarstyle"] == "bar") then if user_opts["seekbarstyle"] ~= "bar" then
lo.box.radius = geo.h / 2 lo.box.radius = geo.h / 2
lo.box.hexagon = user_opts["seekbarstyle"] == "diamond" lo.box.hexagon = user_opts["seekbarstyle"] == "diamond"
end end
@ -1793,7 +1748,7 @@ function osc_init()
local display_w, display_h, display_aspect = mp.get_osd_size() local display_w, display_h, display_aspect = mp.get_osd_size()
local scale = 1 local scale = 1
if (mp.get_property("video") == "no") then -- dummy/forced window if mp.get_property("video") == "no" then -- dummy/forced window
scale = user_opts.scaleforcedwindow scale = user_opts.scaleforcedwindow
elseif state.fullscreen then elseif state.fullscreen then
scale = user_opts.scalefullscreen scale = user_opts.scalefullscreen
@ -1807,7 +1762,7 @@ function osc_init()
osc_param.unscaled_y = display_h osc_param.unscaled_y = display_h
end end
osc_param.playresy = osc_param.unscaled_y / scale osc_param.playresy = osc_param.unscaled_y / scale
if (display_aspect > 0) then if display_aspect > 0 then
osc_param.display_aspect = display_aspect osc_param.display_aspect = display_aspect
end end
osc_param.playresx = osc_param.playresy * osc_param.display_aspect osc_param.playresx = osc_param.playresy * osc_param.display_aspect
@ -1834,14 +1789,13 @@ function osc_init()
ne.content = function () ne.content = function ()
local title = state.forced_title or local title = state.forced_title or
mp.command_native({"expand-text", user_opts.title}) mp.command_native({"expand-text", user_opts.title})
-- escape ASS, and strip newlines and trailing slashes title = title:gsub("\n", " ")
title = title:gsub("\\n", " "):gsub("\\$", ""):gsub("{","\\{") return title ~= "" and mp.command_native({"escape-ass", title}) or "mpv"
return not (title == "") and title or "mpv"
end end
ne.eventresponder["mbtn_left_up"] = function () ne.eventresponder["mbtn_left_up"] = function ()
local title = mp.get_property_osd("media-title") local title = mp.get_property_osd("media-title")
if (have_pl) then if have_pl then
title = string.format("[%d/%d] %s", countone(pl_pos - 1), title = string.format("[%d/%d] %s", countone(pl_pos - 1),
pl_count, title) pl_count, title)
end end
@ -1970,7 +1924,7 @@ function osc_init()
ne.enabled = (#tracks_osc.audio > 0) ne.enabled = (#tracks_osc.audio > 0)
ne.content = function () ne.content = function ()
local aid = "" local aid = ""
if not (get_track("audio") == 0) then if get_track("audio") ~= 0 then
aid = get_track("audio") aid = get_track("audio")
end end
return ("\238\132\134" .. osc_styles.smallButtonsLlabel return ("\238\132\134" .. osc_styles.smallButtonsLlabel
@ -1983,13 +1937,20 @@ function osc_init()
ne.eventresponder["shift+mbtn_left_down"] = ne.eventresponder["shift+mbtn_left_down"] =
function () show_message(get_tracklist("audio"), 2) end function () show_message(get_tracklist("audio"), 2) end
if user_opts.scrollcontrols then
ne.eventresponder["wheel_down_press"] =
function () set_track("audio", 1) end
ne.eventresponder["wheel_up_press"] =
function () set_track("audio", -1) end
end
--cy_sub --cy_sub
ne = new_element("cy_sub", "button") ne = new_element("cy_sub", "button")
ne.enabled = (#tracks_osc.sub > 0) ne.enabled = (#tracks_osc.sub > 0)
ne.content = function () ne.content = function ()
local sid = "" local sid = ""
if not (get_track("sub") == 0) then if get_track("sub") ~= 0 then
sid = get_track("sub") sid = get_track("sub")
end end
return ("\238\132\135" .. osc_styles.smallButtonsLlabel return ("\238\132\135" .. osc_styles.smallButtonsLlabel
@ -2002,10 +1963,17 @@ function osc_init()
ne.eventresponder["shift+mbtn_left_down"] = ne.eventresponder["shift+mbtn_left_down"] =
function () show_message(get_tracklist("sub"), 2) end function () show_message(get_tracklist("sub"), 2) end
if user_opts.scrollcontrols then
ne.eventresponder["wheel_down_press"] =
function () set_track("sub", 1) end
ne.eventresponder["wheel_up_press"] =
function () set_track("sub", -1) end
end
--tog_fs --tog_fs
ne = new_element("tog_fs", "button") ne = new_element("tog_fs", "button")
ne.content = function () ne.content = function ()
if (state.fullscreen) then if state.fullscreen then
return ("\238\132\137") return ("\238\132\137")
else else
return ("\238\132\136") return ("\238\132\136")
@ -2017,11 +1985,11 @@ function osc_init()
--seekbar --seekbar
ne = new_element("seekbar", "slider") ne = new_element("seekbar", "slider")
ne.enabled = not (mp.get_property("percent-pos") == nil) ne.enabled = mp.get_property("percent-pos") ~= nil
state.slider_element = ne.enabled and ne or nil -- used for forced_title state.slider_element = ne.enabled and ne or nil -- used for forced_title
ne.slider.markerF = function () ne.slider.markerF = function ()
local duration = mp.get_property_number("duration", nil) local duration = mp.get_property_number("duration", nil)
if not (duration == nil) then if duration ~= nil then
local chapters = mp.get_property_native("chapter-list", {}) local chapters = mp.get_property_native("chapter-list", {})
local markers = {} local markers = {}
for n = 1, #chapters do for n = 1, #chapters do
@ -2036,7 +2004,7 @@ function osc_init()
function () return mp.get_property_number("percent-pos", nil) end function () return mp.get_property_number("percent-pos", nil) end
ne.slider.tooltipF = function (pos) ne.slider.tooltipF = function (pos)
local duration = mp.get_property_number("duration", nil) local duration = mp.get_property_number("duration", nil)
if not ((duration == nil) or (pos == nil)) then if duration ~= nil and pos ~= nil then
possec = duration * (pos / 100) possec = duration * (pos / 100)
return mp.format_time(possec) return mp.format_time(possec)
else else
@ -2052,7 +2020,7 @@ function osc_init()
return nil return nil
end end
local duration = mp.get_property_number("duration", nil) local duration = mp.get_property_number("duration", nil)
if (duration == nil) or duration <= 0 then if duration == nil or duration <= 0 then
return nil return nil
end end
local ranges = cache_state["seekable-ranges"] local ranges = cache_state["seekable-ranges"]
@ -2074,8 +2042,8 @@ function osc_init()
-- sent when the user is done seeking, so we need to throw away -- sent when the user is done seeking, so we need to throw away
-- identical seeks -- identical seeks
local seekto = get_slider_value(element) local seekto = get_slider_value(element)
if (element.state.lastseek == nil) or if element.state.lastseek == nil or
(not (element.state.lastseek == seekto)) then element.state.lastseek ~= seekto then
local flags = "absolute-percent" local flags = "absolute-percent"
if not user_opts.seekbarkeyframes then if not user_opts.seekbarkeyframes then
flags = flags .. "+exact" flags = flags .. "+exact"
@ -2091,12 +2059,19 @@ function osc_init()
ne.eventresponder["reset"] = ne.eventresponder["reset"] =
function (element) element.state.lastseek = nil end function (element) element.state.lastseek = nil end
if user_opts.scrollcontrols then
ne.eventresponder["wheel_up_press"] =
function () mp.commandv("osd-auto", "seek", 10) end
ne.eventresponder["wheel_down_press"] =
function () mp.commandv("osd-auto", "seek", -10) end
end
-- tc_left (current pos) -- tc_left (current pos)
ne = new_element("tc_left", "button") ne = new_element("tc_left", "button")
ne.content = function () ne.content = function ()
if (state.tc_ms) then if state.tc_ms then
return (mp.get_property_osd("playback-time/full")) return (mp.get_property_osd("playback-time/full"))
else else
return (mp.get_property_osd("playback-time")) return (mp.get_property_osd("playback-time"))
@ -2112,12 +2087,14 @@ function osc_init()
ne.visible = (mp.get_property_number("duration", 0) > 0) ne.visible = (mp.get_property_number("duration", 0) > 0)
ne.content = function () ne.content = function ()
if (state.rightTC_trem) then if state.rightTC_trem then
local minus = user_opts.unicodeminus and UNICODE_MINUS or "-" local minus = user_opts.unicodeminus and UNICODE_MINUS or "-"
local property = user_opts.remaining_playtime and "playtime-remaining"
or "time-remaining"
if state.tc_ms then if state.tc_ms then
return (minus..mp.get_property_osd("playtime-remaining/full")) return (minus..mp.get_property_osd(property .. "/full"))
else else
return (minus..mp.get_property_osd("playtime-remaining")) return (minus..mp.get_property_osd(property))
end end
else else
if state.tc_ms then if state.tc_ms then
@ -2171,10 +2148,12 @@ function osc_init()
ne.eventresponder["mbtn_left_up"] = ne.eventresponder["mbtn_left_up"] =
function () mp.commandv("cycle", "mute") end function () mp.commandv("cycle", "mute") end
ne.eventresponder["wheel_up_press"] = if user_opts.scrollcontrols then
function () mp.commandv("osd-auto", "add", "volume", 5) end ne.eventresponder["wheel_up_press"] =
ne.eventresponder["wheel_down_press"] = function () mp.commandv("osd-auto", "add", "volume", 5) end
function () mp.commandv("osd-auto", "add", "volume", -5) end ne.eventresponder["wheel_down_press"] =
function () mp.commandv("osd-auto", "add", "volume", -5) end
end
-- load layout -- load layout
@ -2204,7 +2183,7 @@ function update_margins()
local margins = osc_param.video_margins local margins = osc_param.video_margins
-- Don't use margins if it's visible only temporarily. -- Don't use margins if it's visible only temporarily.
if (not state.osc_visible) or (get_hidetimeout() >= 0) or if not state.osc_visible or get_hidetimeout() >= 0 or
(state.fullscreen and not user_opts.showfullscreen) or (state.fullscreen and not user_opts.showfullscreen) or
(not state.fullscreen and not user_opts.showwindowed) (not state.fullscreen and not user_opts.showwindowed)
then then
@ -2226,7 +2205,7 @@ function update_margins()
if not margins_used then if not margins_used then
for _, opt in ipairs(margins_opts) do for _, opt in ipairs(margins_opts) do
local v = margins[opt[1]] local v = margins[opt[1]]
if (v ~= 0) or state.using_video_margins then if v ~= 0 or state.using_video_margins then
mp.set_property_number(opt[2], v) mp.set_property_number(opt[2], v)
state.using_video_margins = true state.using_video_margins = true
end end
@ -2236,13 +2215,12 @@ function update_margins()
reset_margins() reset_margins()
end end
utils.shared_script_property_set("osc-margins", mp.set_property_native("user-data/osc/margins", margins)
string.format("%f,%f,%f,%f", margins.l, margins.r, margins.t, margins.b))
end end
function shutdown() function shutdown()
reset_margins() reset_margins()
utils.shared_script_property_set("osc-margins", nil) mp.del_property("user-data/osc")
end end
-- --
@ -2260,7 +2238,7 @@ function show_osc()
osc_visible(true) osc_visible(true)
if (user_opts.fadeduration > 0) then if user_opts.fadeduration > 0 then
state.anitype = nil state.anitype = nil
end end
end end
@ -2272,8 +2250,8 @@ function hide_osc()
-- no-op and won't render again to remove the osc, so do that manually. -- no-op and won't render again to remove the osc, so do that manually.
state.osc_visible = false state.osc_visible = false
render_wipe() render_wipe()
elseif (user_opts.fadeduration > 0) then elseif user_opts.fadeduration > 0 then
if not(state.osc_visible == false) then if state.osc_visible then
state.anitype = "out" state.anitype = "out"
request_tick() request_tick()
end end
@ -2355,8 +2333,8 @@ function render()
local now = mp.get_time() local now = mp.get_time()
-- check if display changed, if so request reinit -- check if display changed, if so request reinit
if not (state.mp_screen_sizeX == current_screen_sizeX if state.mp_screen_sizeX ~= current_screen_sizeX
and state.mp_screen_sizeY == current_screen_sizeY) then or state.mp_screen_sizeY ~= current_screen_sizeY then
request_init_resize() request_init_resize()
@ -2366,7 +2344,7 @@ function render()
-- init management -- init management
if state.active_element then if state.active_element then
-- mouse is held down on some element - keep ticking and igore initReq -- mouse is held down on some element - keep ticking and ignore initReq
-- till it's released, or else the mouse-up (click) will misbehave or -- till it's released, or else the mouse-up (click) will misbehave or
-- get ignored. that's because osc_init() recreates the osc elements, -- get ignored. that's because osc_init() recreates the osc elements,
-- but mouse handling depends on the elements staying unmodified -- but mouse handling depends on the elements staying unmodified
@ -2386,27 +2364,27 @@ function render()
-- fade animation -- fade animation
if not(state.anitype == nil) then if state.anitype ~= nil then
if (state.anistart == nil) then if state.anistart == nil then
state.anistart = now state.anistart = now
end end
if (now < state.anistart + (user_opts.fadeduration/1000)) then if now < state.anistart + (user_opts.fadeduration / 1000) then
if (state.anitype == "in") then --fade in if state.anitype == "in" then --fade in
osc_visible(true) osc_visible(true)
state.animation = scale_value(state.anistart, state.animation = scale_value(state.anistart,
(state.anistart + (user_opts.fadeduration/1000)), (state.anistart + (user_opts.fadeduration / 1000)),
255, 0, now) 255, 0, now)
elseif (state.anitype == "out") then --fade out elseif state.anitype == "out" then --fade out
state.animation = scale_value(state.anistart, state.animation = scale_value(state.anistart,
(state.anistart + (user_opts.fadeduration/1000)), (state.anistart + (user_opts.fadeduration / 1000)),
0, 255, now) 0, 255, now)
end end
else else
if (state.anitype == "out") then if state.anitype == "out" then
osc_visible(false) osc_visible(false)
end end
kill_animation() kill_animation()
@ -2444,7 +2422,7 @@ function render()
state.input_enabled = state.osc_visible state.input_enabled = state.osc_visible
end end
if (mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2)) then if mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2) then
mouse_over_osc = true mouse_over_osc = true
end end
end end
@ -2453,12 +2431,17 @@ function render()
for _,cords in ipairs(osc_param.areas["window-controls"]) do for _,cords in ipairs(osc_param.areas["window-controls"]) do
if state.osc_visible then -- activate only when OSC is actually visible if state.osc_visible then -- activate only when OSC is actually visible
set_virt_mouse_area(cords.x1, cords.y1, cords.x2, cords.y2, "window-controls") set_virt_mouse_area(cords.x1, cords.y1, cords.x2, cords.y2, "window-controls")
mp.enable_key_bindings("window-controls") end
else if state.osc_visible ~= state.windowcontrols_buttons then
mp.disable_key_bindings("window-controls") if state.osc_visible then
mp.enable_key_bindings("window-controls")
else
mp.disable_key_bindings("window-controls")
end
state.windowcontrols_buttons = state.osc_visible
end end
if (mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2)) then if mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2) then
mouse_over_osc = true mouse_over_osc = true
end end
end end
@ -2466,17 +2449,29 @@ function render()
if osc_param.areas["window-controls-title"] then if osc_param.areas["window-controls-title"] then
for _,cords in ipairs(osc_param.areas["window-controls-title"]) do for _,cords in ipairs(osc_param.areas["window-controls-title"]) do
if (mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2)) then if state.osc_visible then -- activate only when OSC is actually visible
set_virt_mouse_area(cords.x1, cords.y1, cords.x2, cords.y2, "window-controls-title")
end
if state.osc_visible ~= state.windowcontrols_title then
if state.osc_visible then
mp.enable_key_bindings("window-controls-title", "allow-vo-dragging")
else
mp.disable_key_bindings("window-controls-title", "allow-vo-dragging")
end
state.windowcontrols_title = state.osc_visible
end
if mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2) then
mouse_over_osc = true mouse_over_osc = true
end end
end end
end end
-- autohide -- autohide
if not (state.showtime == nil) and (get_hidetimeout() >= 0) then if state.showtime ~= nil and get_hidetimeout() >= 0 then
local timeout = state.showtime + (get_hidetimeout()/1000) - now local timeout = state.showtime + (get_hidetimeout() / 1000) - now
if timeout <= 0 then if timeout <= 0 then
if (state.active_element == nil) and not (mouse_over_osc) then if state.active_element == nil and not mouse_over_osc then
hide_osc() hide_osc()
end end
else else
@ -2506,7 +2501,7 @@ function render()
-- submit -- submit
set_osd(osc_param.playresy * osc_param.display_aspect, set_osd(osc_param.playresy * osc_param.display_aspect,
osc_param.playresy, ass.text) osc_param.playresy, ass.text, 1000)
end end
-- --
@ -2570,8 +2565,8 @@ function process_event(source, what)
state.mouse_in_window = true state.mouse_in_window = true
local mouseX, mouseY = get_virt_mouse_pos() local mouseX, mouseY = get_virt_mouse_pos()
if (user_opts.minmousemove == 0) or if user_opts.minmousemove == 0 or
(not ((state.last_mouseX == nil) or (state.last_mouseY == nil)) and ((state.last_mouseX ~= nil and state.last_mouseY ~= nil) and
((math.abs(mouseX - state.last_mouseX) >= user_opts.minmousemove) ((math.abs(mouseX - state.last_mouseX) >= user_opts.minmousemove)
or (math.abs(mouseY - state.last_mouseY) >= user_opts.minmousemove) or (math.abs(mouseY - state.last_mouseY) >= user_opts.minmousemove)
) )
@ -2623,13 +2618,16 @@ function tick()
state.marginsREQ = false state.marginsREQ = false
end end
if (not state.enabled) then return end if not state.enabled then return end
if (state.idle) then if state.idle then
-- render idle message -- render idle message
msg.trace("idle message") msg.trace("idle message")
local _, _, display_aspect = mp.get_osd_size() local _, _, display_aspect = mp.get_osd_size()
if display_aspect == 0 then
return
end
local display_h = 360 local display_h = 360
local display_w = display_h * display_aspect local display_w = display_h * display_aspect
-- logo is rendered at 2^(6-1) = 32 times resolution with size 1800x1800 -- logo is rendered at 2^(6-1) = 32 times resolution with size 1800x1800
@ -2659,7 +2657,7 @@ function tick()
ass:an(8) ass:an(8)
ass:append("Drop files or URLs to play here.") ass:append("Drop files or URLs to play here.")
end end
set_osd(display_w, display_h, ass.text) set_osd(display_w, display_h, ass.text, -1000)
if state.showhide_enabled then if state.showhide_enabled then
mp.disable_key_bindings("showhide") mp.disable_key_bindings("showhide")
@ -2668,7 +2666,7 @@ function tick()
end end
elseif (state.fullscreen and user_opts.showfullscreen) elseif state.fullscreen and user_opts.showfullscreen
or (not state.fullscreen and user_opts.showwindowed) then or (not state.fullscreen and user_opts.showwindowed) then
-- render the OSC -- render the OSC
@ -2731,9 +2729,9 @@ function update_duration_watch()
(mp.get_property_number("chapters", 0) or 0) > 0 and (mp.get_property_number("chapters", 0) or 0) > 0 and
true or false -- ensure it's a boolean true or false -- ensure it's a boolean
if (want_watch ~= duration_watched) then if want_watch ~= duration_watched then
if want_watch then if want_watch then
mp.observe_property("duration", nil, on_duration) mp.observe_property("duration", "native", on_duration)
else else
mp.unobserve_property(on_duration) mp.unobserve_property(on_duration)
end end
@ -2746,13 +2744,8 @@ update_duration_watch()
mp.register_event("shutdown", shutdown) mp.register_event("shutdown", shutdown)
mp.register_event("start-file", request_init) mp.register_event("start-file", request_init)
mp.observe_property("osc", "bool", function(name, value) mp.observe_property("track-list", "native", request_init)
if value == true then mp.observe_property("playlist", "native", request_init)
mp.set_property("osc", "no")
end
end)
mp.observe_property("track-list", nil, request_init)
mp.observe_property("playlist", nil, request_init)
mp.observe_property("chapter-list", "native", function(_, list) mp.observe_property("chapter-list", "native", function(_, list)
list = list or {} -- safety, shouldn't return nil list = list or {} -- safety, shouldn't return nil
table.sort(list, function(a, b) return a.time < b.time end) table.sort(list, function(a, b) return a.time < b.time end)
@ -2789,6 +2782,12 @@ mp.observe_property("border", "bool",
request_init_resize() request_init_resize()
end end
) )
mp.observe_property("title-bar", "bool",
function(name, val)
state.title_bar = val
request_init_resize()
end
)
mp.observe_property("window-maximized", "bool", mp.observe_property("window-maximized", "bool",
function(name, val) function(name, val)
state.maximized = val state.maximized = val
@ -2895,7 +2894,7 @@ function visibility_mode(mode, no_osd)
end end
user_opts.visibility = mode user_opts.visibility = mode
utils.shared_script_property_set("osc-visibility", mode) mp.set_property_native("user-data/osc/visibility", mode)
if not no_osd and tonumber(mp.get_property("osd-level")) >= 1 then if not no_osd and tonumber(mp.get_property("osd-level")) >= 1 then
mp.osd_message("OSC visibility: " .. mode) mp.osd_message("OSC visibility: " .. mode)
@ -2927,7 +2926,7 @@ function idlescreen_visibility(mode, no_osd)
user_opts.idlescreen = false user_opts.idlescreen = false
end end
utils.shared_script_property_set("osc-idlescreen", mode) mp.set_property_native("user-data/osc/idlescreen", user_opts.idlescreen)
if not no_osd and tonumber(mp.get_property("osd-level")) >= 1 then if not no_osd and tonumber(mp.get_property("osd-level")) >= 1 then
mp.osd_message("OSC logo visibility: " .. tostring(mode)) mp.osd_message("OSC logo visibility: " .. tostring(mode))
@ -2942,14 +2941,6 @@ mp.add_key_binding(nil, "visibility", function() visibility_mode("cycle") end)
mp.register_script_message("osc-idlescreen", idlescreen_visibility) mp.register_script_message("osc-idlescreen", idlescreen_visibility)
mp.register_script_message("thumbfast-info", function(json)
local data = utils.parse_json(json)
if type(data) ~= "table" or not data.width or not data.height then
msg.error("thumbfast-info: received json didn't produce a table with thumbnail information")
else
thumbfast = data
end
end)
set_virt_mouse_area(0, 0, 0, 0, "input") set_virt_mouse_area(0, 0, 0, 0, "input")
set_virt_mouse_area(0, 0, 0, 0, "window-controls") set_virt_mouse_area(0, 0, 0, 0, "window-controls")
set_virt_mouse_area(0, 0, 0, 0, "window-controls-title")