0

I am currently having a certain error with background audio on my file in PyGame.

I have imported pygame mixer, initialized it, and used the following code:

pygame.mixer.music.load(open("BACKGROUND.mp3","rb"))
pygame.mixer.music.play()

The sound only plays when I am dragging / holding the window. Any idea why this may occur? Please help this is for a school project.

  • Please update the code to show the event processing - as the window is dragged, a lot of events are generated, maybe the handling of these is helping. Are you waiting long enough for the sound to play? The `music.play()` function returns somewhat immediately. – Kingsley Dec 18 '19 at 23:58
  • Are you checking for events? Try adding e = pygame.event.get() in your main loop – cookertron Dec 19 '19 at 03:05
  • Kingsley and cookertron thank you for the replies! Please help me with my other query if you have the time. –  Dec 19 '19 at 17:02

0 Answers0