script-message mpv.net playlist-first

This commit is contained in:
Frank Skare
2020-03-07 14:12:02 +01:00
parent fbb9cbdc33
commit 97ce08c4c7
4 changed files with 22 additions and 4 deletions

View File

@@ -2,6 +2,8 @@
### ###
- new: menu item 'View > Show Progress' (p key) to show progress bar - new: menu item 'View > Show Progress' (p key) to show progress bar
- new: `script-message mpv.net playlist-first`, unlike mpv does not
restart if the first file is already active
- fix: update routine did only work when mpv.net was located in 'Program Files' - fix: update routine did only work when mpv.net was located in 'Program Files'
- fix: errors were just ignored and only seen printed in the terminal in case mpv.net - fix: errors were just ignored and only seen printed in the terminal in case mpv.net

View File

@@ -36,6 +36,7 @@ namespace mpvnet
case "open-conf-folder": Process.Start(mp.ConfigFolder); break; case "open-conf-folder": Process.Start(mp.ConfigFolder); break;
case "shell-execute": Process.Start(args[0]); break; case "shell-execute": Process.Start(args[0]); break;
case "show-info": ShowInfo(); break; case "show-info": ShowInfo(); break;
case "playlist-first": PlaylistFirst(); break;
case "playlist-last": PlaylistLast(); break; case "playlist-last": PlaylistLast(); break;
case "add-files-to-playlist": OpenFiles("append"); break; // deprecated 2019 case "add-files-to-playlist": OpenFiles("append"); break; // deprecated 2019
default: Msg.ShowError($"No command '{id}' found."); break; default: Msg.ShowError($"No command '{id}' found."); break;
@@ -101,7 +102,22 @@ namespace mpvnet
})); }));
} }
public static void PlaylistLast() => mp.set_property_int("playlist-pos", mp.get_property_int("playlist-count") - 1); public static void PlaylistFirst()
{
int pos = mp.get_property_int("playlist-pos");
if (pos != 0)
mp.set_property_int("playlist-pos", 0);
}
public static void PlaylistLast()
{
int pos = mp.get_property_int("playlist-pos");
int count = mp.get_property_int("playlist-count");
if (pos < count - 1)
mp.set_property_int("playlist-pos", count - 1);
}
public static void ShowHistory() public static void ShowHistory()
{ {

View File

@@ -41,7 +41,7 @@
F11 playlist-prev #menu: Navigate > Previous File F11 playlist-prev #menu: Navigate > Previous File
F12 playlist-next #menu: Navigate > Next File F12 playlist-next #menu: Navigate > Next File
_ ignore #menu: Navigate > - _ ignore #menu: Navigate > -
Home set playlist-pos 0 #menu: Navigate > First File Home script-message mpv.net playlist-first #menu: Navigate > First File
End script-message mpv.net playlist-last #menu: Navigate > Last File End script-message mpv.net playlist-last #menu: Navigate > Last File
_ ignore #menu: Navigate > - _ ignore #menu: Navigate > -
PGUP add chapter 1 #menu: Navigate > Next Chapter PGUP add chapter 1 #menu: Navigate > Next Chapter

View File

@@ -97,7 +97,7 @@ namespace mpvnet
if (Handle == IntPtr.Zero) if (Handle == IntPtr.Zero)
throw new Exception("error mpv_create"); throw new Exception("error mpv_create");
mpv_request_log_messages(Handle, "error"); mpv_request_log_messages(Handle, "fatal");
Task.Run(() => EventLoop()); Task.Run(() => EventLoop());
if (App.IsStartedFromTerminal) if (App.IsStartedFromTerminal)