Closed alterNERDtive closed 1 week ago
Pretty sure this was always racey, I think you'll want playlist-playing-pos
:
Index of the "playing" item on playlist. A playlist item is "playing" if it's being loaded, actually playing, or being unloaded. This property is set during the MPV_EVENT_START_FILE (start-file) and the MPV_EVENT_START_END (end-file) events. Outside of that, it returns -1. If the playlist entry was somehow removed during playback, but playback hasn't stopped yet, or is in progress of being stopped, it also returns -1. (This can happen at least during state transitions.)
Though I don't know whether "or is in progress of being stopped" refers to reaching the end of playlist, worth looking into. Otherwise you might just want to observe the idle-active
property.
During end-file
event, the playlist id corresponding to the item that has been just unloaded is provided, see docs.
Processing events, doesn't stop the player from progressing, so any get_property_native
inside event handler are "racey", scripts are run asynchronous.
Note that valid value for playlist-pos
on end-file
is 0 in your case. By repeatedly calling the get_property_native
you basically forcing script to wait until this value is cleared and mpv switches to idle.
has ended (with --idle=yes)
Observe idle-active
instead.
I think you'll want
playlist-playing-pos
I thought I had double checked that, but β¦ apparently not. Seems to work as expected, thanks!
Otherwise you might just want to observe the
idle-active
property.
That one exhibits the same behaviour as reported, just with false
β true
.
That one exhibits the same behaviour as reported, just with
false
βtrue
.
What do you mean by false
β true
?
It reports idle after finishing playback correctly for me.
mp.observe_property("idle-active", "native", function(_, val)
if val then
mp.set_property_native("fullscreen", false)
end
end)
Oh. Yes. My bad.
mpv Information
Other Information
Reproduction Steps
I am using the following script to exit fullscreen after the last item in a playlist has ended (with
--idle=yes
):After updating to 0.39, this stopped working. Investigation has turned out that there seems to be a race condition now (or always has been and I had never run into it) that leads to
playlist-pos
not resetting to-1
at the end of the play list fast enough for this event handler to work.If I add a couple of
to the start of the handler, I get an output of e.g.
(and then the script works, since itβs
-1
when the condition is hit).Expected Behavior
playlist-pos
is-1
in theend-file
event of the last entry in the playlist.Actual Behavior
playlist-pos
still holds the value of the last entry in the playlist for a little while before assuming the value-1
.Log File
output.txt
Sample Files
No response
I carefully read all instruction and confirm that I did the following:
--log-file=output.txt
.