support mpv idle property partly

This commit is contained in:
stax76
2022-05-17 15:05:00 +02:00
parent b3ebf85772
commit 5d16d7b2d1
5 changed files with 29 additions and 17 deletions

View File

@@ -1,7 +1,10 @@
- When input.conf is created on the very first start and - When input.conf is created on the very first start and a
a script-opts folder does not exist, a script-opts folder is script-opts folder does not exist, a script-opts folder
created with defaults for osc and console. is created with defaults for osc and console.
- Support mpv idle property, see manual for remarks.
- libmpv shinchiro 2022-05-17 with idle fix
5.9.0.0 Beta (2022-05-08) 5.9.0.0 Beta (2022-05-08)

View File

@@ -446,10 +446,6 @@ Can be suppressed via shift key. Default: yes
If the player is paused and another file is loaded, If the player is paused and another file is loaded,
playback automatically resumes. playback automatically resumes.
#### --keep-open-exit
If set to yes and keep-open is set to no, mpv.net exits after the last file ends.
In mpv the idle property would be used, it's not possible for mpv.net to use the idle property.
### General ### General
@@ -790,7 +786,6 @@ https://mpv.io/manual/master/#window
- [autofit-smaller](https://mpv.io/manual/master/#options-autofit-smaller) - [autofit-smaller](https://mpv.io/manual/master/#options-autofit-smaller)
- [autofit](https://mpv.io/manual/master/#options-autofit) - [autofit](https://mpv.io/manual/master/#options-autofit)
mpv.net specific window features are documented in the [screen section](#screen). mpv.net specific window features are documented in the [screen section](#screen).
@@ -809,6 +804,13 @@ need an own implementation in mpv.net, so far implemented are:
--vd=help --vd=help
--version --version
### Other Limitations
The mpv property [idle](https://mpv.io/manual/master/#options-idle) can be
used and mpv.net functions accordingly, but Lua scripts see always `idle=yes`
because mpv.net has to set it to function correctly, this is a difficult
to overcome libmpv limitation.
### mpv.net specific options ### mpv.net specific options

View File

@@ -24,8 +24,8 @@ namespace mpvnet
public static bool AutoLoadFolder { get; set; } = true; public static bool AutoLoadFolder { get; set; } = true;
public static bool AutoPlay { get; set; } public static bool AutoPlay { get; set; }
public static bool DebugMode { get; set; } public static bool DebugMode { get; set; }
public static bool Exit { get; set; }
public static bool IsTerminalAttached { get; } = Environment.GetEnvironmentVariable("_started_from_console") == "yes"; public static bool IsTerminalAttached { get; } = Environment.GetEnvironmentVariable("_started_from_console") == "yes";
public static bool KeepOpenExit { get; set; }
public static bool Queue { get; set; } public static bool Queue { get; set; }
public static bool RememberVolume { get; set; } = true; public static bool RememberVolume { get; set; } = true;
public static bool RememberWindowPosition { get; set; } public static bool RememberWindowPosition { get; set; }
@@ -242,7 +242,6 @@ namespace mpvnet
case "dark-theme": DarkTheme = value.Trim('\'', '"'); return true; case "dark-theme": DarkTheme = value.Trim('\'', '"'); return true;
case "debug-mode": DebugMode = value == "yes"; return true; case "debug-mode": DebugMode = value == "yes"; return true;
case "image-file-extensions": CorePlayer.ImageTypes = value.Split(" ,;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); return true; case "image-file-extensions": CorePlayer.ImageTypes = value.Split(" ,;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); return true;
case "keep-open-exit": KeepOpenExit = value == "yes"; return true;
case "light-theme": LightTheme = value.Trim('\'', '"'); return true; case "light-theme": LightTheme = value.Trim('\'', '"'); return true;
case "minimum-aspect-ratio": MinimumAspectRatio = value.ToFloat(); return true; case "minimum-aspect-ratio": MinimumAspectRatio = value.ToFloat(); return true;
case "process-instance": ProcessInstance = value; return true; case "process-instance": ProcessInstance = value; return true;

View File

@@ -142,7 +142,14 @@ namespace mpvnet
SetPropertyString("config", "yes"); SetPropertyString("config", "yes");
ProcessCommandLine(true); ProcessCommandLine(true);
mpv_error err = mpv_initialize(Handle); mpv_error err = mpv_initialize(Handle);
string idle = GetPropertyString("idle");
App.Exit = idle == "no" || idle == "once";
// otherwise shutdown is raised before media files are loaded,
// this means Lua scripts that use idle might not work correctly
SetPropertyString("idle", "yes");
if (err < 0) if (err < 0)
throw new Exception("mpv_initialize error" + BR2 + GetError(err) + BR); throw new Exception("mpv_initialize error" + BR2 + GetError(err) + BR);
@@ -159,7 +166,7 @@ namespace mpvnet
{ {
ShowLogo(); ShowLogo();
if (GetPropertyString("keep-open") == "no" && App.KeepOpenExit) if (GetPropertyString("keep-open") == "no" && App.Exit)
Core.CommandV("quit"); Core.CommandV("quit");
} }
}); });
@@ -985,7 +992,8 @@ namespace mpvnet
var args = Environment.GetCommandLineArgs().Skip(1); var args = Environment.GetCommandLineArgs().Skip(1);
string[] preInitProperties = { "input-terminal", "terminal", "input-file", "config", string[] preInitProperties = { "input-terminal", "terminal", "input-file", "config",
"config-dir", "input-conf", "load-scripts", "scripts", "player-operation-mode" }; "config-dir", "input-conf", "load-scripts", "scripts", "player-operation-mode",
"idle", "log-file", "msg-color", "dump-stats", "msg-level", "really-quiet" };
foreach (string i in args) foreach (string i in args)
{ {

View File

@@ -513,7 +513,7 @@ filter = Playback
help = Using no, mpv would terminate after the last file but mpv.net never terminates automatically. help = Using no, mpv would terminate after the last file but mpv.net never terminates automatically.
option = yes If the current file ends, go to the next file, keep the last file open. option = yes If the current file ends, go to the next file, keep the last file open.
option = no If the current file ends, go to the next file. If keep-open-exit is set to yes, mpv.net exits after the last file. option = no If the current file ends, go to the next file. If idle is set to no, mpv.net exits after the last file.
option = always Playback will never automatically advance to the next file. option = always Playback will never automatically advance to the next file.
[setting] [setting]
@@ -527,11 +527,11 @@ option = yes
option = no option = no
[setting] [setting]
name = keep-open-exit name = idle
file = mpvnet file = mpv
default = no default = yes
filter = Playback filter = Playback
help = If set to yes and keep-open is set to no, mpv.net exits after the last file ends. In mpv the idle property would be used, it's not possible for mpv.net to use the idle property. help = If set to no and keep-open is also set to no, mpv.net exits after the last file ends. In mpv the idle default is no and in mpv.net the default is yes.
option = yes option = yes
option = no option = no