Fix auto-play not working with user scripts
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
|
||||
- Fix auto-play not working with user scripts.
|
||||
- When input.conf is created on the very first start and a
|
||||
script-opts folder does not exist, a script-opts folder
|
||||
is created with defaults for osc and console.
|
||||
|
||||
@@ -515,12 +515,7 @@ namespace mpvnet
|
||||
CommandPaletteItem item = new CommandPaletteItem()
|
||||
{
|
||||
Text = file.FileName(),
|
||||
Action = () => {
|
||||
Core.SetPropertyInt("playlist-pos", index);
|
||||
|
||||
if (App.AutoPlay && Core.Paused)
|
||||
Core.SetPropertyBool("pause", false);
|
||||
}
|
||||
Action = () => Core.SetPropertyInt("playlist-pos", index)
|
||||
};
|
||||
|
||||
items.Add(item);
|
||||
|
||||
@@ -45,14 +45,15 @@ namespace mpvnet
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
Core.Shutdown += Core_Shutdown;
|
||||
Core.ShowMenu += Core_ShowMenu;
|
||||
Core.VideoSizeChanged += Core_VideoSizeChanged;
|
||||
Core.ScaleWindow += Core_ScaleWindow;
|
||||
Core.WindowScale += Core_WindowScale;
|
||||
Core.FileLoaded += Core_FileLoaded;
|
||||
Core.Seek += () => UpdateProgressBar();
|
||||
Core.Pause += Core_Pause;
|
||||
Core.PlaylistPosChanged += (value) => SetTitle();
|
||||
Core.ScaleWindow += Core_ScaleWindow;
|
||||
Core.Seek += () => UpdateProgressBar();
|
||||
Core.ShowMenu += Core_ShowMenu;
|
||||
Core.Shutdown += Core_Shutdown;
|
||||
Core.VideoSizeChanged += Core_VideoSizeChanged;
|
||||
Core.WindowScale += Core_WindowScale;
|
||||
|
||||
if (Core.GPUAPI != "vulkan")
|
||||
Init();
|
||||
@@ -126,7 +127,6 @@ namespace mpvnet
|
||||
Core.ObservePropertyBool("fullscreen", PropChangeFullscreen);
|
||||
Core.ObservePropertyBool("keepaspect-window", value => Core.KeepaspectWindow = value);
|
||||
Core.ObservePropertyBool("ontop", PropChangeOnTop);
|
||||
Core.ObservePropertyBool("pause", PropChangePause);
|
||||
|
||||
Core.ObservePropertyString("sid", PropChangeSid);
|
||||
Core.ObservePropertyString("aid", PropChangeAid);
|
||||
@@ -1016,13 +1016,11 @@ namespace mpvnet
|
||||
}));
|
||||
}
|
||||
|
||||
void PropChangePause(bool paused)
|
||||
void Core_Pause()
|
||||
{
|
||||
Core.Paused = paused;
|
||||
|
||||
if (Taskbar != null && Core.TaskbarProgress)
|
||||
{
|
||||
if (paused)
|
||||
if (Core.Paused)
|
||||
Taskbar.SetState(TaskbarStates.Paused);
|
||||
else
|
||||
Taskbar.SetState(TaskbarStates.Normal);
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace mpvnet
|
||||
|
||||
public event Action Initialized;
|
||||
public event Action InitializedAsync;
|
||||
public event Action Pause;
|
||||
public event Action ShowMenu;
|
||||
public event Action<float> ScaleWindow;
|
||||
public event Action<float> WindowScale;
|
||||
@@ -144,6 +145,10 @@ namespace mpvnet
|
||||
ProcessCommandLine(true);
|
||||
|
||||
mpv_error err = mpv_initialize(Handle);
|
||||
|
||||
if (err < 0)
|
||||
throw new Exception("mpv_initialize error" + BR2 + GetError(err) + BR);
|
||||
|
||||
string idle = GetPropertyString("idle");
|
||||
App.Exit = idle == "no" || idle == "once";
|
||||
|
||||
@@ -151,8 +156,10 @@ namespace mpvnet
|
||||
// this means Lua scripts that use idle might not work correctly
|
||||
SetPropertyString("idle", "yes");
|
||||
|
||||
if (err < 0)
|
||||
throw new Exception("mpv_initialize error" + BR2 + GetError(err) + BR);
|
||||
ObservePropertyBool("pause", value => {
|
||||
Paused = value;
|
||||
Pause();
|
||||
});
|
||||
|
||||
ObservePropertyInt("video-rotate", value => {
|
||||
VideoRotate = value;
|
||||
@@ -171,6 +178,13 @@ namespace mpvnet
|
||||
}
|
||||
});
|
||||
|
||||
ObservePropertyString("script-opts", value => {
|
||||
if (value.ContainsEx("osc-visibility=never"))
|
||||
HideLogo();
|
||||
else if (GetPropertyInt("playlist-pos") == -1)
|
||||
ShowLogo();
|
||||
});
|
||||
|
||||
Initialized?.Invoke();
|
||||
InvokeAsync(InitializedAsync);
|
||||
}
|
||||
@@ -463,7 +477,11 @@ namespace mpvnet
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_FILE_LOADED:
|
||||
{
|
||||
if (App.AutoPlay && Paused)
|
||||
SetPropertyBool("pause", false);
|
||||
|
||||
HideLogo();
|
||||
|
||||
Duration = TimeSpan.FromSeconds(GetPropertyDouble("duration"));
|
||||
|
||||
if (App.StartSize == "video")
|
||||
@@ -1148,12 +1166,7 @@ namespace mpvnet
|
||||
else
|
||||
{
|
||||
if (i == 0 && !append)
|
||||
{
|
||||
CommandV("loadfile", file);
|
||||
|
||||
if (App.AutoPlay && Paused)
|
||||
SetPropertyBool("pause", false);
|
||||
}
|
||||
else
|
||||
CommandV("loadfile", file, "append");
|
||||
}
|
||||
|
||||
@@ -542,7 +542,7 @@ name = auto-play
|
||||
file = mpvnet
|
||||
default = no
|
||||
filter = Playback
|
||||
help = Sets pause=no on file load and selecting from the playlist. (mpv.net specific option)
|
||||
help = Sets pause=no on file load. (mpv.net specific option)
|
||||
|
||||
option = yes
|
||||
option = no
|
||||
|
||||
@@ -18,8 +18,8 @@ Ctrl+s stop #menu: Stop
|
||||
_ ignore #menu: -
|
||||
Enter cycle fullscreen #menu: Toggle Fullscreen
|
||||
|
||||
F11 script-message mpv.net playlist-add -1; set pause no #menu: Navigate > Previous File
|
||||
F12 script-message mpv.net playlist-add 1; set pause no #menu: Navigate > Next File
|
||||
F11 script-message mpv.net playlist-add -1 #menu: Navigate > Previous File
|
||||
F12 script-message mpv.net playlist-add 1 #menu: Navigate > Next File
|
||||
_ ignore #menu: Navigate > -
|
||||
Home script-message mpv.net playlist-first #menu: Navigate > First File
|
||||
End script-message mpv.net playlist-last #menu: Navigate > Last File
|
||||
@@ -173,8 +173,8 @@ KP6 script-message mpv.net show-progress
|
||||
KP9 ab-loop
|
||||
7 script-message mpv.net cycle-audio
|
||||
Sharp script-message mpv.net cycle-audio
|
||||
Ctrl+F11 script-message mpv.net playlist-add -10; set pause no
|
||||
Ctrl+F12 script-message mpv.net playlist-add 10; set pause no
|
||||
Ctrl+F11 script-message mpv.net playlist-add -10
|
||||
Ctrl+F12 script-message mpv.net playlist-add 10
|
||||
8 cycle sub
|
||||
j cycle sub
|
||||
q quit
|
||||
|
||||
Reference in New Issue
Block a user