diff --git a/docs/Changelog.md b/docs/Changelog.md index 0cd2f8b..e6eb1c8 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -3,6 +3,12 @@ to the conf editor. - Command messages are dispatched with `script-message-to mpvnet`. - New feature to change profile using the command palette. +- New feature to show media info on screen, the command palette shows + an osd option and the show-info command shows more detailed info + after a second key press. +- New `media-info` option allowing to fully disable the usage of the + media info library, media info is disabled by default and considered + to be deprecated. - New show-santa-logo (green and grumpy) option. - New quick bookmark feature, see manual. - Progress command shows time and date. diff --git a/docs/Manual.md b/docs/Manual.md index b58fe25..4e227f2 100644 --- a/docs/Manual.md +++ b/docs/Manual.md @@ -315,7 +315,7 @@ Shows available demuxers. Shows the history file when existing. ### show-info -Shows a simple file info. +Shows media info on screen, a second key press shows more detailed media info. ### show-input-editor Shows the input editor. @@ -478,6 +478,10 @@ Force a single process and add files to playlist. Amount of recent files to be remembered. Default: 15 +#### --media-info=\ + +Usage of the media info library instead of mpv to access media information. Default: no (mpv.net specific option) + #### --video-file-extensions=\ Video file extensions used to create file associations and used by the auto-load-folder feature. diff --git a/src/Misc/App.cs b/src/Misc/App.cs index bb6cd4e..8636604 100644 --- a/src/Misc/App.cs +++ b/src/Misc/App.cs @@ -23,11 +23,10 @@ namespace mpvnet public static bool AutoLoadFolder { get; set; } = true; public static bool AutoPlay { get; set; } - public static bool DebuggerAttached { get; set; } = Debugger.IsAttached; public static bool DebugMode { get; set; } public static bool Exit { get; set; } public static bool IsTerminalAttached { get; } = Environment.GetEnvironmentVariable("_started_from_console") == "yes"; - public static bool MediaInfo { get; set; } = true; + public static bool MediaInfo { get; set; } public static bool Queue { get; set; } public static bool RememberVolume { get; set; } = true; public static bool RememberWindowPosition { get; set; } diff --git a/src/Misc/Commands.cs b/src/Misc/Commands.cs index 5501ec9..0c34f1e 100644 --- a/src/Misc/Commands.cs +++ b/src/Misc/Commands.cs @@ -157,8 +157,19 @@ namespace mpvnet } } + static int LastShowInfo; + public static void ShowInfo() { + if (Environment.TickCount - LastShowInfo < 5000) + { + Core.Command("script-message mpv.net show-media-info osd"); + LastShowInfo = 0; + return; + } + + LastShowInfo = Environment.TickCount; + string performer, title, album, genre, date, duration, text = ""; long fileSize = 0; string path = Core.GetPropertyString("path"); @@ -438,7 +449,7 @@ namespace mpvnet if (editor) ShowTextWithEditor("media-info", text); else if (osd) - Core.CommandV("show-text", text.Replace("\r", ""), "5000"); + ShowText(text.Replace("\r", ""), 5000, 15); else { MsgBoxEx.MessageBoxEx.MsgFontFamily = new FontFamily("Consolas"); diff --git a/src/Misc/MainForm.cs b/src/Misc/MainForm.cs index 2932d81..d513db5 100644 --- a/src/Misc/MainForm.cs +++ b/src/Misc/MainForm.cs @@ -722,6 +722,9 @@ namespace mpvnet string path = Core.GetPropertyString("path"); + if (path.Contains(":/") && !path.Contains("://")) + path = path.Replace("/", "\\"); + if (path.Contains("://")) { string title = Core.GetPropertyString("media-title"); diff --git a/src/Misc/Player.cs b/src/Misc/Player.cs index 954e043..7d43c8c 100644 --- a/src/Misc/Player.cs +++ b/src/Misc/Player.cs @@ -722,7 +722,7 @@ namespace mpvnet { mpv_error err = mpv_command_string(Handle, command); if (err < 0) - HandleError(err, "error executing command:", command); + HandleError(err, "error executing command: " + command); } public void CommandV(params string[] args) @@ -747,7 +747,7 @@ namespace mpvnet Marshal.FreeHGlobal(rootPtr); if (err < 0) - HandleError(err, "error executing command:", string.Join("\n", args)); + HandleError(err, "error executing command: " + string.Join("\n", args)); } public string Expand(string value) @@ -782,7 +782,7 @@ namespace mpvnet if (err < 0) { - HandleError(err, "error executing command:", string.Join("\n", args)); + HandleError(err, "error executing command: " + string.Join("\n", args)); Marshal.FreeHGlobal(resultNodePtr); return "property expansion error"; } @@ -799,7 +799,7 @@ namespace mpvnet mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_FLAG, out IntPtr lpBuffer); if (err < 0) - HandleError(err, $"error getting property: {name}"); + HandleError(err, "error getting property: " + name); return lpBuffer.ToInt32() != 0; } @@ -815,8 +815,8 @@ namespace mpvnet { mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, out IntPtr lpBuffer); - if (err < 0 && (App.DebugMode || App.DebuggerAttached)) - HandleError(err, $"error getting property: {name}"); + if (err < 0 && App.DebugMode) + HandleError(err, "error getting property: " + name); return lpBuffer.ToInt32(); } @@ -840,7 +840,7 @@ namespace mpvnet mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, out IntPtr lpBuffer); if (err < 0) - HandleError(err, $"error getting property: {name}"); + HandleError(err, "error getting property: " + name); return lpBuffer.ToInt64(); } @@ -848,8 +848,8 @@ namespace mpvnet { mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_DOUBLE, out double value); - if (err < 0 && handleError && (App.DebugMode || App.DebuggerAttached)) - HandleError(err, $"error getting property: {name}"); + if (err < 0 && handleError && App.DebugMode) + HandleError(err, "error getting property: " + name); return value; } @@ -873,8 +873,8 @@ namespace mpvnet return ret; } - if (err < 0 && (App.DebugMode || App.DebuggerAttached)) - HandleError(err, $"error getting property: {name}"); + if (err < 0 && App.DebugMode) + HandleError(err, "error getting property: " + name); return ""; } @@ -884,7 +884,7 @@ namespace mpvnet byte[] bytes = GetUtf8Bytes(value); mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_STRING, ref bytes); if (err < 0) - HandleError(err, $"error setting property: {name} = " + value); + HandleError(err, $"error setting property: {name} = {value}"); } public string GetPropertyOsdString(string name) @@ -900,7 +900,7 @@ namespace mpvnet } if (err < 0) - HandleError(err, $"error getting property: {name}"); + HandleError(err, "error getting property: " + name); return ""; } @@ -937,7 +937,7 @@ namespace mpvnet mpv_error err = mpv_observe_property(NamedHandle, 0, name, mpv_format.MPV_FORMAT_INT64); if (err < 0) - HandleError(err, $"error observing property: {name}"); + HandleError(err, "error observing property: " + name); else IntPropChangeActions[name] = new List>(); } @@ -956,7 +956,7 @@ namespace mpvnet mpv_error err = mpv_observe_property(NamedHandle, 0, name, mpv_format.MPV_FORMAT_DOUBLE); if (err < 0) - HandleError(err, $"error observing property: {name}"); + HandleError(err, "error observing property: " + name); else DoublePropChangeActions[name] = new List>(); } @@ -975,7 +975,7 @@ namespace mpvnet mpv_error err = mpv_observe_property(NamedHandle, 0, name, mpv_format.MPV_FORMAT_FLAG); if (err < 0) - HandleError(err, $"error observing property: {name}"); + HandleError(err, "error observing property: " + name); else BoolPropChangeActions[name] = new List>(); } @@ -994,7 +994,7 @@ namespace mpvnet mpv_error err = mpv_observe_property(NamedHandle, 0, name, mpv_format.MPV_FORMAT_STRING); if (err < 0) - HandleError(err, $"error observing property: {name}"); + HandleError(err, "error observing property: " + name); else StringPropChangeActions[name] = new List>(); } @@ -1013,7 +1013,7 @@ namespace mpvnet mpv_error err = mpv_observe_property(NamedHandle, 0, name, mpv_format.MPV_FORMAT_NONE); if (err < 0) - HandleError(err, $"error observing property: {name}"); + HandleError(err, "error observing property: " + name); else PropChangeActions[name] = new List(); } @@ -1023,11 +1023,9 @@ namespace mpvnet } } - public void HandleError(mpv_error err, params string[] messages) + public void HandleError(mpv_error err, string msg) { - foreach (string msg in messages) - Terminal.WriteError(msg); - + Terminal.WriteError(msg); Terminal.WriteError(GetError(err)); } diff --git a/src/Resources/editor_conf.txt b/src/Resources/editor_conf.txt index 0ae54bf..a3778f7 100644 --- a/src/Resources/editor_conf.txt +++ b/src/Resources/editor_conf.txt @@ -1,4 +1,62 @@ +[setting] +name = process-instance +file = mpvnet +default = single +filter = General +help = Defines if more then one mpv.net process is allowed. (mpv.net specific option)\n\nTip: Whenever the control key is pressed when files or URLs are opened, the playlist is not cleared but the files or URLs are appended to the playlist. This not only works on process startup but in all mpv.net features that open files and URLs. + +option = multi Create a new process everytime the shell starts mpv.net +option = single Force a single process everytime the shell starts mpv.net +option = queue Force a single process and add files to playlist + +[setting] +name = recent-count +file = mpvnet +filter = General +help = Amount of recent files to be remembered. Default: 15 (mpv.net specific option) + +[setting] +name = media-info +file = mpvnet +default = no +filter = General +help = Usage of the media info library instead of mpv to access media information. Default: no (mpv.net specific option) + +option = yes +option = no + +[setting] +name = video-file-extensions +file = mpvnet +filter = General +width = 500 +help = Video file extensions used to create file associations and used by the auto-load-folder feature. (mpv.net specific option) + +[setting] +name = audio-file-extensions +file = mpvnet +filter = General +width = 500 +help = Audio file extensions used to create file associations and used by the auto-load-folder feature. (mpv.net specific option) + +[setting] +name = image-file-extensions +file = mpvnet +filter = General +width = 500 +help = Image file extensions used to create file associations and used by the auto-load-folder feature. (mpv.net specific option) + +[setting] +name = debug-mode +file = mpvnet +default = no +filter = General +help = Enable this only when a developer asks for it. (mpv.net specific option) + +option = yes +option = no + [setting] name = vo file = mpv @@ -546,54 +604,6 @@ file = mpv filter = Input help = Number of key presses to generate per second on autorepeat. -[setting] -name = process-instance -file = mpvnet -default = single -filter = General -help = Defines if more then one mpv.net process is allowed. (mpv.net specific option)\n\nTip: Whenever the control key is pressed when files or URLs are opened, the playlist is not cleared but the files or URLs are appended to the playlist. This not only works on process startup but in all mpv.net features that open files and URLs. - -option = multi Create a new process everytime the shell starts mpv.net -option = single Force a single process everytime the shell starts mpv.net -option = queue Force a single process and add files to playlist - -[setting] -name = recent-count -file = mpvnet -filter = General -help = Amount of recent files to be remembered. Default: 15 (mpv.net specific option) - -[setting] -name = video-file-extensions -file = mpvnet -filter = General -width = 500 -help = Video file extensions used to create file associations and used by the auto-load-folder feature. (mpv.net specific option) - -[setting] -name = audio-file-extensions -file = mpvnet -filter = General -width = 500 -help = Audio file extensions used to create file associations and used by the auto-load-folder feature. (mpv.net specific option) - -[setting] -name = image-file-extensions -file = mpvnet -filter = General -width = 500 -help = Image file extensions used to create file associations and used by the auto-load-folder feature. (mpv.net specific option) - -[setting] -name = debug-mode -file = mpvnet -default = no -filter = General -help = Enable this only when a developer asks for it. (mpv.net specific option) - -option = yes -option = no - [setting] name = dark-mode file = mpvnet diff --git a/src/Resources/input.conf.txt b/src/Resources/input.conf.txt index 77622c5..b3d694b 100644 --- a/src/Resources/input.conf.txt +++ b/src/Resources/input.conf.txt @@ -124,7 +124,7 @@ t script-binding stats/display-stats-toggle #menu: View > Toggle Stati Del script-binding osc/visibility #menu: View > Toggle OSC Visibility i script-message-to mpvnet show-info #menu: View > Show File/Stream Info p show-progress #menu: View > Show Progress -F9 show-text ${track-list} 5000 #menu: View > Show Tracks +F9 script-message mpv.net show-media-info osd #menu: View > Show Tracks Ctrl+m script-message-to mpvnet show-media-info #menu: View > Show Media Info Alt+r script-message-to mpvnet show-recent #menu: View > Show Recent