Works for me on Windows after replacing `pygame.init()` with
`pygame.mixer.init()`
Christoph
On 6/27/2013 8:11 AM, sarah wrote:
Hi all,
I've just subscribed to this list hoping someone can hplease elp me with the
following problem: I wrote the class bellow (I also attached it) that simply
plays a sound
file when its method play_file() is called. It works on Linux perfectly, but
on Windows, no sound is played and I do need to find the reason of it.
Configurations are:
Windows 7 (32 bits), Python 2.6 and Pygame 1.9.1 (win32). Thank very
much for any help!
Sarah Barreto Marques
www.audiogames.com.br
@sarahbmarques
import sys, pygame
import time
class Sound:
pygame.mixer.pre_init(frequency=22050, size=-16, channels=2, buffer=1024)
def play_file(self, name):
# pygame.mixer.pre_init(frequency=44100, size=-16, channels=2,
buffer=1024)
# pygame.mixer.get_init()
sound=pygame.mixer.Sound(name)
print 'playing'
sound.play()
print 'done'
time.sleep(2)
return sound
if __name__=='__main__':
pygame.init()
sound=Sound()
som.play_file('0.wav')