From 9bb5a0b70550c2b071080e24e498fc30624b072e Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Tue, 3 Mar 2026 23:21:46 -0500 Subject: [PATCH] osc.lua: add audioonlyscreen script option Allows rendering mpv logo when there is no video, instead of black screen. osc is still available at the same time for playback control. --- DOCS/interface-changes/osc-audioonly.txt | 1 + DOCS/man/osc.rst | 5 +++ player/lua/osc.lua | 43 ++++++++++++++++++------ 3 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 DOCS/interface-changes/osc-audioonly.txt diff --git a/DOCS/interface-changes/osc-audioonly.txt b/DOCS/interface-changes/osc-audioonly.txt new file mode 100644 index 0000000000..fc12325b1b --- /dev/null +++ b/DOCS/interface-changes/osc-audioonly.txt @@ -0,0 +1 @@ +add `audioonlyscreen` script option to osc diff --git a/DOCS/man/osc.rst b/DOCS/man/osc.rst index 08d1969118..104e04bb58 100644 --- a/DOCS/man/osc.rst +++ b/DOCS/man/osc.rst @@ -261,6 +261,11 @@ Configurable Options Show the mpv logo and message when idle +``audioonlyscreen`` + Default: no + + Show the mpv logo when no video track is present or selected. + ``scalewindowed`` Default: 1.0 diff --git a/player/lua/osc.lua b/player/lua/osc.lua index 190f3e3849..bcbc91e04d 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -11,6 +11,7 @@ local user_opts = { showwindowed = true, -- show OSC when windowed? showfullscreen = true, -- show OSC when fullscreen? idlescreen = true, -- show mpv logo on idle + audioonlyscreen = false, -- show mpv logo when no video scalewindowed = 1, -- scaling of the controller when windowed scalefullscreen = 1, -- scaling of the controller when fullscreen vidscale = "auto", -- scale the controller with the video? @@ -256,6 +257,8 @@ local state = { hide_timer = nil, cache_state = nil, idle = false, + no_video = false, + file_loaded = false, enabled = true, input_enabled = true, showhide_enabled = false, @@ -2616,22 +2619,20 @@ local function render_logo() local ass = assdraw.ass_new() -- mpv logo - if user_opts.idlescreen then - for _, line in ipairs(logo_lines) do - ass:new_event() - ass:append(line_prefix .. line) - end + for _, line in ipairs(logo_lines) do + ass:new_event() + ass:append(line_prefix .. line) end -- Santa hat - if is_december and user_opts.idlescreen and not user_opts.greenandgrumpy then + if is_december and not user_opts.greenandgrumpy then for _, line in ipairs(santa_hat_lines) do ass:new_event() ass:append(line_prefix .. line) end end - if user_opts.idlescreen then + if state.idle then ass:new_event() ass:pos(display_w / 2, icon_y + 65) ass:an(8) @@ -2648,14 +2649,15 @@ tick = function() end if not state.enabled then return end - if not state.idle then - render_wipe(state.logo_osd) - end if state.idle then -- render idle message msg.trace("idle message") - render_logo() + if user_opts.idlescreen then + render_logo() + else + render_wipe(state.osd) + end if state.showhide_enabled then mp.disable_key_bindings("showhide") @@ -2665,6 +2667,11 @@ tick = function() elseif state.fullscreen and user_opts.showfullscreen or (not state.fullscreen and user_opts.showwindowed) then + if state.no_video and state.file_loaded and user_opts.audioonlyscreen then + render_logo() + else + render_wipe(state.logo_osd) + end -- render the OSC render() else @@ -2798,6 +2805,20 @@ mp.observe_property("idle-active", "bool", function(_, val) state.idle = val request_tick() end) +mp.observe_property("current-tracks/video", "native", function(_, val) + state.no_video = val == nil + request_tick() +end) + +mp.register_event("file-loaded", function() + state.file_loaded = true + state.no_video = mp.get_property_native("current-tracks/video") == nil + request_tick() +end) +mp.add_hook("on_unload", 50, function() + state.file_loaded = false + request_tick() +end) mp.observe_property("display-fps", "number", set_tick_delay) mp.observe_property("pause", "bool", pause_state)