Skip to content

Commit

Permalink
v7.0.0.6 Beta
Browse files Browse the repository at this point in the history
  • Loading branch information
stax76 committed Jan 2, 2024
1 parent 4451eaf commit 3970d5c
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 71 deletions.
5 changes: 5 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -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)

- Fix mpv.net option `language` not working from command line.
Expand Down
15 changes: 15 additions & 0 deletions docs/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,21 @@ Shows available audio devices in a message box.
### show-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
Shows the conf editor.

Expand Down
113 changes: 62 additions & 51 deletions src/MpvNet.Windows/GuiCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Windows.Forms;
Expand All @@ -11,9 +12,8 @@
using MpvNet.Windows.WPF.Views;
using MpvNet.Windows.WPF;
using MpvNet.Windows.WPF.MsgBox;
using MpvNet.Help;
using System.Text.Json;
using MpvNet.Windows.Help;
using MpvNet.Help;

namespace MpvNet;

Expand Down Expand Up @@ -47,27 +47,35 @@ 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(),
["add-to-path"] = args => AddToPath(),
["edit-conf-file"] = EditCongFile,
["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
["show-info"] = args => ShowMediaInfo(new[] { "osd" }), // deprecated
["show-recent"] = args => ShowRemoved(), // deprecated
["show-playlist"] = args => ShowPlaylist(), // deprecated
["quick-bookmark"] = args => QuickBookmark(), // deprecated
["show-history"] = args => ShowHistory(), // 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;
new WindowInteropHelper(win).Owner = MainForm.Instance!.Handle;
win?.ShowDialog();
}

public void LoadSubtitle(IList<string> args)
void LoadSubtitle(IList<string> args)
{
using var dialog = new OpenFileDialog();
string path = Player.GetPropertyString("path");
Expand All @@ -82,7 +90,7 @@ public void LoadSubtitle(IList<string> args)
Player.CommandV("sub-add", filename);
}

public void OpenFiles(IList<string> args)
void OpenFiles(IList<string> args)
{
bool append = false;

Expand All @@ -96,31 +104,31 @@ public void OpenFiles(IList<string> args)
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();

if (dialog.ShowDialog() == DialogResult.OK)
Player.LoadDiskFolder(dialog.SelectedPath);
}

public void EditCongFile(IList<string> args)
void EditCongFile(IList<string> args)
{
string file = Player.ConfigFolder + args[0];

if (File.Exists(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");
App.TempFiles.Add(file);
File.WriteAllText(file, BR + text.Trim() + BR);
ProcessHelp.ShellExecute(WinApiHelp.GetAppPathForExtension("txt"), "\"" + file + "\"");
}

public static void ShowCommands()
void ShowCommands()
{
string json = Core.GetPropertyString("command-list");
var enumerator = JsonDocument.Parse(json).RootElement.EnumerateArray();
Expand Down Expand Up @@ -151,7 +159,22 @@ public static void ShowCommands()
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";

Expand Down Expand Up @@ -185,7 +208,7 @@ public void OpenFromClipboard(IList<string> args)
}
}

public void LoadAudio(IList<string> args)
void LoadAudio(IList<string> args)
{
using var dialog = new OpenFileDialog();
string path = Player.GetPropertyString("path");
Expand All @@ -200,7 +223,7 @@ public void LoadAudio(IList<string> args)
Player.CommandV("audio-add", i);
}

public void RegisterFileAssociations(IList<string> args)
void RegisterFileAssociations(IList<string> args)
{
string perceivedType = args[0];
string[] extensions = Array.Empty<string>();
Expand Down Expand Up @@ -238,7 +261,7 @@ public void RegisterFileAssociations(IList<string> args)
catch { }
}

public void ShowMediaInfo(IList<string> args)
void ShowMediaInfo(IList<string> args)
{
if (Player.PlaylistPos == -1)
return;
Expand Down Expand Up @@ -320,11 +343,11 @@ public void ShowMediaInfo(IList<string> args)
}
}

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)!;

Expand All @@ -341,55 +364,43 @@ public void AddToPath()
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);
}
// deprecated
void ShowTracks() =>
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");

string header = BR + "For a playlist menu the following user scripts exist:" + BR2 +
// 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" + BR2;
"https://github.com/jonniek/mpv-playlistmanager");

Msg.ShowInfo(header + sb.ToString().TrimEnd());
}
// 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
public void QuickBookmark() =>
Msg.ShowInfo("This feature was moved to a user script,\nwhich can be found here:\n\n" +
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
public void ShowHistory() =>
Msg.ShowInfo("This feature was moved to a user script,\nwhich can be found here:\n\n" +
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
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#search_menu" + BR +
"https://github.com/tomasklaen/uosc");
void ShowRemoved() => Msg.ShowInfo(_("This feature was removed."));
}



//public void ShowCommandPalette()
//{
// MainForm.Instance?.BeginInvoke(() => {
Expand Down
6 changes: 3 additions & 3 deletions src/MpvNet.Windows/MpvNet.Windows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>mpv-icon.ico</ApplicationIcon>
<Product>mpv.net</Product>
<FileVersion>7.0.0.5</FileVersion>
<AssemblyVersion>7.0.0.5</AssemblyVersion>
<InformationalVersion>7.0.0.5</InformationalVersion>
<FileVersion>7.0.0.6</FileVersion>
<AssemblyVersion>7.0.0.6</AssemblyVersion>
<InformationalVersion>7.0.0.6</InformationalVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
22 changes: 10 additions & 12 deletions src/MpvNet/Command.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

using System.Globalization;
using System.Text;
using System.Text.Json;
using MpvNet.Help;

namespace MpvNet;
Expand All @@ -26,13 +24,13 @@ public class Command

// 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
};

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");

Expand Down Expand Up @@ -66,7 +64,7 @@ public static void ShowText(string text, int duration = 0, int fontSize = 0)
"}${osd-ass-cc/1}" + text + "\" " + duration);
}

public static void CycleAudio()
void CycleAudio()
{
Player.UpdateExternalTracks();

Expand Down Expand Up @@ -94,7 +92,7 @@ public static void CycleAudio()
}
}

public static void CycleSubtitles()
void CycleSubtitles()
{
Player.UpdateExternalTracks();

Expand Down Expand Up @@ -126,7 +124,7 @@ public static void CycleSubtitles()
}

// deprecated
public static void PlaylistAdd(int value)
void PlaylistAdd(int value)
{
int pos = Player.PlaylistPos;
int count = Player.GetPropertyInt("playlist-count");
Expand All @@ -145,13 +143,13 @@ public static void PlaylistAdd(int value)
Player.SetPropertyInt("playlist-pos", pos);
}

public static void PlaylistFirst()
void PlaylistFirst()
{
if (Player.PlaylistPos != 0)
Player.SetPropertyInt("playlist-pos", 0);
}

public static void PlaylistLast()
void PlaylistLast()
{
int count = Player.GetPropertyInt("playlist-count");

Expand All @@ -160,14 +158,14 @@ public static void PlaylistLast()
}

// deprecated
public static void PlaylistRandom()
void PlaylistRandom()
{
int count = Player.GetPropertyInt("playlist-count");
Player.SetPropertyInt("playlist-pos", new Random().Next(count));
}

// deprecated
public void ShowProgress()
void ShowProgress()
{
TimeSpan position = TimeSpan.FromSeconds(Player.GetPropertyDouble("time-pos"));
TimeSpan duration = TimeSpan.FromSeconds(Player.GetPropertyDouble("duration"));
Expand Down
Loading

0 comments on commit 3970d5c

Please sign in to comment.