def selection():
for song in my_music:
print(song)
pygame.mixer.music.load(song)
pygame.mixer.music.play(loops=0)
Here my_music
is list containing the paths of mp3 files that i want to play but, the problem is that it plays only first file though the my_music
list contains more than 5. I also used print(song)
to check but it prints the paths of all files but plays only one. can someone help!!
the pygame.mixer.music.play()
is not blocking. The songs need to be queued into the mixer and then played. The loops=x
argument is used to repeat the songs in the queue
def play_songs(song_list):
for song in song_list:
print("queueing song: {}".format(song))
pygame.mixer.music.queue(song)
print("now playing...")
pygame.mixer.music.play(loops=-1) # -1 means repeat forever
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.