From 9d37e679017166bb727a8bd3f119a2745437847d Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Fri, 26 Jul 2019 18:32:42 +0200 Subject: [PATCH] terminal support added via mpvnet.com --- Changelog.md | 6 ++---- mpv.net/Misc/Misc.cs | 1 + mpv.net/Misc/Program.cs | 4 ++-- mpv.net/mpv/mp.cs | 7 +++++++ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Changelog.md b/Changelog.md index ee330eb..4792d2c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -17,10 +17,8 @@ to fail if it was waiting for a drive to wakeup - a new JavaScript was included to show the playlist with a smaller font size, the script is located at startup/scripts -- mpv.net attaches now to the parent terminal, when started from - a PowerShell terminal using the --terminal switch mpvnet gives - status messages on the console and debug messages useful to write - JavaScript and Lua scripts +- terminal support added via mpvnet.com, reading input keys from stdin + is not supported ### 4.7.7 diff --git a/mpv.net/Misc/Misc.cs b/mpv.net/Misc/Misc.cs index 9c77c82..73c3689 100644 --- a/mpv.net/Misc/Misc.cs +++ b/mpv.net/Misc/Misc.cs @@ -34,6 +34,7 @@ namespace mpvnet public static bool RememberHeight { get; set; } = true; public static bool RememberPosition { get; set; } public static bool DebugMode { get; set; } + public static bool IsTerminalHosted { get; } = Environment.GetEnvironmentVariable("_started_from_console") == "yes"; public static int StartThreshold { get; set; } = 1500; diff --git a/mpv.net/Misc/Program.cs b/mpv.net/Misc/Program.cs index fe831e6..c95d4e7 100644 --- a/mpv.net/Misc/Program.cs +++ b/mpv.net/Misc/Program.cs @@ -64,9 +64,9 @@ namespace mpvnet return; } - Native.AttachConsole(-1 /*ATTACH_PARENT_PROCESS*/); + if (App.IsTerminalHosted) Native.AttachConsole(-1 /*ATTACH_PARENT_PROCESS*/); Application.Run(new MainForm()); - Native.FreeConsole(); + if (App.IsTerminalHosted) Native.FreeConsole(); mutex.Dispose(); } catch (Exception ex) diff --git a/mpv.net/mpv/mp.cs b/mpv.net/mpv/mp.cs index b14c786..4408c11 100644 --- a/mpv.net/mpv/mp.cs +++ b/mpv.net/mpv/mp.cs @@ -89,6 +89,13 @@ namespace mpvnet { LoadLibrary("mpv-1.dll"); Handle = mpv_create(); + + if (App.IsTerminalHosted) + { + set_property_string("terminal", "yes"); + set_property_string("msg-level", "osd/libass=fatal"); + } + set_property_string("config-dir", ConfigFolder); set_property_string("osc", "yes"); set_property_string("config", "yes");