1

I am writing a simple game using python and I was using the following:

import pygame
pygame.mixer.init()
pygame.mixer.music.load('02_3AM.wav')
pygame.mixer.music.play()

There is no errorcode when I run it, but there is also no audio... (see below shell print out)

PS C:\Users\Vincent\python> py music.py pygame 1.9.4 Hello from the pygame community. https://www.pygame.org/contribute.html

I know that this has been asked a few times, but there doesn't seem to be a definitive way to make it work yet, can anyone help pls?

  • There is no reason for this to not work. Does your file have sound? maybe it's corrupt. Maybe your windows is on Mute. Maybe your sound channel is set to headphone and you're listening on speaker. – Vineeth Sai Nov 22 '18 at 06:56
  • Hi, I was using those lines in a script that only had those lines and it seems the playback itself has to be run concurrent with something else or it runs and the program cuts and it cuts as well. I added timer.sleep(5) to my miniscript and then i managed to hear the music for 5secs. Thanks anyway! – Vincent_Koo Nov 23 '18 at 07:43
  • Yes.. All GUIs will be in a main loop anyway. – Vineeth Sai Nov 23 '18 at 08:56

0 Answers0