full implementation for window-minimized and window-maximized
This commit is contained in:
37
scripts/examples/dynamic-context-menu-items.cs
Normal file
37
scripts/examples/dynamic-context-menu-items.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
// creates context menu items dynamically
|
||||
|
||||
using mpvnet;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
|
||||
class Script
|
||||
{
|
||||
MainForm MainForm;
|
||||
|
||||
public Script()
|
||||
{
|
||||
MainForm = mpvnet.MainForm.Instance;
|
||||
MainForm.ContextMenu.Opening += ContextMenu_Opening;
|
||||
}
|
||||
|
||||
void ContextMenu_Opening(object sender, CancelEventArgs e)
|
||||
{
|
||||
// edit input.conf and add 'Edition' menu item there
|
||||
MenuItem menuItem = MainForm.FindMenuItem("Edition");
|
||||
|
||||
if (menuItem == null)
|
||||
return;
|
||||
|
||||
menuItem.DropDownItems.Clear();
|
||||
var editionTracks = mp.MediaTracks.Where(track => track.Type == "e");
|
||||
|
||||
foreach (MediaTrack track in editionTracks)
|
||||
{
|
||||
MenuItem mi = new MenuItem(track.Text);
|
||||
mi.Action = () => { mp.commandv("set", "edition", track.ID.ToString()); };
|
||||
mi.Checked = mp.Edition == track.ID;
|
||||
menuItem.DropDownItems.Add(mi);
|
||||
}
|
||||
}
|
||||
}
|
||||
19
scripts/examples/pause-when-minimize.lua
Normal file
19
scripts/examples/pause-when-minimize.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
local did_minimize = false
|
||||
|
||||
mp.observe_property("window-minimized", "bool", function(name, value)
|
||||
local pause = mp.get_property_bool("pause")
|
||||
|
||||
if value == true then
|
||||
if pause == false then
|
||||
mp.set_property_bool("pause", true)
|
||||
did_minimize = true
|
||||
end
|
||||
elseif value == false then
|
||||
if did_minimize and (pause == true) then
|
||||
mp.set_property_bool("pause", false)
|
||||
end
|
||||
|
||||
did_minimize = false
|
||||
end
|
||||
end)
|
||||
Reference in New Issue
Block a user