History

TOOLS/lua: add script that pauses playback when minimizing the window

Uses functionality that was added a month ago for exactly this purpose. Fixes #1237.

wm4 committed 11 years ago

Commit 9666d481 parent a72a4b21 file · +22 −0Browse files

Showing the changes to TOOLS/lua/pause-when-minimize.lua (1 of 1 file). Show all

Unified · Split

TOOLS/lua/pause-when-minimize.lua+22−0
@@ -0,0 +1,22 @@
1+-- This script pauses playback when minimizing the window, and resumes playback
2+-- if it's brought back again. If the player was already paused when minimizing,
3+-- then try not to mess with the pause state.
4+
5+-- Note: currently works with X11 only.
6+
7+local did_minimize = false
8+
9+mp.observe_property("window-minimized", "bool", function(name, value)
10+ local pause = mp.get_property_native("pause")
11+ if value == true then
12+ if pause == false then
13+ mp.set_property_native("pause", true)
14+ did_minimize = true
15+ end
16+ elseif value == false then
17+ if did_minimize and (pause == true) then
18+ mp.set_property_native("pause", false)
19+ end
20+ did_minimize = false
21+ end
22+end)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t