Mpv: DIsplay OSC when Paused

Created on 29 Mar 2019  ·  3Comments  ·  Source: mpv-player/mpv

Is there anyway to have the OSC show when pausing?
Maybe through scripting?

Most helpful comment

For reference if anyone finds this in a search.
I adding the following script in a new script file I created titled _osc-custom-pause.lua_ script file located in ~/.config/mpv/scripts

function on_pause_change(name, value)
    if value == true then
        mp.command("script-message osc-visibility " .. ("always"))
    else
        mp.command("script-message osc-visibility " .. ("auto"))
    end
end
mp.observe_property("pause", "bool", on_pause_change)

All 3 comments

yes, something along these lines. observe the pause property, and the set osc-visibility to either always or auto.

For reference if anyone finds this in a search.
I adding the following script in a new script file I created titled _osc-custom-pause.lua_ script file located in ~/.config/mpv/scripts

function on_pause_change(name, value)
    if value == true then
        mp.command("script-message osc-visibility " .. ("always"))
    else
        mp.command("script-message osc-visibility " .. ("auto"))
    end
end
mp.observe_property("pause", "bool", on_pause_change)

I have an updated version of @SPDurkee's script, where the messages OSC visibility: always/auto are not displayed:

-- from https://github.com/mpv-player/mpv/issues/6592#issuecomment-488269456
function on_pause_show_osc(name, value)
    if value == true then
        mp.command("no-osd set osd-level 0; script-message osc-visibility always")
        reset_osd()
    else
        mp.command("no-osd set osd-level 0; script-message osc-visibility auto")
        reset_osd()
    end
end

-- For some reason `set osd-level 0; script-message osc-visibility always; no-osd set osd-level 1` does not work.
-- The OSC messages `OSC visibility: always/auto` are still displayed.
-- It's as if `no-osd set osd-level 1` runs before `script-message osc-visibility always` is run/displayed.`¯\_(ツ)_/¯`
-- As a workaround, I have to make the osd visible after a 1 second timeout.
-- Why? No idea. Bugs?`¯\_(ツ)_/¯`
function reset_osd()
    mp.add_timeout(1,
        function()
            mp.command("no-osd set osd-level 1")
        end
    )
end

mp.observe_property("pause", "bool", on_pause_show_osc)

Here's a preview of what i mean:

With 1 second delay osd-reset:
with script

Without 1 second delay osd-reset:
without

Was this page helpful?
0 / 5 - 0 ratings