scripting docs
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
// creates context menu items dynamically
|
||||
// This script creates context menu items dynamically.
|
||||
|
||||
using mpvnet;
|
||||
using System.ComponentModel;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
|
||||
// This script adds a key binding.
|
||||
|
||||
using System.Reflection;
|
||||
|
||||
using mpvnet;
|
||||
|
||||
4
scripts/examples/message-box.ps1
Normal file
4
scripts/examples/message-box.ps1
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
// This script shows a message box using the Msg class of mpv.net.
|
||||
|
||||
[Msg]::Show("Hello World")
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
25
scripts/examples/open-file-dialog.ps1
Normal file
25
scripts/examples/open-file-dialog.ps1
Normal 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)
|
||||
8
scripts/examples/seek.ps1
Normal file
8
scripts/examples/seek.ps1
Normal 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)
|
||||
27
scripts/examples/show-playlist.js
Normal file
27
scripts/examples/show-playlist.js
Normal 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);
|
||||
Reference in New Issue
Block a user