5.4.4.4 Beta
This commit is contained in:
43
scripts/examples/pause-when-minimize.cs
Normal file
43
scripts/examples/pause-when-minimize.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
// Pauses playback when window is minimized and resumes afterwards.
|
||||
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using mpvnet;
|
||||
|
||||
class Script
|
||||
{
|
||||
MainForm Form;
|
||||
|
||||
bool WasPlaying;
|
||||
bool WasPaused;
|
||||
|
||||
public Script()
|
||||
{
|
||||
Form = MainForm.Instance;
|
||||
Form.Resize += Form_Resize;
|
||||
}
|
||||
|
||||
private void Form_Resize(object sender, EventArgs e)
|
||||
{
|
||||
if (Form.WindowState == FormWindowState.Minimized)
|
||||
{
|
||||
WasPlaying = !mp.get_property_bool("pause");
|
||||
|
||||
if (WasPlaying)
|
||||
{
|
||||
mp.set_property_bool("pause", true, true);
|
||||
WasPaused = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WasPaused)
|
||||
{
|
||||
mp.set_property_bool("pause", false, true);
|
||||
WasPaused = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,10 @@
|
||||
|
||||
-- https://github.com/mpv-player/mpv/blob/master/TOOLS/lua/pause-when-minimize.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)
|
||||
|
||||
Reference in New Issue
Block a user