use mpv.net to cycle subtitles
This commit is contained in:
@@ -25,6 +25,7 @@ namespace mpvnet
|
||||
switch (id)
|
||||
{
|
||||
case "cycle-audio": CycleAudio(); break;
|
||||
case "cycle-subtitles": CycleSubtitles(); break;
|
||||
case "load-audio": LoadAudio(); break;
|
||||
case "load-sub": LoadSubtitle(); break;
|
||||
case "open-clipboard": OpenFromClipboard(); break;
|
||||
@@ -309,13 +310,44 @@ namespace mpvnet
|
||||
if (++aid > tracks.Length)
|
||||
aid = 1;
|
||||
|
||||
Core.CommandV("set", "aid", aid.ToString());
|
||||
Core.SetPropertyInt("aid", aid);
|
||||
}
|
||||
|
||||
Core.CommandV("show-text", aid + "/" + tracks.Length + ": " + tracks[aid - 1].Text.Substring(3), "5000");
|
||||
}
|
||||
}
|
||||
|
||||
public static void CycleSubtitles()
|
||||
{
|
||||
Core.UpdateExternalTracks();
|
||||
|
||||
lock (Core.MediaTracksLock)
|
||||
{
|
||||
MediaTrack[] tracks = Core.MediaTracks.Where(track => track.Type == "s").ToArray();
|
||||
|
||||
if (tracks.Length < 1)
|
||||
{
|
||||
Core.CommandV("show-text", "No subtitles");
|
||||
return;
|
||||
}
|
||||
|
||||
int sid = Core.GetPropertyInt("sid");
|
||||
|
||||
if (tracks.Length > 1)
|
||||
{
|
||||
if (++sid > tracks.Length)
|
||||
sid = 0;
|
||||
|
||||
Core.SetPropertyInt("sid", sid);
|
||||
}
|
||||
|
||||
if (sid == 0)
|
||||
Core.CommandV("show-text", "No subtitle");
|
||||
else
|
||||
Core.CommandV("show-text", sid + "/" + tracks.Length + ": " + tracks[sid - 1].Text.Substring(3), "5000");
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowCommands()
|
||||
{
|
||||
string jsonString = Core.GetPropertyString("command-list");
|
||||
|
||||
@@ -80,7 +80,7 @@ _ ignore #menu: Audio > -
|
||||
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
|
||||
KP8 script-message-to mpvnet cycle-subtitles #menu: Subtitle > Cycle/Next #menu: Subtitle > Cycle/Next
|
||||
v cycle sub-visibility #menu: Subtitle > Toggle Visibility
|
||||
_ ignore #menu: Subtitle > -
|
||||
z add sub-delay -0.1 #menu: Subtitle > Delay -0.1
|
||||
|
||||
Reference in New Issue
Block a user