Learn Before
Code

Loading/Playing Music in Pygame

You can load music using the load() method and passing in the music filename. You can then play the music in the background channel using the play() method. Both of these methods are contained within the music submodule. The only parameter is an int representing the number of times the music will loop. If set to -1, pygame will loop the music indefinitely.

pygame.mixer.music.load("music.wav") pygame.mixer.music.play(-1)

0

1

Updated 2021-08-02

Tags

Python Programming Language

Data Science