Winsound not playing sounds

349 Views Asked by At

I want to loop the sound with winsound but it doesn't work with

winsound.PlaySound(song[0], winsound.SND_ASYNC + winsound.SND_LOOP

and

winsound.PlaySound(song[0], winsound.SND_FILENAME | winsound.SND_ASYNC + winsound.SND_LOOP

The code just closes after this. What's the problem?

1

There are 1 best solutions below

1
Tim Roberts On

To use SND_LOOP, you have to use SND_ASYNC, and that means the sound is playing in a separate thread. The PlaySound function will return immediately. Your code is presumably going to do something else while the sound plays. If nothing else, do time.sleep(5) in a loop.