[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] [Pygame] Sound not playing
> Now that I'm testing sound, rather than music, nothing's happening.
>
> def PlaySound(sound):
> if type(sound) is str: ## Have to load it first.
> x = pygame.mixer.Sound(sound)
> else:
> x = sound
> x.play()
>
> "PlaySound("foo.wav")" doesn't produce any sound I can hear even after
> calling pygame.mixer.init() and cranking up the volume. "x.play" returns
> a Channel, suggesting that it thinks it's playing. Ideas?
Are you successfully playing other sounds? Is the channel tied up with a
sound that is looping? Is the sound too faint? Try sound.set_volume(1.0)
to crank it up.
Anyway, I'd not use the function above in a real game, otherwise you'll be
loading the same sound(s) multiple times (assuming you're calling it with
a string every time). Load them all once at the start of your program and
then play as needed.