This commit is contained in:
stax76
2022-03-05 07:55:34 +01:00
parent 8d25803b71
commit a4ffab7b50
3 changed files with 93 additions and 55 deletions

View File

@@ -24,7 +24,6 @@ namespace mpvnet
{
switch (id)
{
case "add-files-to-playlist": OpenFiles("append"); break; // deprecated 2019
case "cycle-audio": CycleAudio(); break;
case "execute-mpv-command": Msg.ShowError("Command was removed, reset input.conf."); break; // deprecated 2020
@@ -55,6 +54,7 @@ namespace mpvnet
case "show-media-info": ShowMediaInfo(args); break;
case "show-playlist": ShowPlaylist(); break;
case "show-profiles": Msg.ShowInfo(mpvHelp.GetProfiles()); break;
case "show-progress": ShowProgress(); break;
case "show-properties": ShowProperties(); break;
case "show-protocols": ShowStrings(mpvHelp.GetProtocols().Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)); break;
case "show-recent": ShowRecent(); break;
@@ -185,11 +185,12 @@ namespace mpvnet
duration = mediaInfo.GetInfo(MediaInfoStreamKind.Audio, "Duration/String");
if (performer != "") text += "Artist: " + performer + "\n";
if (title != "") text += "Title: " + title + "\n";
if (album != "") text += "Album: " + album + "\n";
if (genre != "") text += "Genre: " + genre + "\n";
if (date != "") text += "Year: " + date + "\n";
if (duration != "") text += "Length: " + duration + "\n";
if (title != "") text += "Title: " + title + "\n";
if (album != "") text += "Album: " + album + "\n";
if (genre != "") text += "Genre: " + genre + "\n";
if (date != "") text += "Year: " + date + "\n";
if (duration != "") text += "Length: " + duration + "\n";
text += "Size: " + mediaInfo.GetInfo(MediaInfoStreamKind.General, "FileSize/String") + "\n";
text += "Type: " + path.Ext().ToUpper();
@@ -213,17 +214,10 @@ namespace mpvnet
}
}
TimeSpan position = TimeSpan.FromSeconds(Core.GetPropertyDouble("time-pos"));
TimeSpan duration2 = TimeSpan.FromSeconds(Core.GetPropertyDouble("duration"));
string videoFormat = Core.GetPropertyString("video-format").ToUpper();
string audioCodec = Core.GetPropertyString("audio-codec-name").ToUpper();
text = path.FileName() + "\n" +
FormatTime(position.TotalMinutes) + ":" +
FormatTime(position.Seconds) + " / " +
FormatTime(duration2.TotalMinutes) + ":" +
FormatTime(duration2.Seconds) + "\n" +
$"{width} x {height}\n";
text = path.FileName() + $"\n{width} x {height}\n";
if (fileSize > 0)
text += Convert.ToInt32(fileSize / 1024.0 / 1024.0) + " MB\n";
@@ -231,14 +225,28 @@ namespace mpvnet
text += $"{videoFormat}\n{audioCodec}";
Core.CommandV("show-text", text, "5000");
string FormatTime(double value) => ((int)value).ToString("00");
}
catch (Exception e)
{
App.ShowException(e);
}
}
public static void ShowProgress()
{
TimeSpan position = TimeSpan.FromSeconds(Core.GetPropertyDouble("time-pos"));
TimeSpan duration = TimeSpan.FromSeconds(Core.GetPropertyDouble("duration"));
string text = FormatTime(position.TotalMinutes) + ":" +
FormatTime(position.Seconds) + " / " +
FormatTime(duration.TotalMinutes) + ":" +
FormatTime(duration.Seconds);
Core.CommandV("show-text", text, "5000");
string FormatTime(double value) => ((int)value).ToString("00");
}
public static void OpenURL()
{
App.InvokeOnMainThread(new Action(() => {

View File

@@ -241,15 +241,7 @@ namespace mpvnet
_ConfigFolder = _ConfigFolder.AddSep();
if (!File.Exists(_ConfigFolder + "input.conf"))
{
string content = Properties.Resources.input_conf;
if (Environment.GetEnvironmentVariable("username") == "frank")
content = content.Replace("volume 2 ", "volume 10")
.Replace("volume -2 ", "volume -10");
File.WriteAllText(_ConfigFolder + "input.conf", content);
}
File.WriteAllText(_ConfigFolder + "input.conf", PatchInput(Properties.Resources.input_conf));
}
return _ConfigFolder;
@@ -279,6 +271,28 @@ namespace mpvnet
}
}
string PatchInput(string value)
{
if (Environment.GetEnvironmentVariable("username") == "frank" && Directory.Exists(@"D:\Projects\CS\mpv.net"))
value = value.Replace("volume 2 ", "volume 10")
.Replace("volume -2 ", "volume -10");
value += @"
KP2 script-message rate-file 2
2 script-message rate-file 2
KP3 script-message rate-file 3
3 script-message rate-file 3
KP4 script-message rate-file 4
4 script-message rate-file 4
KP5 script-message rate-file 5
5 script-message rate-file 5
KP0 script-binding delete_current_file/delete
0 script-binding delete_current_file/delete
KP1 script-binding delete_current_file/confirm
1 script-binding delete_current_file/confirm";
return value;
}
public void LoadScripts()
{
if (Directory.Exists(ConfigFolder + "scripts-ps"))

View File

@@ -17,7 +17,6 @@ Space script-message mpv.net play-pause #menu: Play/Pause
Ctrl+s stop #menu: Stop
_ ignore #menu: -
Enter cycle fullscreen #menu: Toggle Fullscreen
f cycle fullscreen
F11 playlist-prev; set pause no #menu: Navigate > Previous File
F12 playlist-next; set pause no #menu: Navigate > Next File
@@ -75,8 +74,8 @@ a cycle-values video-aspect 16:9 4:3 2.35:1 -1 #menu: Video > Cycle As
KP7 script-message mpv.net cycle-audio #menu: Audio > Cycle/Next
_ ignore #menu: Audio > -
KP6 add audio-delay 0.1 #menu: Audio > Delay +0.1
KP9 add audio-delay -0.1 #menu: Audio > Delay -0.1
Ctrl+d add audio-delay 0.1 #menu: Audio > Delay +0.1
Ctrl+D add audio-delay -0.1 #menu: Audio > Delay -0.1
KP8 cycle sub #menu: Subtitle > Cycle/Next
v cycle sub-visibility #menu: Subtitle > Toggle Visibility
@@ -153,6 +152,7 @@ l ab-loop #menu: Tools > Set/clear A-B
L cycle-values loop-file inf no #menu: Tools > Toggle infinite file looping
_ playlist-shuffle #menu: Tools > Shuffle Playlist
Ctrl+h cycle-values hwdec auto no #menu: Tools > Toggle Hardware Decoding
Q quit-watch-later #menu: Tools > Exit Watch Later
_ script-message mpv.net shell-execute https://mpv.io #menu: Help > Website mpv
_ script-message mpv.net shell-execute https://github.com/stax76/mpv.net #menu: Help > Website mpv.net
@@ -163,31 +163,47 @@ _ ignore #menu:
_ script-message mpv.net show-about #menu: Help > About mpv.net
F1 script-message mpv.net show-command-palette #menu: Command Palette
_ ignore #menu: -
Esc quit #menu: Exit
_ ignore #menu: -
Esc quit #menu: Exit
Q quit-watch-later #menu: Exit Watch Later
Power quit
Play cycle pause
Pause cycle pause
PlayPause cycle pause
MBTN_Mid cycle pause
Stop stop
Forward seek 60
Rewind seek -60
Wheel_Up add volume 2
Wheel_Down add volume -2
Wheel_Left add volume -2
Wheel_Right add volume 2
Prev playlist-prev
Next playlist-next
MBTN_Forward playlist-next
MBTN_Back playlist-prev
> playlist-next
< playlist-prev
Ctrl+Wheel_Up no-osd seek 7
Ctrl+Wheel_Down no-osd seek -7
MBTN_Left ignore
MBTN_Left_DBL cycle fullscreen
KP_Enter cycle fullscreen
6 script-message mpv.net show-progress
KP6 script-message mpv.net show-progress
7 script-message mpv.net cycle-audio
SHARP script-message mpv.net cycle-audio
8 cycle sub
j cycle sub
q quit
Power quit
Play cycle pause
Pause cycle pause
PlayPause cycle pause
MBTN_Mid cycle pause
Stop stop
Forward seek 60
Rewind seek -60
Wheel_Up add volume 2
Wheel_Down add volume -2
Wheel_Left add volume -2
Wheel_Right add volume 2
Prev playlist-prev
Next playlist-next
MBTN_Forward playlist-next
MBTN_Back playlist-prev
> playlist-next
< playlist-prev
MBTN_Left ignore
f cycle fullscreen
MBTN_Left_DBL cycle fullscreen
KP_Enter cycle fullscreen
Shift+RIGHT no-osd seek 1 exact
Shift+LEFT no-osd seek -1 exact
Shift+UP no-osd seek 5 exact
Shift+DOWN no-osd seek -5 exact
Shift+BS revert-seek # undo the previous (or marked) seek
Shift+Ctrl+BS revert-seek mark # mark the position for revert-seek
Shift+g add sub-scale +0.1 # increase the subtitle font size
Shift+f add sub-scale -0.1 # decrease the subtitle font size
Ctrl+Shift+LEFT no-osd sub-seek -1 # seek to the previous subtitle
Ctrl+Shift+RIGHT no-osd sub-seek 1 # seek to the next subtitle
Ctrl+Wheel_Up no-osd seek 7
Ctrl+Wheel_Down no-osd seek -7