Support for encoding mode and thumbfast and some other new features and improvements

This commit is contained in:
stax76
2023-12-10 16:56:51 +01:00
parent 60dfbee16d
commit b3877492dd
12 changed files with 254 additions and 131 deletions

View File

@@ -7,7 +7,7 @@
the .NET 6 platform. There are user scripts as replacement:
[command_palette](https://github.com/stax76/mpv-scripts#command_palette) or
[search_menu](https://github.com/stax76/mpv-scripts#search_menu).
Unfortunately the user scripts don't support IME mode which is a problem for asian users.
Unfortunately the user scripts don't support IME mode which is a problem for Asian users.
- The blue mpv.net logo was removed for better mpv compatibility.
- Fix message box exceding working area size.
- C# and PowerShell scripting was removed because of a compatibility problem
@@ -25,8 +25,14 @@
- Various improvements and fixes in the input bindings editor.
- Automated nightly portable builds (thx to dyphire).
- Various new or changed default bindings.
- Context menu and message boxes are available in the languages German,
it can be enabled with the new option `language`.
- Context menu and message boxes are available in the languages Chinese and German.
Interested joining our translation team?: https://app.transifex.com/stax76/teams/
- Support for encoding mode and thumbfast.
- For script authors the following info is available in user-data:
user-data/frontend/name=mpv.net
user-data/frontend/version=7.0.0.0
user-data/frontend/process-path=the process path
- MediaInfo 23.11
- libmpv zhongfly 2023-11-03.
# v6.0.3.2 Beta (2022-10-14)

View File

@@ -253,7 +253,7 @@ Shows the about dialog.
Shows available audio devices in a message box.
### show-commands
Shows available mpv input commands.
Shows available [mpv input commands](https://mpv.io/manual/master/#list-of-input-commands).
### show-conf-editor
Shows the conf editor.
@@ -286,6 +286,15 @@ Shows media info with raw property names.
### show-menu
Shows the context menu.
### show-playlist
Shows the playlist in a message box. For a playlist menu
the following user scripts exist:
- https://github.com/stax76/mpv-scripts#command_palette
- https://github.com/stax76/mpv-scripts#search_menu
- https://github.com/tomasklaen/uosc
- https://github.com/jonniek/mpv-playlistmanager
### show-profiles
Shows available profiles with a message box.
@@ -432,6 +441,9 @@ Enable this only when a developer asks for it. Default: no
User interface display language.
mpv.net must be restarted after a change.
Interested joining our translation team?:
https://app.transifex.com/stax76/teams/
#### --dark-mode=\<value\>
Enables a dark theme.

View File

@@ -1,12 +1,12 @@

using System.Text;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Windows.Forms;
using System.Windows.Interop;
using System.Windows;
using System.Globalization;
using MpvNet.ExtensionMethod;
using MpvNet.Help;
using MpvNet.Windows.WinForms;
using MpvNet.Windows.WPF.Views;
using MpvNet.Windows.WPF;
@@ -20,7 +20,6 @@ public class GuiCommand
public event Action<float>? ScaleWindow;
public event Action<string>? MoveWindow;
public event Action<double>? WindowScaleMpv;
public event Action<float>? WindowScaleNet;
public event Action? ShowMenu;
@@ -45,14 +44,13 @@ public class GuiCommand
["window-scale"] = args => WindowScaleNet?.Invoke(float.Parse(args[0], CultureInfo.InvariantCulture)),
["show-menu"] = args => ShowMenu?.Invoke(),
["show-bindings"] = args => ShowBindings(),
["show-playlist"] = args => ShowPlaylist(),
// deprecated
["show-info"] = args => ShowMediaInfo(new[] { "osd" }), // deprecated
["quick-bookmark"] = args => QuickBookmark(), // deprecated
["show-commands"] = args => ShowCommands(), // deprecated
["show-history"] = args => ShowHistory(), // deprecated
["show-playlist"] = args => ShowPlaylist(), // deprecated
["show-command-palette"] = args => ShowCommandPalette(), // deprecated
};
@@ -250,7 +248,7 @@ public class GuiCommand
text = text.TrimEx();
if (editor)
ShowTextWithEditor("media-info", text);
Command.ShowTextWithEditor("media-info", text);
else if (osd)
Command.ShowText(text.Replace("\r", ""), 5000, 16);
else
@@ -263,53 +261,62 @@ public class GuiCommand
public static string FormatTime(double value) => ((int)value).ToString("00");
public void ShowTextWithEditor(string name, string text)
public void ShowBindings() => Command.ShowTextWithEditor("Bindings", Player.UsedInputConfContent);
public void ShowPlaylist()
{
string file = Path.Combine(Path.GetTempPath(), name + ".txt");
App.TempFiles.Add(file);
File.WriteAllText(file, BR + text.Trim() + BR);
ProcessHelp.ShellExecute(file);
var count = Player.GetPropertyInt("playlist-count");
if (count < 1)
return;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < count; i++)
{
string name = Player.GetPropertyString($"playlist/{i}/title");
if (string.IsNullOrEmpty(name))
name = Player.GetPropertyString($"playlist/{i}/filename").FileName();
sb.AppendLine(name);
}
public void ShowBindings()
{
string info = "# mpv.net might modify the input.conf content before it is passed to mpv." + BR +
"# Below are the bindings as they were passed to mpv." + BR2;
string header = BR + "For a playlist menu the following user scripts exist:" + BR2 +
"https://github.com/stax76/mpv-scripts#command_palette" + BR +
"https://github.com/stax76/mpv-scripts#search_menu" + BR +
"https://github.com/tomasklaen/uosc" + BR +
"https://github.com/jonniek/mpv-playlistmanager" + BR2;
ShowTextWithEditor("Bindings", info + Player.UsedInputConfContent);
Msg.ShowInfo(header + sb.ToString().TrimEnd());
}
//public void ShowCommandPalette()
//{
// MainForm.Instance?.BeginInvoke(() => {
// CommandPalette.Instance.SetItems(CommandPalette.GetItems());
// MainForm.Instance.ShowCommandPalette();
// CommandPalette.Instance.SelectFirst();
// });
//}
// deprecated
public void QuickBookmark() =>
Msg.ShowInfo("This feature was moved to a user script,\nwhich can be found here:\n\n" +
"https://github.com/stax76/mpv-scripts/blob/main/misc.lua");
// deprecated
public void ShowCommands() =>
Msg.ShowInfo("This feature was moved to a user script,\nwhich can be found here:\n\n" +
"https://github.com/stax76/mpv-scripts#command_palette");
// deprecated
public void ShowHistory() =>
Msg.ShowInfo("This feature was moved to a user script,\nwhich can be found here:\n\n" +
"https://github.com/stax76/mpv-scripts/blob/main/history.lua");
// deprecated
public void ShowPlaylist() =>
Msg.ShowInfo("This feature was moved to a user script,\nwhich can be found here:\n\n" +
"https://github.com/stax76/mpv-scripts#command_palette");
// deprecated
public void ShowCommandPalette() =>
Msg.ShowInfo("This feature was moved to a user script,\nwhich can be found here:\n\n" +
"https://github.com/stax76/mpv-scripts#command_palette");
Msg.ShowInfo(
"This feature was removed but is still available in the form of user scripts:" + BR2 +
"https://github.com/stax76/mpv-scripts#command_palette" + BR +
"https://github.com/stax76/mpv-scripts#search_menu" + BR +
"https://github.com/tomasklaen/uosc");
}
//public void ShowCommandPalette()
//{
// MainForm.Instance?.BeginInvoke(() => {
// CommandPalette.Instance.SetItems(CommandPalette.GetItems());
// MainForm.Instance.ShowCommandPalette();
// CommandPalette.Instance.SelectFirst();
// });
//}

View File

@@ -1,5 +1,4 @@

using System.Globalization;
using System.Windows.Forms;
using System.Threading;
@@ -8,6 +7,7 @@ using MpvNet.Help;
using MpvNet.Windows.UI;
using MpvNet.Windows.Help;
using MpvNet.Windows.WPF;
using System.Diagnostics;
namespace MpvNet.Windows;
@@ -42,8 +42,12 @@ static class Program
Theme.Init();
Mutex mutex = new Mutex(true, StringHelp.GetMD5Hash(App.ConfPath), out bool isFirst);
if (Control.ModifierKeys.HasFlag(Keys.Shift))
if (Control.ModifierKeys.HasFlag(Keys.Shift) ||
App.CommandLine.Contains("--process-instance=multi") ||
App.CommandLine.Contains("--o="))
{
App.ProcessInstance = "multi";
}
if ((App.ProcessInstance == "single" || App.ProcessInstance == "queue") && !isFirst)
{
@@ -93,6 +97,16 @@ static class Program
return;
}
if (App.CommandLine.Contains("--o="))
{
App.AutoLoadFolder = false;
Player.Init(IntPtr.Zero);
Player.ProcessCommandLine(false);
Player.SetPropertyString("idle", "no");
Player.EventLoop();
Player.Destroy();
}
else
Application.Run(new WinForms.MainForm());
if (App.IsTerminalAttached)

View File

@@ -522,7 +522,8 @@ name = language
file = mpvnet
default = system
directory = UI
help = User interface display language.\nmpv.net must be restarted after a change.
help = User interface display language.\nmpv.net must be restarted after a change.\nInterested joining our translation team?:
url = https://app.transifex.com/stax76/teams/
option = system
option = english
option = chinese-china

View File

@@ -9,10 +9,8 @@ namespace MpvNet.Windows.WPF;
public class HyperlinkEx : Hyperlink
{
void HyperLinkEx_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
void HyperLinkEx_RequestNavigate(object sender, RequestNavigateEventArgs e) =>
ProcessHelp.ShellExecute(e.Uri.AbsoluteUri);
}
public void SetURL(string? url)
{

View File

@@ -3,8 +3,18 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="clr-namespace:HandyControl.Controls"
xmlns:o="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
xmlns:local="clr-namespace:MpvNet.Windows.WPF"
>
<Style TargetType="local:HyperlinkEx">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="CornflowerBlue" />
<Setter Property="TextBlock.TextDecorations" Value="Underline" />
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="Button">
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>

View File

@@ -1,16 +1,16 @@

using CommunityToolkit.Mvvm.Messaging;
using Microsoft.VisualBasic;
using MpvNet.ExtensionMethod;
using MpvNet.Help;
using MpvNet.MVVM;
using System.Runtime.CompilerServices;
namespace MpvNet;
public class AppClass
{
public List<string> TempFiles { get; } = new List<string>();
public List<string> TempFiles { get; } = new ();
public Dictionary<string, string> CommandLineArguments { get; } = new ();
public string ConfPath { get => Player.ConfigFolder + "mpvnet.conf"; }
public string ProcessInstance { get; set; } = "single";
@@ -19,6 +19,7 @@ public class AppClass
public string LightTheme { get; set; } = "light";
public string StartSize { get; set; } = "height-session";
public string Language { get; set; } = "system";
public string CommandLine { get; set; } = Environment.CommandLine;
public bool AutoLoadFolder { get; set; } = true;
public bool DebugMode { get; set; }

View File

@@ -1,6 +1,7 @@

using System.Globalization;
using System.Text;
using System.Text.Json;
using MpvNet.Help;
namespace MpvNet;
@@ -17,15 +18,16 @@ public class Command
["play-pause"] = PlayPause,
["shell-execute"] = args => ProcessHelp.ShellExecute(args[0]),
["show-text"] = args => ShowText(args[0], Convert.ToInt32(args[1]), Convert.ToInt32(args[2])),
["show-commands"] = args => ShowCommands(),
["cycle-audio"] = args => CycleAudio(),
["cycle-subtitles"] = args => CycleSubtitles(),
["playlist-first"] = args => PlaylistFirst(),
["playlist-last"] = args => PlaylistLast(),
// deprecated
["playlist-add"] = args => PlaylistAdd(Convert.ToInt32(args[0])), // deprecated
["show-progress"] = args => ShowProgress(), // deprecated
["cycle-audio"] = args => CycleAudio(), // deprecated
["cycle-subtitles"] = args => CycleSubtitles(), // deprecated
["playlist-first"] = args => PlaylistFirst(), // deprecated
["playlist-last"] = args => PlaylistLast(), // deprecated
["playlist-random"] = args => PlaylistRandom(), // deprecated
};
@@ -50,6 +52,37 @@ public class Command
}
}
public static void ShowCommands()
{
string json = Core.GetPropertyString("command-list");
var enumerator = JsonDocument.Parse(json).RootElement.EnumerateArray();
var commands = enumerator.OrderBy(it => it.GetProperty("name").GetString());
StringBuilder sb = new StringBuilder();
foreach (var cmd in commands)
{
sb.AppendLine();
sb.AppendLine(cmd.GetProperty("name").GetString());
foreach (var args in cmd.GetProperty("args").EnumerateArray())
{
string value = args.GetProperty("name").GetString() + " <" +
args.GetProperty("type").GetString()!.ToLower() + ">";
if (args.GetProperty("optional").GetBoolean())
value = "[" + value + "]";
sb.AppendLine(" " + value);
}
}
string header = BR +
"https://mpv.io/manual/master/#list-of-input-commands" + BR2 +
"https://github.com/stax76/mpv-scripts#command_palette" + BR;
ShowTextWithEditor("Input Commands", header + sb.ToString());
}
public static void ShowText(string text, int duration = 0, int fontSize = 0)
{
if (string.IsNullOrEmpty(text))
@@ -65,42 +98,14 @@ public class Command
"}${osd-ass-cc/1}" + text + "\" " + duration);
}
// deprecated
public static void PlaylistAdd(int value)
public static void ShowTextWithEditor(string name, string text)
{
int pos = Player.PlaylistPos;
int count = Player.GetPropertyInt("playlist-count");
if (count < 2)
return;
pos += value;
if (pos < 0)
pos = count - 1;
if (pos > count - 1)
pos = 0;
Player.SetPropertyInt("playlist-pos", pos);
string file = Path.Combine(Path.GetTempPath(), name + ".txt");
App.TempFiles.Add(file);
File.WriteAllText(file, BR + text.Trim() + BR);
ProcessHelp.ShellExecute(file);
}
// deprecated
public void ShowProgress()
{
TimeSpan position = TimeSpan.FromSeconds(Player.GetPropertyDouble("time-pos"));
TimeSpan duration = TimeSpan.FromSeconds(Player.GetPropertyDouble("duration"));
string text = FormatTime(position.TotalMinutes) + ":" +
FormatTime(position.Seconds) + " / " +
FormatTime(duration.TotalMinutes) + ":" +
FormatTime(duration.Seconds) + " " +
DateTime.Now.ToString("H:mm dddd d MMMM", CultureInfo.InvariantCulture);
Player.CommandV("show-text", text, "5000");
}
// deprecated
public static void CycleAudio()
{
Player.UpdateExternalTracks();
@@ -129,7 +134,6 @@ public class Command
}
}
// deprecated
public static void CycleSubtitles()
{
Player.UpdateExternalTracks();
@@ -162,13 +166,31 @@ public class Command
}
// deprecated
public static void PlaylistAdd(int value)
{
int pos = Player.PlaylistPos;
int count = Player.GetPropertyInt("playlist-count");
if (count < 2)
return;
pos += value;
if (pos < 0)
pos = count - 1;
if (pos > count - 1)
pos = 0;
Player.SetPropertyInt("playlist-pos", pos);
}
public static void PlaylistFirst()
{
if (Player.PlaylistPos != 0)
Player.SetPropertyInt("playlist-pos", 0);
}
// deprecated
public static void PlaylistLast()
{
int count = Player.GetPropertyInt("playlist-count");
@@ -183,4 +205,19 @@ public class Command
int count = Player.GetPropertyInt("playlist-count");
Player.SetPropertyInt("playlist-pos", new Random().Next(count));
}
// deprecated
public void ShowProgress()
{
TimeSpan position = TimeSpan.FromSeconds(Player.GetPropertyDouble("time-pos"));
TimeSpan duration = TimeSpan.FromSeconds(Player.GetPropertyDouble("duration"));
string text = FormatTime(position.TotalMinutes) + ":" +
FormatTime(position.Seconds) + " / " +
FormatTime(duration.TotalMinutes) + ":" +
FormatTime(duration.Seconds) + " " +
DateTime.Now.ToString("H:mm dddd d MMMM", CultureInfo.InvariantCulture);
Player.CommandV("show-text", text, "5000");
}
}

