5.4.5.1 Beta
This commit is contained in:
@@ -8,9 +8,11 @@ using System.Linq;
|
||||
class Script
|
||||
{
|
||||
MainForm MainForm;
|
||||
Core core;
|
||||
|
||||
public Script()
|
||||
{
|
||||
core = Core.core;
|
||||
MainForm = mpvnet.MainForm.Instance;
|
||||
MainForm.ContextMenu.Opening += ContextMenu_Opening;
|
||||
}
|
||||
@@ -24,13 +26,13 @@ class Script
|
||||
return;
|
||||
|
||||
menuItem.DropDownItems.Clear();
|
||||
var editionTracks = mp.MediaTracks.Where(track => track.Type == "e");
|
||||
var editionTracks = core.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;
|
||||
mi.Action = () => { core.commandv("set", "edition", track.ID.ToString()); };
|
||||
mi.Checked = core.Edition == track.ID;
|
||||
menuItem.DropDownItems.Add(mi);
|
||||
}
|
||||
}
|
||||
@@ -11,9 +11,10 @@ class Script
|
||||
{
|
||||
string content = "ctrl+w script-message my-message-1 my-argument-1";
|
||||
string sectionName = Assembly.GetExecutingAssembly().GetName().Name;
|
||||
mp.commandv("define-section", sectionName, content, "force");
|
||||
mp.commandv("enable-section", sectionName);
|
||||
mp.ClientMessage += ClientMessage;
|
||||
Core core = Core.core;
|
||||
core.commandv("define-section", sectionName, content, "force");
|
||||
core.commandv("enable-section", sectionName);
|
||||
core.ClientMessage += ClientMessage;
|
||||
}
|
||||
|
||||
void ClientMessage(string[] args)
|
||||
@@ -6,13 +6,16 @@ using mpvnet;
|
||||
|
||||
class Script
|
||||
{
|
||||
Core core;
|
||||
|
||||
public Script()
|
||||
{
|
||||
mp.observe_property_bool("fullscreen", FullscreenChange);
|
||||
core = Core.core;
|
||||
core.observe_property_bool("fullscreen", FullscreenChange);
|
||||
}
|
||||
|
||||
void FullscreenChange(bool value)
|
||||
{
|
||||
mp.commandv("show-text", "fullscreen: " + value);
|
||||
core.commandv("show-text", "fullscreen: " + value);
|
||||
}
|
||||
}
|
||||
@@ -9,12 +9,14 @@ using mpvnet;
|
||||
class Script
|
||||
{
|
||||
MainForm Form;
|
||||
Core core;
|
||||
|
||||
bool WasPlaying;
|
||||
bool WasPaused;
|
||||
|
||||
public Script()
|
||||
{
|
||||
core = Core.core;
|
||||
Form = MainForm.Instance;
|
||||
Form.Resize += Form_Resize;
|
||||
}
|
||||
@@ -23,11 +25,11 @@ class Script
|
||||
{
|
||||
if (Form.WindowState == FormWindowState.Minimized)
|
||||
{
|
||||
WasPlaying = !mp.get_property_bool("pause");
|
||||
WasPlaying = !core.get_property_bool("pause");
|
||||
|
||||
if (WasPlaying)
|
||||
{
|
||||
mp.set_property_bool("pause", true, true);
|
||||
core.set_property_bool("pause", true, true);
|
||||
WasPaused = true;
|
||||
}
|
||||
}
|
||||
@@ -35,7 +37,7 @@ class Script
|
||||
{
|
||||
if (WasPaused)
|
||||
{
|
||||
mp.set_property_bool("pause", false, true);
|
||||
core.set_property_bool("pause", false, true);
|
||||
WasPaused = false;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
// This script shows a message box using the Msg class of mpv.net.
|
||||
|
||||
[Msg]::Show("Hello World")
|
||||
@@ -1,25 +0,0 @@
|
||||
|
||||
# Shows the Open File dialog to open a file without loading its folder into the playlist.
|
||||
|
||||
# In input.conf add: <key> script-message load-without-folder
|
||||
|
||||
$job = Register-ObjectEvent -InputObject ([mpvnet.mp]) -EventName ClientMessage -Action {
|
||||
|
||||
# exit if message does not equal 'load-without-folder'
|
||||
if ($args.Length -ne 1 -or $args[0] -ne 'load-without-folder')
|
||||
{
|
||||
exit
|
||||
}
|
||||
|
||||
$dialog = New-Object Windows.Forms.OpenFileDialog
|
||||
|
||||
if ($dialog.ShowDialog() -ne "OK") {
|
||||
$dialog.Dispose()
|
||||
exit
|
||||
}
|
||||
|
||||
[mp]::Load($dialog.FileNames, $false, $false);
|
||||
$dialog.Dispose()
|
||||
}
|
||||
|
||||
$ScriptHost.RedirectEventJobStreams($job)
|
||||
@@ -1,8 +0,0 @@
|
||||
|
||||
# Display position in window title bar when seeking
|
||||
|
||||
$job = Register-ObjectEvent -InputObject ([mpvnet.mp]) -EventName Seek -Action {
|
||||
[MainForm]::Instance.Text = [mp]::get_property_number("time-pos")
|
||||
}
|
||||
|
||||
$ScriptHost.RedirectEventJobStreams($job)
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
function showPlaylist()
|
||||
{
|
||||
|
||||
// set font size
|
||||
mp.set_property_number("osd-font-size", 40);
|
||||
|
||||
@@ -8,18 +8,16 @@
|
||||
local did_minimize = false
|
||||
|
||||
mp.observe_property("window-minimized", "bool", function(name, value)
|
||||
local pause = mp.get_property_bool("pause")
|
||||
|
||||
local pause = mp.get_property_native("pause")
|
||||
if value == true then
|
||||
if pause == false then
|
||||
mp.set_property_bool("pause", true)
|
||||
mp.set_property_native("pause", true)
|
||||
did_minimize = true
|
||||
end
|
||||
elseif value == false then
|
||||
if did_minimize and (pause == true) then
|
||||
mp.set_property_bool("pause", false)
|
||||
mp.set_property_native("pause", false)
|
||||
end
|
||||
|
||||
did_minimize = false
|
||||
end
|
||||
end)
|
||||
20
scripts/powershell/open-file-dialog.ps1
Normal file
20
scripts/powershell/open-file-dialog.ps1
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
# Shows the Open File dialog to open a file without loading its folder into the playlist.
|
||||
|
||||
# In input.conf add: <key> script-message load-without-folder
|
||||
|
||||
$code = {
|
||||
if ($args[0] -eq 'load-without-folder')
|
||||
{
|
||||
$dialog = New-Object Windows.Forms.OpenFileDialog
|
||||
|
||||
if ($dialog.ShowDialog() -eq 'OK')
|
||||
{
|
||||
$core.LoadFiles($dialog.FileNames, $false, $false);
|
||||
}
|
||||
|
||||
$dialog.Dispose()
|
||||
}
|
||||
}
|
||||
|
||||
$mp.register_event("client-message", $code)
|
||||
27
scripts/powershell/pause-when-minimize.ps1
Normal file
27
scripts/powershell/pause-when-minimize.ps1
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
Set-Variable wasPaused $false -Option AllScope
|
||||
|
||||
$code = {
|
||||
$isMinimized = $args[0]
|
||||
$isPaused = $mp.get_property_bool('pause')
|
||||
|
||||
if ($isMinimized)
|
||||
{
|
||||
if (-not $isPaused)
|
||||
{
|
||||
$mp.set_property_bool('pause', $true)
|
||||
$wasPaused = $true
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($wasPaused -and $isPaused)
|
||||
{
|
||||
$mp.set_property_bool('pause', $false)
|
||||
}
|
||||
|
||||
$wasPaused = $false
|
||||
}
|
||||
}
|
||||
|
||||
$mp.observe_property('window-minimized', 'bool', $code)
|
||||
Reference in New Issue
Block a user