1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-11 17:37:23 +00:00
mpv/TOOLS/lua/pause-when-minimize.lua
2015-03-09 11:46:06 +01:00

21 lines
692 B
Lua

-- This script pauses playback when minimizing the window, and resumes playback
-- if it's brought back again. If the player was already paused when minimizing,
-- then try not to mess with the pause state.
local did_minimize = false
mp.observe_property("window-minimized", "bool", function(name, value)
local pause = mp.get_property_native("pause")
if value == true then
if pause == false then
mp.set_property_native("pause", true)
did_minimize = true
end
elseif value == false then
if did_minimize and (pause == true) then
mp.set_property_native("pause", false)
end
did_minimize = false
end
end)