This commit is contained in:
Frank Skare
2021-07-19 02:33:32 +02:00
parent fbeeb3f015
commit e1c9d81496
8 changed files with 252 additions and 214 deletions

View File

@@ -3,6 +3,8 @@
- Manual translated to simplified Chinese (hooke007)
- Showing the playlist selects the currently played file/stream in the playlist.
- Properties are shown in the command palette instead of the text editor
making it very easy to find a property and show/print its value.
5.4.9.1 Beta (2021-06-23)

View File

@@ -210,9 +210,8 @@ Adds files to the playlist, requires [--process-instance=single](#--process-inst
#### --command=\<input command\>
Sends a input command. Useful to control mpv.net from the command line, for instance
to create global hotkeys with AutoHotkey, for that [process-instance=single](#--process-instancevalue)
must be used. Spaces have to be escaped with quotes and quotes have to be escaped with double quotes.
Sends a input command to a running mpv.net instance via command line, for instance
to create global hotkeys with AutoHotkey. Requires [process-instance=single](#--process-instancevalue).
### Audio

View File

@@ -23,7 +23,7 @@ namespace mpvnet
public static bool RememberWindowPosition { get; set; }
public static bool DebugMode { get; set; }
public static bool IsStartedFromTerminal { get; } = Environment.GetEnvironmentVariable("_started_from_console") == "yes";
public static bool IsTerminalAttached { get; } = Environment.GetEnvironmentVariable("_started_from_console") == "yes";
public static bool RememberVolume { get; set; } = true;
public static bool AutoLoadFolder { get; set; } = true;
public static bool Queue { get; set; }
@@ -126,7 +126,7 @@ namespace mpvnet
public static void ShowException(object obj)
{
if (IsStartedFromTerminal)
if (IsTerminalAttached)
Terminal.WriteError(obj.ToString());
else
{
@@ -139,9 +139,23 @@ namespace mpvnet
public static void InvokeOnMainThread(Action action) => MainForm.Instance.BeginInvoke(action);
public static void ShowInfo(string title, string msg = null)
{
if (IsTerminalAttached)
{
if (title != null)
Terminal.Write(title);
if (msg != null)
Terminal.Write(msg);
}
else
InvokeOnMainThread(() => Msg.ShowInfo(title, msg));
}
public static void ShowError(string title, string msg = null)
{
if (IsStartedFromTerminal)
if (IsTerminalAttached)
{
if (title != null)
Terminal.WriteError(title);

View File

@@ -327,12 +327,6 @@ namespace mpvnet
ShowTextWithEditor("command-list", PowerShell.InvokeAndReturnString(code, "json", json));
}
public static void ShowProperties()
{
var props = Core.GetPropertyString("property-list").Split(',').OrderBy(prop => prop);
ShowTextWithEditor("property-list", string.Join(BR, props));
}
public static void ShowTextWithEditor(string name, string text)
{
string file = Path.Combine(Path.GetTempPath(), name + ".txt");
@@ -425,5 +419,37 @@ namespace mpvnet
MainForm.Instance.ShowCommandPalette();
}
public static void ShowProperties() => App.InvokeOnMainThread(ShowPropertiesInternal);
public static void ShowPropertiesInternal()
{
var props = Core.GetPropertyString("property-list").Split(',').OrderBy(prop => prop);
List<CommandPaletteItem> items = new List<CommandPaletteItem>();
foreach (string i in props)
{
string prop = i;
CommandPaletteItem item = new CommandPaletteItem()
{
Text = prop,
Action = () =>
{
string propValue = Core.GetPropertyString(prop);
if (propValue.ContainsEx("${"))
propValue += BR2 + Core.Expand(propValue);
App.ShowInfo(prop + ": " +propValue);
}
};
items.Add(item);
}
CommandPalette.Instance.SetItems(items);
MainForm.Instance.ShowCommandPalette();
}
}
}

View File

@@ -129,7 +129,7 @@ namespace mpvnet
App.RunTask(() => EventLoop());
if (App.IsStartedFromTerminal)
if (App.IsTerminalAttached)
{
SetPropertyString("terminal", "yes");
SetPropertyString("input-terminal", "yes");
@@ -1061,7 +1061,7 @@ namespace mpvnet
}
catch (Exception e)
{
if (!App.IsStartedFromTerminal)
if (!App.IsTerminalAttached)
Msg.ShowException(e);
}
}
@@ -1290,7 +1290,7 @@ namespace mpvnet
gx.DrawImage(bmp2, rect);
BitmapData bd = bmp.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppPArgb);
int x = Convert.ToInt32((cr.Width - len) / (december ? 1.95 : 2));
int y = Convert.ToInt32(((cr.Height - len) / 2.0) * (december ? 0.85 : 0.9));
int y = Convert.ToInt32((cr.Height - len) / 2.0 * (december ? 0.85 : 0.9));
CommandV("overlay-add", "0", $"{x}", $"{y}", "&" + bd.Scan0.ToInt64().ToString(), "0", "bgra", bd.Width.ToString(), bd.Height.ToString(), bd.Stride.ToString());
bmp.UnlockBits(bd);
IsLogoVisible = true;

View File

@@ -18,7 +18,7 @@ namespace mpvnet
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (App.IsStartedFromTerminal)
if (App.IsTerminalAttached)
Native.AttachConsole(-1 /*ATTACH_PARENT_PROCESS*/);
string[] args = Environment.GetCommandLineArgs().Skip(1).ToArray();
@@ -75,7 +75,7 @@ namespace mpvnet
Native.SendMessage(proc.MainWindowHandle, 0x004A /*WM_COPYDATA*/, IntPtr.Zero, ref data);
mutex.Dispose();
if (App.IsStartedFromTerminal)
if (App.IsTerminalAttached)
Native.FreeConsole();
return;
@@ -91,7 +91,7 @@ namespace mpvnet
Application.Run(new MainForm());
if (App.IsStartedFromTerminal)
if (App.IsTerminalAttached)
Native.FreeConsole();
mutex.Dispose();

View File

@@ -1,18 +1,15 @@
# This file defines the key and mouse bindings and the context menu of mpv.net.
# This file defines the key and mouse bindings and also the context menu of mpv.net.
# A input and config editor can be found in the context menu under 'Settings'.
# The mpv.conf defaults of mpv.net contain: 'input-default-bindings = no'
# which disables the input defaults of mpv.
# Every line in this file begins with a space character to make search easier,
# if you want to know if 'o' has already a binding you can search for ' o '.
# The input test mode can be started via command line: --input-test
# input test mode:
# mpvnet --input-test
# The input key list can be found in the context menu under: View > Show Keys
# The input key list can be printed with --input-keylist or
# shown from the context menu under: View > Show Keys
# mpv.net input.conf defaults:
# https://github.com/stax76/mpv.net/blob/master/src/Resources/input.conf.txt
@@ -156,7 +153,7 @@
F8 script-message mpv.net show-playlist #menu: View > Show Playlist
Ctrl+p script-message mpv.net show-profiles #menu: View > Show Profiles
p show-progress #menu: View > Show Progress
Shift+p script-message mpv.net show-properties #menu: View > Show Properties
P script-message mpv.net show-properties #menu: View > Show Properties
_ script-message mpv.net show-protocols #menu: View > Show Protocols
F9 show-text ${track-list} 5000 #menu: View > Show Tracks
Ctrl+m script-message mpv.net show-media-info #menu: View > Show Media Info
@@ -165,7 +162,6 @@
Ctrl+i script-message mpv.net show-input-editor #menu: Settings > Show Input Editor
Ctrl+f script-message mpv.net open-conf-folder #menu: Settings > Open Config Folder
F1 script-message mpv.net show-command-palette #menu: Tools > Show All Commands
h script-message mpv.net show-history #menu: Tools > Show History
l ab-loop #menu: Tools > Set/clear A-B loop points
L cycle-values loop-file inf no #menu: Tools > Toggle infinite file looping
@@ -182,6 +178,8 @@
_ script-message mpv.net update-check #menu: Help > Check for Updates
_ script-message mpv.net show-about #menu: Help > About mpv.net
F1 script-message mpv.net show-command-palette #menu: Command Palette
_ ignore #menu: -
Esc quit #menu: Exit
Q quit-watch-later #menu: Exit Watch Later
@@ -208,4 +206,3 @@
Ctrl+Wheel_Down no-osd seek -7
MBTN_Left_DBL cycle fullscreen
KP_Enter cycle fullscreen

View File

@@ -1065,11 +1065,11 @@ namespace mpvnet
if (CommandPaletteHost != null)
{
ActiveControl = null;
CommandPalette.Instance.SearchControl.SearchTextBox.Text = "";
Controls.Remove(CommandPaletteHost);
CommandPaletteHost.Child = null;
CommandPaletteHost.Dispose();
CommandPaletteHost = null;
CommandPalette.Instance.SearchControl.SearchTextBox.Text = "";
}
}