Gabriele Cirulli Gabriele Cirulli - 1 year ago 107
Python Question

Pygame, sounds don't play

I'm trying to play sound files (.wav) with pygame but when I start it I never hear anything.

This is the code:

import pygame

sounda= pygame.mixer.Sound("desert_rustle.wav")

I also tried using channels but the result is the same

Answer Source

Your code plays desert_rustle.wav quite fine on my machine (Mac OSX 10.5, Python 2.6.4, pygame 1.9.1). What OS and Python and pygame releases are you using? Can you hear the .wav OK by other means (e.g. open on a Mac's terminal or start on a Windows console followed by the filename/path to the .wav file) to guarante the file is not damaged? It's hard to debug your specific problem (which is not with the code you give) without being able to reproduce it and without having all of these crucial details.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download