user5457243
user5457243

Reputation:

How to play multiple sounds simultaneously using winsound?

I am trying to layer multiple sounds on top of each other with the built-in winsound library. I start my 1st sound with

winsound.PlaySound("test1.wav", winsound.SND_FILENAME | winsound.SND_ASYNC) 

When I try to start my other sound

winsound.PlaySound("test1.wav", winsound.SND_FILENAME | winsound.SND_ASYNC 
            | winsound.SND_NOSTOP)

I get the not-very-descriptive RuntimeError: Can't play sound.
How do I fix that?

Upvotes: 2

Views: 4154

Answers (1)

R. Wayne
R. Wayne

Reputation: 407

I was able to play two sounds by using winsound and playsound:

from playsound import playsound
import winsound
#
filename1 = "C:/Users/sound1.wav"
filename2 = "C:/Users/sound2.wav"
soundfile = filename1
winsound.PlaySound(soundfile, winsound.SND_FILENAME|winsound.SND_ASYNC)
playsound(filename2)

Upvotes: 1

Related Questions