Not able to play sounds with pygame

Viewed 40

I was developing a simple game with Pygame and wanted to play some sound file. I first initialized the mixer(a pygame module used to play audio) by the following command :

pygame.mixer.init()

And then I played some sounds using the music.load and music.play commands of mixer module. It worked a few times just fine but later on, I started getting the following error in my terminal :

Traceback (most recent call last):
  File "c:\Users\Path\To\File", line 7, in <module>
    pygame.mixer.init()
pygame.error: WASAPI can't initialize audio client:

My python version is 3.10.5 and the Pygame version is 2.1.2. I want to play music with Pygame but the current error stops the program on start. I tried searching google for answers but there wasn't any relevant one. One of them was about using headphones but I don't want to restrict the sound play to headphones and similar devices only. And the original code was working earlier pretty much alright.

Here's the link for what I mentioned above. The problem there is quite different too : pygame.error: mixer not initialized How To Fix?

0 Answers
Related