scripting docs

This commit is contained in:
Frank Skare
2020-04-22 19:17:12 +02:00
parent 2eb324bf41
commit 14a172b78b
8 changed files with 139 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
// creates context menu items dynamically
// This script creates context menu items dynamically.
using mpvnet;
using System.ComponentModel;

View File

@@ -1,4 +1,6 @@
// This script adds a key binding.
using System.Reflection;
using mpvnet;

View File

@@ -0,0 +1,4 @@
// This script shows a message box using the Msg class of mpv.net.
[Msg]::Show("Hello World")

View File

@@ -1,5 +1,6 @@
// Draws text on screen when full screen property changes.
// This script observes the fullscreen property and
// draws text on screen when the property changes.
using mpvnet;
@@ -12,6 +13,6 @@ class Script
void FullscreenChange(bool value)
{
mp.commandv("show-text", "fullscreen: " + value.ToString());
mp.commandv("show-text", "fullscreen: " + value);
}
}

View File

@@ -0,0 +1,25 @@
# 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)

View File

@@ -0,0 +1,8 @@
# 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)

View File

@@ -0,0 +1,27 @@
// This script shows the playlist.
function showPlaylist()
{
// set font size
mp.set_property_number("osd-font-size", 40);
// show playlist for 5 seconds
mp.command("show-text ${playlist} 5000");
// restore original font size in 6 seconds
setTimeout(resetFontSize, 6000);
}
// restore original font size
function resetFontSize()
{
mp.set_property_number("osd-font-size", size);
}
// save original font size
var size = mp.get_property_number("osd-font-size");
// input.conf: key script-binding show-playlist
mp.add_key_binding(null, "show-playlist", showPlaylist);