View File

@@ -6,16 +6,18 @@ namespace MpvNet;
public class InputConf
{
string? _content;
string? _path;
public InputConf(string path) { Path = path; }
public string Path { get; }
public string Content { get; set; } = "";
public string Content
{
get => _content ??= FileHelp.ReadTextFile(Path);
set => _content = value;
public string Path {
get => _path ?? "";
set {
_path = value;
Content = File.Exists(_path) ? FileHelp.ReadTextFile(_path) : "";
}
}
public bool HasMenu => Content.Contains("#menu:") || Content.Contains("#! ");

View File

@@ -20,10 +20,16 @@ public static class InputHelp
new (_("File"), _("Recent Files")),
new (_("File"), "-"),
new (_("File"), _("Exit"), "quit", "Esc"),
new (_("Playback"), _("Play/Pause"), "script-message-to mpvnet play-pause", "Space"),
new (_("Playback"), _("Stop"), "stop", "Ctrl+s"),
new (_("Navigate"), _("Previous File"), "playlist-prev", "F11"),
new (_("Navigate"), _("Next File"), "playlist-next", "F12"),
new (_("Navigate"), "-"),
new (_("Navigate"), _("First File"), "script-message-to mpvnet playlist-first", "Home"),
new (_("Navigate"), _("Last File"), "script-message-to mpvnet playlist-last", "End"),
new (_("Navigate"), "-"),
new (_("Navigate"), _("Next Chapter"), "add chapter 1", "PGUP"),
new (_("Navigate"), _("Previous Chapter"), "add chapter -1", "PGDWN"),
@@ -42,6 +48,7 @@ public static class InputHelp
new (_("Navigate"), "-"),
new (_("Navigate"), _("Title")),
new (_("Navigate"), _("Chapter")),
new (_("Pan & Scan"), _("Decrease Size"), "add video-zoom -0.1", "Ctrl+-"),
new (_("Pan & Scan"), _("Increase Size"), "add video-zoom 0.1", "Ctrl++"),
new (_("Pan & Scan"), "-"),
@@ -55,6 +62,7 @@ public static class InputHelp
new (_("Pan & Scan"), _("Increase Height"), "add panscan 0.1", "W"),
new (_("Pan & Scan"), "-"),
new (_("Pan & Scan"), _("Reset"), "set video-zoom 0; set video-pan-x 0; set video-pan-y 0", "Ctrl+BS"),
new (_("Video"), _("Decrease Contrast"), "add contrast -1", "Ctrl+1"),
new (_("Video"), _("Increase Contrast"), "add contrast 1", "Ctrl+2"),
new (_("Video"), "-"),
@@ -72,11 +80,13 @@ public static class InputHelp
new (_("Video"), _("Toggle Deinterlace"), "cycle deinterlace", "d"),
new (_("Video"), _("Change Aspect Ratio"), "cycle-values video-aspect-override 16:9 4:3 2.35:1 -1", "a"),
new (_("Video"), _("Rotate Video"), "cycle-values video-rotate 90 180 270 0", "Ctrl+r"),
new (_("Audio"), _("Next Track"), "cycle audio", "KP7"),
new (_("Audio"), _("Next Track"), "script-message-to mpvnet cycle-audio", "KP7"),
new (_("Audio"), "-"),
new (_("Audio"), _("Delay +0.1"), "add audio-delay 0.1", "Ctrl+d"),
new (_("Audio"), _("Delay -0.1"), "add audio-delay -0.1", "Ctrl+D"),
new (_("Subtitle"), _("Next Track"), "cycle sub", "KP8"),
new (_("Subtitle"), _("Next Track"), "script-message-to mpvnet cycle-subtitles", "KP8"),
new (_("Subtitle"), _("Toggle Visibility"), "cycle sub-visibility", "v"),
new (_("Subtitle"), "-"),
new (_("Subtitle"), _("Delay -0.1"), "add sub-delay -0.1", "z"),
@@ -89,11 +99,14 @@ public static class InputHelp
new (_("Subtitle"), _("Increase Font Size"), "add sub-scale 0.1", "G"),
new (_("Subtitle"), "-"),
new (_("Subtitle") + " > " + _("More"), _("Toggle overriding SSA/ASS styles with normal styles"), "cycle-values sub-ass-override force no", "u"),
new ("", _("Track")),
new (_("Volume"), _("Up"), "add volume 2", "+"),
new (_("Volume"), _("Down"), "add volume -2", "-"),
new (_("Volume"), "-"),
new (_("Volume"), _("Mute"), "cycle mute", "m"),
new (_("Speed"), _("-10%"), "multiply speed 1/1.1", "["),
new (_("Speed"), _("+10%"), "multiply speed 1.1", "]"),
new (_("Speed"), "-"),
@@ -101,6 +114,8 @@ public static class InputHelp
new (_("Speed"), _("Double"), "multiply speed 2.0", "}"),
new (_("Speed"), "-"),
new (_("Speed"), _("Reset"), "set speed 1", "BS"),
new (_("View"), _("Show Playlist"), "script-message-to mpvnet show-playlist", "F8"),
new (_("View"), _("Show Profiles"), "script-message-to mpvnet show-profiles", "Ctrl+P"),
new (_("View"), _("Toggle Statistics"), "script-binding stats/display-stats-toggle", "t"),
new (_("View"), _("Toggle OSC Visibility"), "script-binding osc/visibility", "Del"),
@@ -109,10 +124,11 @@ public static class InputHelp
new (_("View"), _("Show Progress"), "show-progress", "p"),
new (_("View") + " > " + _("More"), _("Show Console"), "script-binding console/enable", "`"),
new (_("View") + " > " + _("More"), _("Show Audio Devices"), "script-message-to mpvnet show-audio-devices"),
new (_("View") + " > " + _("More"), _("Show Commands"), "script-message-to mpvnet show-commands", "C"),
new (_("View") + " > " + _("More"), _("Show Commands"), "script-message-to mpvnet show-commands", "F2"),
new (_("View") + " > " + _("More"), _("Show Demuxers"), "script-message-to mpvnet show-demuxers"),
new (_("View") + " > " + _("More"), _("Show Decoders"), "script-message-to mpvnet show-decoders"),
new (_("View") + " > " + _("More"), _("Show Bindings"), "script-message-to mpvnet show-bindings"),
new (_("Window"), _("Fullscreen"), "cycle fullscreen", "Enter"),
new (_("Window") + " > " + _("Zoom"), _("Enlarge"), "script-message-to mpvnet scale-window 1.2", "Alt++"),
new (_("Window") + " > " + _("Zoom"), _("Shrink"), "script-message-to mpvnet scale-window 0.8", "Alt+-"),
@@ -128,7 +144,9 @@ public static class InputHelp
new (_("Window") + " > " + _("Move"), _("Center"), "script-message-to mpvnet move-window center", "Alt+BS"),
new (_("Window"), _("Toggle Border"), "cycle border", "b"),
new (_("Window"), _("Toggle On Top"), "cycle ontop", "Ctrl+t"),
new ("", _("Profile")),
new (_("Settings"), _("Show Config Editor"), "script-message-to mpvnet show-conf-editor", "Ctrl+,"),
new (_("Settings"), _("Show Input Editor"), "script-message-to mpvnet show-input-editor", "Ctrl+i"),
new (_("Settings"), _("Open Config Folder"), "script-message-to mpvnet open-conf-folder", "Ctrl+f"),
@@ -136,20 +154,24 @@ public static class InputHelp
new (_("Settings") + " > " + _("Setup"), _("Register audio file associations"), "script-message-to mpvnet reg-file-assoc audio"),
new (_("Settings") + " > " + _("Setup"), _("Register image file associations"), "script-message-to mpvnet reg-file-assoc image"),
new (_("Settings") + " > " + _("Setup"), _("Unregister file associations"), "script-message-to mpvnet reg-file-assoc unreg"),
new (_("Tools"), _("Set/clear A-B loop points"), "ab-loop", "l"),
new (_("Tools"), _("Toggle infinite file looping"), "cycle-values loop-file inf no", "L"),
new (_("Tools"), _("Shuffle Playlist"), "playlist-shuffle"),
new (_("Tools"), _("Toggle Hardware Decoding"), "cycle-values hwdec auto no", "Ctrl+h"),
new (_("Tools"), _("Exit Watch Later"), "quit-watch-later", "Q"),
new ("", _("Custom")),
new (_("Help"), _("Website mpv"), "script-message-to mpvnet shell-execute https://mpv.io", "Ctrl+Home"),
new (_("Help"), _("Website mpv.net"), "script-message-to mpvnet shell-execute https://github.com/mpvnet-player/mpv.net", "Home"),
new (_("Help"), _("Website mpv.net"), "script-message-to mpvnet shell-execute https://github.com/mpvnet-player/mpv.net"),
new (_("Help"), "-"),
new (_("Help"), _("Manual mpv"), "script-message-to mpvnet shell-execute https://mpv.io/manual/stable", "Ctrl+F1"),
new (_("Help"), _("Manual mpv.net"), "script-message-to mpvnet shell-execute https://github.com/mpvnet-player/mpv.net/blob/main/docs/manual.md", "Ctrl+F2"),
new (_("Help"), "-"),
new (_("Help"), _("awesome-mpv"), "script-message-to mpvnet shell-execute https://github.com/stax76/awesome-mpv", "Ctrl+a"),
new (_("Help"), _("About mpv.net"), "script-message-to mpvnet show-about"),
new ("", "", "quit", "q", _("Exit")),
new ("", "", "script-message-to mpvnet show-menu", "MBTN_Right", _("Show Menu")),
new ("", "", "quit", "Power", _("Exit")),
@@ -183,6 +205,8 @@ public static class InputHelp
new ("", "", "no-osd sub-seek 1", "Ctrl+Shift+Right", _("Seek to next subtitle")),
new ("", "", "no-osd seek 5", "Ctrl+Wheel_Up", _("Seek Forward")),
new ("", "", "no-osd seek -5", "Ctrl+Wheel_Down", _("Seek Backward")),
new ("", "", "quit 4", "Esc", _("Quit encoding")),
new ("", "", "quit 4", "q", _("Quit encoding")),
//new (_("Command Palette"), _("Commands"), "script-message-to mpvnet show-command-palette", "F1"),
};

View File

@@ -78,6 +78,7 @@ public class MainPlayer : MpvClient
mpv_request_log_messages(MainHandle, "no");
if (formHandle != IntPtr.Zero)
TaskHelp.Run(MainEventLoop);
if (MainHandle == IntPtr.Zero)
@@ -89,7 +90,9 @@ public class MainPlayer : MpvClient
SetPropertyString("input-terminal", "yes");
}
if (formHandle != IntPtr.Zero)
SetPropertyLong("wid", formHandle.ToInt64());
SetPropertyInt("osd-duration", 2000);
SetPropertyBool("input-default-bindings", true);
@@ -102,17 +105,36 @@ public class MainPlayer : MpvClient
SetPropertyString("force-window", "yes");
SetPropertyString("config-dir", ConfigFolder);
SetPropertyString("config", "yes");
SetPropertyString("input-conf", @"memory://" + (UsedInputConfContent = App.InputConf.GetContent()));
UsedInputConfContent = App.InputConf.GetContent();
if (!string.IsNullOrEmpty(UsedInputConfContent))
SetPropertyString("input-conf", @"memory://" + UsedInputConfContent);
ProcessCommandLine(true);
Environment.SetEnvironmentVariable("MPVNET_VERSION", AppInfo.Version.ToString());
if (App.CommandLineArguments.ContainsKey("config-dir"))
{
string configDir = App.CommandLineArguments["config-dir"];
string fullPath = System.IO.Path.GetFullPath(configDir);
App.InputConf.Path = fullPath.AddSep() + "input.conf";
string content = App.InputConf.GetContent();
if (!string.IsNullOrEmpty(content))
SetPropertyString("input-conf", @"memory://" + content);
}
Environment.SetEnvironmentVariable("MPVNET_VERSION", AppInfo.Version.ToString()); // deprecated
mpv_error err = mpv_initialize(MainHandle);
if (err < 0)
throw new Exception("mpv_initialize error" + BR2 + GetError(err) + BR);
SetPropertyString("user-data/frontend/name", "mpv.net");
SetPropertyString("user-data/frontend/version", AppInfo.Version.ToString());
SetPropertyString("user-data/frontend/process-path", Environment.ProcessPath!);
string idle = GetPropertyString("idle");
App.Exit = idle == "no" || idle == "once";
@@ -123,6 +145,7 @@ public class MainPlayer : MpvClient
mpv_request_log_messages(Handle, "info");
if (formHandle != IntPtr.Zero)
TaskHelp.Run(EventLoop);
// otherwise shutdown is raised before media files are loaded,
@@ -389,13 +412,6 @@ public class MainPlayer : MpvClient
bool shuffle = false;
var args = Environment.GetCommandLineArgs().Skip(1);
//string[] preInitProperties = { "input-terminal", "terminal", "input-file", "config",
// "config-dir", "input-conf", "load-scripts", "scripts", "player-operation-mode",
// "idle", "log-file", "msg-color", "dump-stats", "msg-level", "really-quiet" };
//string[] preInitProperties = Array.Empty<string>();
string[] postInitProperties = Array.Empty<string>();
foreach (string i in args)
{
string arg = i;
@@ -453,6 +469,9 @@ public class MainPlayer : MpvClient
string left = arg[2..arg.IndexOf("=")];
string right = arg[(left.Length + 3)..];
if (string.IsNullOrEmpty(left))
continue;
switch (left)
{
case "script": left = "scripts"; break;
@@ -464,21 +483,13 @@ public class MainPlayer : MpvClient
if (left == "shuffle" && right == "yes")
shuffle = true;
if (preInit && !postInitProperties.Contains(left))
{
App.CommandLineArguments[left] = right;
ProcessProperty(left, right);
if (!App.ProcessProperty(left, right))
SetPropertyString(left, right);
}
else if (!preInit && postInitProperties.Contains(left))
{
ProcessProperty(left, right);
if (!App.ProcessProperty(left, right))
SetPropertyString(left, right);
}
}
}
if (!preInit)