Winsound doesn't play whole sound?

Graham Fawcett graham.fawcett at gmail.com
Wed Nov 30 09:29:21 EST 2005


Dieter Vanderelst wrote:
> Hello,
>
> I'm having a problem with playing WAV files using Winsound.
>
> If I use winsound to play a certain WAV files only the first few seconds
> of the file get played. I think this comes because these files contain
> some parts of silence. There winsound seems the stop playing the files
> (windows media player plays the sounds correctly).
[snip]
> Just as a reference, the code I use:
> winsound.PlaySound("My_wav.wav", winsound.SND_FILENAME)

This is totally a guess, but add the following to the end of your test
script:

import time
time.sleep(10)

Did the file play for ten seconds longer? I don't know anything about
winsound, but I'm guessing that the PlaySound call is non-blocking, and
your playback stops because your process is quitting before the sound
has played.

Graham




More information about the Python-list mailing list