This commit is contained in:
Frank Skare
2019-03-30 15:29:25 +01:00
parent 7fa4418e1f
commit 49b184c99c
9 changed files with 46 additions and 22 deletions

View File

@@ -68,7 +68,7 @@ namespace mpvnet
Process.Start(Application.StartupPath + "\\mpvConfEdit.exe");
}
public static void history(string[] args)
public static void show_history(string[] args)
{
var fp = mp.mpvConfFolderPath + "history.txt";

View File

@@ -362,10 +362,7 @@ namespace mpvnet
{
var buttons = MessageBoxButtons.OK;
if (icon == MessageBoxIcon.Question) buttons = MessageBoxButtons.OKCancel;
var fn = new Func<DialogResult>(() => MessageBox.Show(
message, Application.ProductName, buttons, MessageBoxIcon.Information));
var fn = new Func<DialogResult>(() => MessageBox.Show(message, Application.ProductName, buttons, icon));
return (DialogResult)Invoke(fn);
}

View File

@@ -92,7 +92,7 @@
t script-binding stats/display-stats #menu: Tools > Show Statistics
T script-binding stats/display-stats-toggle #menu: Tools > Toggle Statistics
_ ignore #menu: Tools > -
h script-message mpv.net history #menu: Tools > Show History
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 Looping
Del script-binding osc/visibility #menu: Tools > Toggle OSC Visibility
@@ -109,7 +109,7 @@
Q quit-watch-later #menu: Exit Watch Later
> playlist-next
< playlist-prev
Enter cycle pause
Enter cycle pause
Power quit
Play cycle pause
Pause cycle pause
@@ -118,7 +118,7 @@
Forward seek 60
Rewind seek -60
Mute cycle mute
Volume_Up add volume 10
Volume_Up add volume 10
Volume_Down add volume -10
Wheel_Up add volume 10
Wheel_Down add volume -10

View File

@@ -195,21 +195,36 @@ namespace mpvnet
case mpv_event_id.MPV_EVENT_CLIENT_MESSAGE:
if (ClientMessage != null)
{
var client_messageData = (mpv_event_client_message)Marshal.PtrToStructure(evt.data, typeof(mpv_event_client_message));
var args = NativeUtf8StrArray2ManagedStrArray(client_messageData.args, client_messageData.num_args);
try
{
var client_messageData = (mpv_event_client_message)Marshal.PtrToStructure(evt.data, typeof(mpv_event_client_message));
string[] args = NativeUtf8StrArray2ManagedStrArray(client_messageData.args, client_messageData.num_args);
if (args != null && args.Length > 1 && args[0] == "mpv.net")
foreach (var i in mpvnet.Command.Commands)
if (args[1] == i.Name)
try
if (args != null && args.Length > 1 && args[0] == "mpv.net")
{
bool found = false;
foreach (var i in mpvnet.Command.Commands)
{
if (args[1] == i.Name)
{
i.Action(args.Skip(2).ToArray());
found = true;
i.Action.Invoke(args.Skip(2).ToArray());
}
catch (Exception ex)
{
MainForm.Instance.ShowMsgBox(ex.GetType().Name + "\n\n" + ex.ToString(), MessageBoxIcon.Error);
}
ClientMessage?.Invoke(args);
}
if (!found)
{
List<string> names = mpvnet.Command.Commands.Select((item) => item.Name).ToList();
names.Sort();
MainForm.Instance.ShowMsgBox($"No command '{args[1]}' found. Available commands are:\n\n{string.Join("\n", names)}\n\nHow to bind these commands can be seen in the default input bindings and menu definition located at:\n\nhttps://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt", MessageBoxIcon.Error);
}
}
ClientMessage?.Invoke(args);
}
catch (Exception ex)
{
MainForm.Instance.ShowMsgBox(ex.GetType().Name + "\n\n" + ex.ToString(), MessageBoxIcon.Error);
}
}
break;
case mpv_event_id.MPV_EVENT_VIDEO_RECONFIG: