v7.0.0.6 Beta

This commit is contained in:
stax76
2024-01-02 09:09:16 +01:00
parent 4451eafe71
commit 3970d5c0c2
10 changed files with 145 additions and 80 deletions

View File

@@ -1,4 +1,9 @@
# v7.0.0.6 Beta (2023-01-02)
- Improved backward compatibility with input.conf files created by old versions.
# v7.0.0.5 Beta (2023-12-28) # v7.0.0.5 Beta (2023-12-28)
- Fix mpv.net option `language` not working from command line. - Fix mpv.net option `language` not working from command line.

View File

@@ -270,6 +270,21 @@ Shows available audio devices in a message box.
### show-commands ### show-commands
Shows available [mpv input commands](https://mpv.io/manual/master/#list-of-input-commands). Shows available [mpv input commands](https://mpv.io/manual/master/#list-of-input-commands).
### show-properties
Shows available [properties](https://mpv.io/manual/master/#properties).
### show-keys
Shows available [input keys](https://mpv.io/manual/master/#options-input-keylist).
### show-protocols
Shows available [protocols](https://mpv.io/manual/master/#options-list-protocols).
### show-decoders
Shows available decoders.
### show-demuxers
Shows available demuxers.
### show-conf-editor ### show-conf-editor
Shows the conf editor. Shows the conf editor.

View File

@@ -1,5 +1,6 @@
 
using System.Text; using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Globalization; using System.Globalization;
using System.Windows.Forms; using System.Windows.Forms;
@@ -11,9 +12,8 @@ using MpvNet.Windows.WinForms;
using MpvNet.Windows.WPF.Views; using MpvNet.Windows.WPF.Views;
using MpvNet.Windows.WPF; using MpvNet.Windows.WPF;
using MpvNet.Windows.WPF.MsgBox; using MpvNet.Windows.WPF.MsgBox;
using MpvNet.Help;
using System.Text.Json;
using MpvNet.Windows.Help; using MpvNet.Windows.Help;
using MpvNet.Help;
namespace MpvNet; namespace MpvNet;
@@ -47,27 +47,35 @@ public class GuiCommand
["window-scale"] = args => WindowScaleNet?.Invoke(float.Parse(args[0], CultureInfo.InvariantCulture)), ["window-scale"] = args => WindowScaleNet?.Invoke(float.Parse(args[0], CultureInfo.InvariantCulture)),
["show-menu"] = args => ShowMenu?.Invoke(), ["show-menu"] = args => ShowMenu?.Invoke(),
["show-bindings"] = args => ShowBindings(), ["show-bindings"] = args => ShowBindings(),
["show-playlist"] = args => ShowPlaylist(),
["add-to-path"] = args => AddToPath(), ["add-to-path"] = args => AddToPath(),
["edit-conf-file"] = EditCongFile, ["edit-conf-file"] = EditCongFile,
["show-commands"] = args => ShowCommands(), ["show-commands"] = args => ShowCommands(),
["show-properties"] = args => ShowProperties(),
["show-keys"] = args => ShowKeys(),
["show-protocols"] = args => ShowProtocols(),
["show-decoders"] = args => ShowDecoders(),
["show-demuxers"] = args => ShowDemuxers(),
["show-info"] = args => ShowMediaInfo(new[] { "osd" }),
// deprecated // deprecated
["show-info"] = args => ShowMediaInfo(new[] { "osd" }), // deprecated ["show-recent"] = args => ShowRemoved(), // deprecated
["show-playlist"] = args => ShowPlaylist(), // deprecated
["quick-bookmark"] = args => QuickBookmark(), // deprecated ["quick-bookmark"] = args => QuickBookmark(), // deprecated
["show-history"] = args => ShowHistory(), // deprecated ["show-history"] = args => ShowHistory(), // deprecated
["show-command-palette"] = args => ShowCommandPalette(), // deprecated ["show-command-palette"] = args => ShowCommandPalette(), // deprecated
["show-audio-tracks"] = args => ShowTracks(), // deprecated
["show-subtitle-tracks"] = args => ShowTracks(), // deprecated
}; };
public void ShowDialog(Type winType) void ShowDialog(Type winType)
{ {
Window? win = Activator.CreateInstance(winType) as Window; Window? win = Activator.CreateInstance(winType) as Window;
new WindowInteropHelper(win).Owner = MainForm.Instance!.Handle; new WindowInteropHelper(win).Owner = MainForm.Instance!.Handle;
win?.ShowDialog(); win?.ShowDialog();
} }
public void LoadSubtitle(IList<string> args) void LoadSubtitle(IList<string> args)
{ {
using var dialog = new OpenFileDialog(); using var dialog = new OpenFileDialog();
string path = Player.GetPropertyString("path"); string path = Player.GetPropertyString("path");
@@ -82,7 +90,7 @@ public class GuiCommand
Player.CommandV("sub-add", filename); Player.CommandV("sub-add", filename);
} }
public void OpenFiles(IList<string> args) void OpenFiles(IList<string> args)
{ {
bool append = false; bool append = false;
@@ -96,7 +104,7 @@ public class GuiCommand
Player.LoadFiles(dialog.FileNames, true, append); Player.LoadFiles(dialog.FileNames, true, append);
} }
public void Open_DVD_Or_BD_Folder(IList<string> args) void Open_DVD_Or_BD_Folder(IList<string> args)
{ {
var dialog = new FolderBrowserDialog(); var dialog = new FolderBrowserDialog();
@@ -104,7 +112,7 @@ public class GuiCommand
Player.LoadDiskFolder(dialog.SelectedPath); Player.LoadDiskFolder(dialog.SelectedPath);
} }
public void EditCongFile(IList<string> args) void EditCongFile(IList<string> args)
{ {
string file = Player.ConfigFolder + args[0]; string file = Player.ConfigFolder + args[0];
@@ -112,7 +120,7 @@ public class GuiCommand
ProcessHelp.ShellExecute(WinApiHelp.GetAppPathForExtension("txt"), "\"" + file + "\""); ProcessHelp.ShellExecute(WinApiHelp.GetAppPathForExtension("txt"), "\"" + file + "\"");
} }
public static void ShowTextWithEditor(string name, string text) void ShowTextWithEditor(string name, string text)
{ {
string file = Path.Combine(Path.GetTempPath(), name + ".txt"); string file = Path.Combine(Path.GetTempPath(), name + ".txt");
App.TempFiles.Add(file); App.TempFiles.Add(file);
@@ -120,7 +128,7 @@ public class GuiCommand
ProcessHelp.ShellExecute(WinApiHelp.GetAppPathForExtension("txt"), "\"" + file + "\""); ProcessHelp.ShellExecute(WinApiHelp.GetAppPathForExtension("txt"), "\"" + file + "\"");
} }
public static void ShowCommands() void ShowCommands()
{ {
string json = Core.GetPropertyString("command-list"); string json = Core.GetPropertyString("command-list");
var enumerator = JsonDocument.Parse(json).RootElement.EnumerateArray(); var enumerator = JsonDocument.Parse(json).RootElement.EnumerateArray();
@@ -151,7 +159,22 @@ public class GuiCommand
ShowTextWithEditor("Input Commands", header + sb.ToString()); ShowTextWithEditor("Input Commands", header + sb.ToString());
} }
public void OpenFromClipboard(IList<string> args) void ShowProperties() =>
ShowTextWithEditor("Properties", Core.GetPropertyString("property-list").Replace(",", BR));
void ShowKeys() =>
ShowTextWithEditor("Keys", Core.GetPropertyString("input-key-list").Replace(",", BR));
void ShowProtocols() =>
ShowTextWithEditor("Protocols", Core.GetPropertyString("protocol-list").Replace(",", BR));
void ShowDecoders() =>
ShowTextWithEditor("Decoders", Core.GetPropertyOsdString("decoder-list").Replace(",", BR));
void ShowDemuxers() =>
ShowTextWithEditor("Demuxers", Core.GetPropertyOsdString("demuxer-lavf-list").Replace(",", BR));
void OpenFromClipboard(IList<string> args)
{ {
bool append = args.Count == 1 && args[0] == "append"; bool append = args.Count == 1 && args[0] == "append";
@@ -185,7 +208,7 @@ public class GuiCommand
} }
} }
public void LoadAudio(IList<string> args) void LoadAudio(IList<string> args)
{ {
using var dialog = new OpenFileDialog(); using var dialog = new OpenFileDialog();
string path = Player.GetPropertyString("path"); string path = Player.GetPropertyString("path");
@@ -200,7 +223,7 @@ public class GuiCommand
Player.CommandV("audio-add", i); Player.CommandV("audio-add", i);
} }
public void RegisterFileAssociations(IList<string> args) void RegisterFileAssociations(IList<string> args)
{ {
string perceivedType = args[0]; string perceivedType = args[0];
string[] extensions = Array.Empty<string>(); string[] extensions = Array.Empty<string>();
@@ -238,7 +261,7 @@ public class GuiCommand
catch { } catch { }
} }
public void ShowMediaInfo(IList<string> args) void ShowMediaInfo(IList<string> args)
{ {
if (Player.PlaylistPos == -1) if (Player.PlaylistPos == -1)
return; return;
@@ -320,11 +343,11 @@ public class GuiCommand
} }
} }
public static string FormatTime(double value) => ((int)value).ToString("00"); string FormatTime(double value) => ((int)value).ToString("00");
public void ShowBindings() => ShowTextWithEditor("Bindings", Player.UsedInputConfContent); void ShowBindings() => ShowTextWithEditor("Bindings", Player.UsedInputConfContent);
public void AddToPath() void AddToPath()
{ {
string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User)!; string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User)!;
@@ -341,53 +364,41 @@ public class GuiCommand
Msg.ShowInfo(_("mpv.net was successfully added to Path.")); Msg.ShowInfo(_("mpv.net was successfully added to Path."));
} }
public void ShowPlaylist()
{
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);
}
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;
Msg.ShowInfo(header + sb.ToString().TrimEnd());
}
// deprecated // deprecated
public void QuickBookmark() => void ShowTracks() =>
Msg.ShowInfo("This feature was moved to a user script,\nwhich can be found here:\n\n" + Msg.ShowInfo(_("This feature was removed, but there are user scripts:") + BR2 +
"https://github.com/stax76/mpv-scripts/blob/main/misc.lua");
// 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 ShowCommandPalette() =>
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#command_palette" + BR +
"https://github.com/stax76/mpv-scripts#search_menu" + BR + "https://github.com/stax76/mpv-scripts#search_menu" + BR +
"https://github.com/tomasklaen/uosc"); "https://github.com/tomasklaen/uosc");
}
// deprecated
void ShowPlaylist() =>
Msg.ShowInfo(_("This feature was removed, but there are 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" + BR +
"https://github.com/jonniek/mpv-playlistmanager");
// deprecated
void ShowCommandPalette() =>
Msg.ShowInfo(_("This feature was removed, but there are 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");
// deprecated
void QuickBookmark() =>
Msg.ShowInfo(_("This feature was removed, but there are user scripts:") + BR2 +
"https://github.com/stax76/mpv-scripts/blob/main/misc.lua");
// deprecated
void ShowHistory() =>
Msg.ShowInfo(_("This feature was removed, but there are user scripts:") + BR2 +
"https://github.com/stax76/mpv-scripts/blob/main/history.lua");
// deprecated
void ShowRemoved() => Msg.ShowInfo(_("This feature was removed."));
}
//public void ShowCommandPalette() //public void ShowCommandPalette()

View File

@@ -11,9 +11,9 @@
<UseWindowsForms>true</UseWindowsForms> <UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>mpv-icon.ico</ApplicationIcon> <ApplicationIcon>mpv-icon.ico</ApplicationIcon>
<Product>mpv.net</Product> <Product>mpv.net</Product>
<FileVersion>7.0.0.5</FileVersion> <FileVersion>7.0.0.6</FileVersion>
<AssemblyVersion>7.0.0.5</AssemblyVersion> <AssemblyVersion>7.0.0.6</AssemblyVersion>
<InformationalVersion>7.0.0.5</InformationalVersion> <InformationalVersion>7.0.0.6</InformationalVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>

View File

@@ -1,7 +1,5 @@
 
using System.Globalization; using System.Globalization;
using System.Text;
using System.Text.Json;
using MpvNet.Help; using MpvNet.Help;
namespace MpvNet; namespace MpvNet;
@@ -26,13 +24,13 @@ public class Command
// deprecated // deprecated
["playlist-add"] = args => PlaylistAdd(Convert.ToInt32(args[0])), // deprecated ["playlist-add"] = args => PlaylistAdd(Convert.ToInt32(args[0])), // deprecated
["show-progress"] = args => ShowProgress(), // deprecated ["show-progress"] = args => Player.Command("show-progress"), // deprecated
["playlist-random"] = args => PlaylistRandom(), // deprecated ["playlist-random"] = args => PlaylistRandom(), // deprecated
}; };
public string FormatTime(double value) => ((int)value).ToString("00"); string FormatTime(double value) => ((int)value).ToString("00");
public static void PlayPause(IList<string> args) void PlayPause(IList<string> args)
{ {
int count = Player.GetPropertyInt("playlist-count"); int count = Player.GetPropertyInt("playlist-count");
@@ -66,7 +64,7 @@ public class Command
"}${osd-ass-cc/1}" + text + "\" " + duration); "}${osd-ass-cc/1}" + text + "\" " + duration);
} }
public static void CycleAudio() void CycleAudio()
{ {
Player.UpdateExternalTracks(); Player.UpdateExternalTracks();
@@ -94,7 +92,7 @@ public class Command
} }
} }
public static void CycleSubtitles() void CycleSubtitles()
{ {
Player.UpdateExternalTracks(); Player.UpdateExternalTracks();
@@ -126,7 +124,7 @@ public class Command
} }
// deprecated // deprecated
public static void PlaylistAdd(int value) void PlaylistAdd(int value)
{ {
int pos = Player.PlaylistPos; int pos = Player.PlaylistPos;
int count = Player.GetPropertyInt("playlist-count"); int count = Player.GetPropertyInt("playlist-count");
@@ -145,13 +143,13 @@ public class Command
Player.SetPropertyInt("playlist-pos", pos); Player.SetPropertyInt("playlist-pos", pos);
} }
public static void PlaylistFirst() void PlaylistFirst()
{ {
if (Player.PlaylistPos != 0) if (Player.PlaylistPos != 0)
Player.SetPropertyInt("playlist-pos", 0); Player.SetPropertyInt("playlist-pos", 0);
} }
public static void PlaylistLast() void PlaylistLast()
{ {
int count = Player.GetPropertyInt("playlist-count"); int count = Player.GetPropertyInt("playlist-count");
@@ -160,14 +158,14 @@ public class Command
} }
// deprecated // deprecated
public static void PlaylistRandom() void PlaylistRandom()
{ {
int count = Player.GetPropertyInt("playlist-count"); int count = Player.GetPropertyInt("playlist-count");
Player.SetPropertyInt("playlist-pos", new Random().Next(count)); Player.SetPropertyInt("playlist-pos", new Random().Next(count));
} }
// deprecated // deprecated
public void ShowProgress() void ShowProgress()
{ {
TimeSpan position = TimeSpan.FromSeconds(Player.GetPropertyDouble("time-pos")); TimeSpan position = TimeSpan.FromSeconds(Player.GetPropertyDouble("time-pos"));
TimeSpan duration = TimeSpan.FromSeconds(Player.GetPropertyDouble("duration")); TimeSpan duration = TimeSpan.FromSeconds(Player.GetPropertyDouble("duration"));

View File

@@ -1,5 +1,4 @@
 
using MpvNet.ExtensionMethod;
using MpvNet.Help; using MpvNet.Help;
namespace MpvNet; namespace MpvNet;
@@ -15,10 +14,13 @@ public class InputConf
public string Path { public string Path {
get => _path ?? ""; get => _path ?? "";
set { set {
if (_path != value)
{
_path = value; _path = value;
Content = File.Exists(_path) ? FileHelp.ReadTextFile(_path) : ""; Content = File.Exists(_path) ? FileHelp.ReadTextFile(_path) : "";
} }
} }
}
public bool HasMenu => Content.Contains(App.MenuSyntax + " "); public bool HasMenu => Content.Contains(App.MenuSyntax + " ");
@@ -50,7 +52,29 @@ public class InputConf
public string GetContent() public string GetContent()
{ {
if (HasMenu) if (HasMenu)
{
try
{
if (App.Settings.MenuUpdateVersion != 1)
{
string updatedContent = UpdateContent(Content);
if (updatedContent != Content)
{
File.Copy(Path, Path + ".backup", true);
File.WriteAllText(Path, Content = updatedContent);
}
App.Settings.MenuUpdateVersion = 1;
}
}
catch (Exception ex)
{
Terminal.WriteError("Failed to update menu." + BR + ex.Message);
}
return Content; return Content;
}
else else
{ {
var defaults = InputHelp.GetDefaults(); var defaults = InputHelp.GetDefaults();
@@ -73,4 +97,9 @@ public class InputConf
return InputHelp.ConvertToString(defaults); return InputHelp.ConvertToString(defaults);
} }
} }
static string UpdateContent(string content) => content
.Replace("script-message mpv.net", "script-message-to mpvnet")
.Replace("/docs/Manual.md", "/docs/manual.md")
.Replace("https://github.com/stax76/mpv.net", "https://github.com/mpvnet-player/mpv.net");
} }

View File

@@ -127,6 +127,11 @@ public static class InputHelp
new (_("View") + " > " + _("More"), _("Show Audio Devices"), "script-message-to mpvnet show-audio-devices"), new (_("View") + " > " + _("More"), _("Show Audio Devices"), "script-message-to mpvnet show-audio-devices"),
new (_("View") + " > " + _("More"), _("Show Commands"), "script-message-to mpvnet show-commands", "F2"), new (_("View") + " > " + _("More"), _("Show Commands"), "script-message-to mpvnet show-commands", "F2"),
new (_("View") + " > " + _("More"), _("Show Bindings"), "script-message-to mpvnet show-bindings"), new (_("View") + " > " + _("More"), _("Show Bindings"), "script-message-to mpvnet show-bindings"),
new (_("View") + " > " + _("More"), _("Show Properties"), "script-message-to mpvnet show-properties", "F3"),
new (_("View") + " > " + _("More"), _("Show Keys"), "script-message-to mpvnet show-keys", "Alt+k"),
new (_("View") + " > " + _("More"), _("Show Protocols"), "script-message-to mpvnet show-protocols", "Alt+p"),
new (_("View") + " > " + _("More"), _("Show Decoders"), "script-message-to mpvnet show-decoders", "Alt+d"),
new (_("View") + " > " + _("More"), _("Show Demuxers"), "script-message-to mpvnet show-demuxers"),
new (_("Window"), _("Fullscreen"), "cycle fullscreen", "Enter"), new (_("Window"), _("Fullscreen"), "cycle fullscreen", "Enter"),
new (_("Window") + " > " + _("Zoom"), _("Enlarge"), "script-message-to mpvnet scale-window 1.2", "Alt++"), new (_("Window") + " > " + _("Zoom"), _("Enlarge"), "script-message-to mpvnet scale-window 1.2", "Alt++"),
@@ -483,7 +488,7 @@ public static class InputHelp
Binding binding = it.Value; Binding binding = it.Value;
if (!keys.Contains(binding.Input) && (charCount + binding.Input.Length) < 20 && keys.Count < 2) if (!keys.Contains(binding.Input) && (charCount + binding.Input.Length) < 15 && keys.Count < 2)
{ {
keys.Add(binding.Input); keys.Add(binding.Input);
charCount += binding.Input.Length; charCount += binding.Input.Length;

View File

@@ -98,6 +98,7 @@ public class MainPlayer : MpvClient
SetPropertyBool("input-default-bindings", true); SetPropertyBool("input-default-bindings", true);
SetPropertyBool("input-builtin-bindings", false); SetPropertyBool("input-builtin-bindings", false);
SetPropertyString("idle", "yes");
SetPropertyString("screenshot-directory", "~~desktop/"); SetPropertyString("screenshot-directory", "~~desktop/");
SetPropertyString("osd-playing-msg", "${media-title}"); SetPropertyString("osd-playing-msg", "${media-title}");
SetPropertyString("osc", "yes"); SetPropertyString("osc", "yes");

View File

@@ -11,6 +11,7 @@ public class AppSettings
{ {
public bool InputDefaultBindingsFixApplied; public bool InputDefaultBindingsFixApplied;
public bool ShowMenuFixApplied; public bool ShowMenuFixApplied;
public int MenuUpdateVersion;
public int Volume = 70; public int Volume = 70;
public List<string> RecentFiles = new List<string>(); public List<string> RecentFiles = new List<string>();
public Point WindowLocation; public Point WindowLocation;

View File

@@ -25,4 +25,4 @@ Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
[Files] [Files]
Source: "{#MyAppSourceDir}\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion Source: "{#MyAppSourceDir}\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MyAppSourceDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Source: "{#MyAppSourceDir}\*"; DestDir: "{app}"; Excludes: "win-x64"; Flags: ignoreversion recursesubdirs createallsubdirs;