Pygame wont play background music when loading game

209 views Asked by At

Recently I have been trying to make a game in python with pygame and have so far succeeded. My endeavors came to a sudden halt when I tested the game after implementing sound code, and found that no sound played. I have looked around the forums and most people say to convert the .mp3 to a .wav or .ogg, and convert I did, but to no avail. I was thinking if it isn't the file, then maybe there must be something off with my code. Can you guys tell me what I can do to fix it?

The code is as follows

pygame.mixer.init()
pygame.mixer.music.load('BennyHill.wav')
pygame.mixer.music.play(-1, 0.0)

I am just a beginner at the moment, so it might look completely wrong to you experts out there

1

There are 1 answers

0
Luke B On

Do pygame.music.play(-1). In my programs that always works.

The docs are sometimes incorrect with needed/optional arguments.