So I need to reproduce my song on loop using VLC. I used this code and when I play it, it only plays the song once and then the program stops. How can I fix it? Here is the code:
def reproduce_song():
player = vlc.Instance()
media_list = player.media_list_new()
media_player = player.media_list_player_new()
media = player.media_new("Complements//song1.mp3")
media_list.add_media(media)
media_player.set_media_list(media_list)
player.vlm_set_loop("Complements//song1.mp3", True)
media_player.play()
time.sleep(120)
Try this code.
def reproduce_song():
player = vlc.Instance()
media_list = player.media_list_new()
media_player = player.media_list_player_new()
media = player.media_new("Complements//song1.mp3")
media_list.add_media(media)
media_player.set_media_list(media_list)
player.vlm_set_loop("Complements//song1.mp3", True)
media_player.play()
time.sleep(120)
flag = True
while flag:
reproduce_song()
quit_input = input()
if quit_input == "q": # To quit your program manually.
flag = False
It will make your song continue playing until you quit it.