Program not playing sound

146 Views Asked by At

I am programmin a text based game in Python and I want to play effects music over the battle music, I have written the following module to play sounds

#Music.py:
#V2
import winsound as ws
def playS(a):
    p=("C:\\Users\\user\\OneDrive\\Desktop\\Game\\soundLibrary\\"+(a)+".wav")
    ws.PlaySound(p,ws.SND_ASYNC)

def playE(a):
    p=("C:\\Users\\user\\OneDrive\\Desktop\\Game\\soundLibrary\\"+(a)+".wav")
    ws.PlaySound(p,ws.SND_NOSTOP)

When the function playE('effect') is played the following error message is returned

File "c:\Users\user\OneDrive\Desktop\Game\Music.py", line 10, in playE
    ws.PlaySound(p,ws.SND_NOSTOP)
RuntimeError: Failed to play sound

If anyone could say why it would be appreciated.

(note: playS() works fine)

1

There are 1 best solutions below

0
On

Playsound doesn't actually let you play two sounds simultaeneously, hence it is returning an error.