Optimize track menu

Add encoding information to subtitles

Add title for external tracks, match and replace the filename to avoid too long characters
This commit is contained in:
dyphire
2022-06-02 11:33:18 +08:00
parent b2b387c017
commit 1a714a39df

View File

@@ -14,6 +14,7 @@ using System.Windows.Forms;
using static libmpv;
using static mpvnet.Global;
using System.Text.RegularExpressions;
namespace mpvnet
{
@@ -128,7 +129,7 @@ namespace mpvnet
SetPropertyString("input-terminal", "yes");
SetPropertyString("msg-level", "osd/libass=fatal");
}
SetPropertyInt("osd-duration", 2000);
SetPropertyLong("wid", handle.ToInt64());
@@ -1399,6 +1400,9 @@ namespace mpvnet
if (external)
{
string type = GetPropertyString($"track-list/{i}/type");
string filename = GetPropertyString($"filename/no-ext");
string title = GetPropertyString($"track-list/{i}/title").Replace(filename, "");
title = Regex.Replace(title, @"^[\._\-]", "").Replace("_", "__");
if (type == "audio")
{
@@ -1407,6 +1411,7 @@ namespace mpvnet
Add(track, GetPropertyString($"track-list/{i}/codec").ToUpperEx());
Add(track, GetPropertyInt($"track-list/{i}/audio-channels") + " channels");
Add(track, "External");
Add(track, $"{title}");
track.Text = "A: " + track.Text.Trim(' ', ',');
track.Type = "a";
track.ID = GetPropertyInt($"track-list/{i}/id");
@@ -1416,7 +1421,9 @@ namespace mpvnet
{
MediaTrack track = new MediaTrack();
Add(track, GetLanguage(GetPropertyString($"track-list/{i}/lang")));
Add(track, GetPropertyString($"track-list/{i}/codec").ToUpperEx());
Add(track, "External");
Add(track, $"{title}");
track.Text = "S: " + track.Text.Trim(' ', ',');
track.Type = "s";
track.ID = GetPropertyInt($"track-list/{i}/id");
@@ -1463,6 +1470,7 @@ namespace mpvnet
{
MediaTrack track = new MediaTrack();
Add(track, GetLanguage(GetPropertyString($"track-list/{i}/lang")));
Add(track, GetPropertyString($"track-list/{i}/codec").ToUpperEx());
track.Text = "S: " + track.Text.Trim(' ', ',');
track.Type = "s";
track.ID = GetPropertyInt($"track-list/{i}/id");