Skip to content

Commit

Permalink
osc.lua add idlelogo and osc-idlelogo
Browse files Browse the repository at this point in the history
This is mainly for other user scripts that may conflict with the osc
logo in some way. Although it is possible to listen for
shared-script-properties, this has many edge cases that could easily pop
up. A user could want other OSC things to happen at the same time (say
osc-message). They just don't want the logo. The idlelogo option
disables all logo related things (including the santa hat) if it is set
to "no". A new script message (osc-idlelogo) is also added so users and
scripts can easily toggle the value (passing "cycle" or just explictly
setting "yes" or "no"). Some more discussion on this is found on the
below github issues.
mpv-player#10201
CogentRedTester/mpv-file-browser#55
  • Loading branch information
Dudemanguy committed May 24, 2022
1 parent f20dbcd commit ee30f51
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 8 deletions.
9 changes: 9 additions & 0 deletions DOCS/man/osc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ Configurable Options

Enable the OSC when fullscreen

``showlogo``
Default: yes

Show the mpv logo and message when idle

``scalewindowed``
Default: 1.0

Expand Down Expand Up @@ -418,6 +423,10 @@ to set auto mode (the default) with ``b``::
a script-message osc-visibility never
b script-message osc-visibility auto

``osc-idlelogo``
Controls the visibility of the mpv logo on idle. Valid arguments are ``yes``,
``no``, and ``cycle`` to toggle between yes and no.

``osc-playlist``, ``osc-chapterlist``, ``osc-tracklist``
Shows a limited view of the respective type of list using the OSC. First
argument is duration in seconds.
Expand Down
56 changes: 48 additions & 8 deletions player/lua/osc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ local utils = require 'mp.utils'
local user_opts = {
showwindowed = true, -- show OSC when windowed?
showfullscreen = true, -- show OSC when fullscreen?
idlelogo = true, -- show mpv logo on idle
scalewindowed = 1, -- scaling of the controller when windowed
scalefullscreen = 1, -- scaling of the controller when fullscreen
scaleforcedwindow = 2, -- scaling when rendered on a forced window
Expand Down Expand Up @@ -2579,23 +2580,27 @@ function tick()

local ass = assdraw.ass_new()
-- mpv logo
for i, line in ipairs(logo_lines) do
ass:new_event()
ass:append(line_prefix .. line)
if user_opts.idlelogo then
for i, line in ipairs(logo_lines) do
ass:new_event()
ass:append(line_prefix .. line)
end
end

-- Santa hat
if is_december and not user_opts.greenandgrumpy then
if is_december and user_opts.idlelogo and not user_opts.greenandgrumpy then
for i, line in ipairs(santa_hat_lines) do
ass:new_event()
ass:append(line_prefix .. line)
end
end

ass:new_event()
ass:pos(320, icon_y+65)
ass:an(8)
ass:append("Drop files or URLs to play here.")
if user_opts.idlelogo then
ass:new_event()
ass:pos(320, icon_y+65)
ass:an(8)
ass:append("Drop files or URLs to play here.")
end
set_osd(640, 360, ass.text)

if state.showhide_enabled then
Expand Down Expand Up @@ -2844,9 +2849,44 @@ function visibility_mode(mode, no_osd)
request_tick()
end

function idlelogo_visibility(mode, no_osd)
if mode == "cycle" then
if user_opts.idlelogo then
mode = "no"
else
mode = "yes"
end
end

if mode == "yes" then
user_opts.idlelogo = true
else
user_opts.idlelogo = false
end

utils.shared_script_property_set("osc-idlelogo", mode)

if not no_osd and tonumber(mp.get_property("osd-level")) >= 1 then
mp.osd_message("OSC logo visibility: " .. tostring(mode))
end

request_tick()
end

function idlelogo_visibility_toggle()
if user_opts.idlelogo == true then
mode = "no"
else
mode = "yes"
end
idlelogo_visibility(mode)
end

visibility_mode(user_opts.visibility, true)
mp.register_script_message("osc-visibility", visibility_mode)
mp.add_key_binding(nil, "visibility", function() visibility_mode("cycle") end)

mp.register_script_message("osc-idlelogo", idlelogo_visibility)

set_virt_mouse_area(0, 0, 0, 0, "input")
set_virt_mouse_area(0, 0, 0, 0, "window-controls")

0 comments on commit ee30f51

Please sign in to comment.