Why doesn't my PyGame mixer play sounds,?

user164814 picture user164814 · Sep 9, 2013 · Viewed 10.6k times · Source

My PyGame mixer in 2.7 won't work with the sound option. I can make it work with mixer.music but not with mixer.sound, with mixer.sound it makes a small ticking noise and then stops. Code:

import pygame
pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=4096)
song = pygame.mixer.Sound("song.mp3")
pygame.mixer.Sound.play(song)

No error, it just won't play and gives a small ticking noise. On windows 7-x64 btw.

Answer

SimonT picture SimonT · Sep 16, 2013

Usually, Pygame will not play mp3 files. You could test to see if .wav and .ogg files will play first, to make sure your code is correct (based on what you pasted, it seems to be right). I suggest converting your mp3 sounds to ogg for Pygame.