command palette support
This commit is contained in:
@@ -14,6 +14,7 @@ using MpvNet.Windows.WPF;
|
||||
using MpvNet.Windows.WPF.MsgBox;
|
||||
using MpvNet.Windows.Help;
|
||||
using MpvNet.Help;
|
||||
using System.Windows.Documents;
|
||||
|
||||
namespace MpvNet;
|
||||
|
||||
@@ -56,6 +57,8 @@ public class GuiCommand
|
||||
["show-properties"] = args => Player.Command("script-binding select/show-properties"),
|
||||
["show-protocols"] = args => ShowProtocols(),
|
||||
["window-scale"] = args => WindowScaleNet?.Invoke(float.Parse(args[0], CultureInfo.InvariantCulture)),
|
||||
["install-command-palette"] = args => InstallCommandPalette(),
|
||||
["show-recent-in-command-palette"] = args => ShowRecentFilesInCommandPalette(),
|
||||
|
||||
|
||||
// deprecated
|
||||
@@ -267,6 +270,56 @@ public class GuiCommand
|
||||
catch { }
|
||||
}
|
||||
|
||||
void InstallCommandPalette()
|
||||
{
|
||||
if (Msg.ShowQuestion("Install command palette?") != MessageBoxResult.OK)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
Environment.SetEnvironmentVariable("MPVNET_HOME", Player.ConfigFolder);
|
||||
using Process proc = new Process();
|
||||
proc.StartInfo.FileName = "powershell";
|
||||
proc.StartInfo.Arguments = "-executionpolicy bypass -nologo -noexit -noprofile -command \"irm https://raw.githubusercontent.com/stax76/mpv-scripts/refs/heads/main/powershell/command_palette_installer.ps1 | iex\"";
|
||||
proc.Start();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void ShowRecentFilesInCommandPalette()
|
||||
{
|
||||
Obj o = new();
|
||||
o.title = "Recent Files";
|
||||
o.selected_index = 0;
|
||||
|
||||
var items = new List<Item>();
|
||||
|
||||
foreach (string file in App.Settings.RecentFiles)
|
||||
items.Add(new Item() { title = Path.GetFileName(file),
|
||||
value = new string []{ "loadfile", file },
|
||||
hint = file});
|
||||
|
||||
o.items = items.ToArray();
|
||||
string json = JsonSerializer.Serialize(o);
|
||||
Player.CommandV("script-message", "show-command-palette-json", json);
|
||||
}
|
||||
|
||||
public class Obj
|
||||
{
|
||||
public string title { get; set; } = "";
|
||||
public int selected_index { get; set; } = 0;
|
||||
public Item[] items { get; set; } = Array.Empty<Item>();
|
||||
}
|
||||
|
||||
public class Item
|
||||
{
|
||||
public string[] value { get; set; } = Array.Empty<string>();
|
||||
public string title { get; set; } = "";
|
||||
public string hint { get; set; } = "";
|
||||
}
|
||||
|
||||
void ShowMediaInfo(IList<string> args)
|
||||
{
|
||||
if (Player.PlaylistPos == -1)
|
||||
|
||||
@@ -25,7 +25,7 @@ name = image-exts
|
||||
file = mpv
|
||||
directory = General
|
||||
width = 500
|
||||
help = Image file extentions to try to match when using --cover-art-auto, --autocreate-playlist or --directory-filter-types. By mpv.net used to create file associations and used by the auto-load-folder feature.
|
||||
help = Image file extentions to try to match when using --cover-art-auto, --autocreate-playlist or --directory-filter-types. By mpv.net used to create file associations and used by the auto-load-folder feature. Default: avif,bmp,gif,j2k,jp2,jpeg,jpg,jxl,png,svg,tga,tif,tiff,webp
|
||||
|
||||
name = menu-syntax
|
||||
file = mpvnet
|
||||
@@ -782,7 +782,7 @@ name = video-exts
|
||||
file = mpv
|
||||
directory = Video
|
||||
width = 500
|
||||
help = Video file extentions to try to match when using --autocreate-playlist or --directory-filter-types. By mpv.net used to create file associations and used by the auto-load-folder feature.
|
||||
help = Video file extentions to try to match when using --autocreate-playlist or --directory-filter-types. By mpv.net used to create file associations and used by the auto-load-folder feature. Default: 3g2,3gp,avi,flv,m2ts,m4v,mj2,mkv,mov,mp4,mpeg,mpg,ogv,rmvb,ts,webm,wmv,y4m
|
||||
|
||||
name = volume
|
||||
file = mpv
|
||||
@@ -831,7 +831,7 @@ name = audio-exts
|
||||
file = mpv
|
||||
directory = Audio
|
||||
width = 500
|
||||
help = Audio file extentions to try to match when using --audio-file-auto, --autocreate-playlist or --directory-filter-types. By mpv.net used to create file associations and used by the auto-load-folder feature.
|
||||
help = Audio file extentions to try to match when using --audio-file-auto, --autocreate-playlist or --directory-filter-types. By mpv.net used to create file associations and used by the auto-load-folder feature. Default: aac,ac3,aiff,ape,au,dts,eac3,flac,m4a,mka,mp3,oga,ogg,ogm,opus,thd,wav,wav,wma,wv
|
||||
|
||||
name = slang
|
||||
file = mpv
|
||||
|
||||
Reference in New Issue
Block a user