Closed wcarman1 closed 3 years ago
Because you call wait_for_playback
in an infinite loop, your script does the following:
a.avi
b.avi
wait_for_playback
-> returns after a.avi
is donewait_for_playback
again -> returns after b.avi
is donewait_for_playback
again -> never returns, because nothing is playing. Would only return if you started playing something again.To wait for the end of the playlist in one call, you can call wait_for_property
on the idle-active
property, doc here.
#!/usr/bin/env python3
import mpv
player = mpv.MPV(log_handler=print, loglevel='debug', input_default_bindings=True, input_vo_keyboard=True)
player.playlist_append('/home/user/Videos/a.avi')
player.playlist_append('/home/user/Videos/b.avi')
player.fullscreen = True
player.playlist_pos = 0
player.wait_for_property('idle-active')
That was exactly what I was looking for. Thank you very much! I knew it was going to be something easy .
I'm trying to get python to run a folder as a playlist like mpv does in bash. I slightly modified the example from the readme page for playlist handling to pull local files instead of youtube. Here is what I have:
It plays through the playlist fine but then loops at player.wait_for_playback() and never exits the script after the playlist is over. when I run player.play(xxxx) on the individual files it exits after playback is complete.
I know this is probably difficult because between each video in the playlist it sends a return status but figured I'd ask anyway.
All I want to do is run the script and play everything in the /home/user/Videos/ directory as a playlist and then exit the script gracefully but it keeps looping on the player.wait_for_playback() and doesn't return after playback is complete.
Here's my log output from running this script. https://pastebin.com/7uFzAK0G