0
for title in songs:
        media_player = vlc.MediaPlayer()

        media = vlc.Media(title + ".mp4")
        media.add_option('start-time=' + str(seconds))
        media.add_option('stop-time=' + str(seconds + 20))
        media_player.set_media(media)
        media_player.play()
        
        time.sleep(20)

If I remove time.sleep, the next song immediately plays. How can I wait until the current song finishes its set time then play the next one?

I tried using start and stop times but it did not work.

1 Answers1

0

How about you make sure the player isn't playing :

for title in songs:
        media_player = vlc.MediaPlayer()

        if(!media_player.is_playing()):
          media = vlc.Media(title + ".mp4")
          media.add_option('start-time=' + str(seconds))
          media.add_option('stop-time=' + str(seconds + 20))
          media_player.set_media(media)
          media_player.play()