Reputation: 171
I'm trying to make a game with pygame and I want to loop a music but when I put it in my main loop it just repeats the first second.
import pygame
import os
from pygame import mixer
pygame.init()
mixer.init()
#here i have all the display settings and stuff so im not gonna write them
mixer.music.load(os.path.join("Music", "music.wav"))
mixer.music.play()
I want this to play in a loop without stopping but I don't know how.
Upvotes: 1
Views: 4247
Reputation: 724
from the documentation for pygame.mixer.play:
The loops argument controls the number of repeats a music will play. play(5) will cause the music to played once, then repeated five times, for a total of six. If the loops is -1 then the music will repeat indefinitely.
so call
mixer.music.play(loops=-1)
Upvotes: 9