Reputation: 1
I am working on a game project in which I want to play sound effects while background music is going on , and I don't want to use any external library. This is my Code :
from winsound import SND_LOOP as LoopMusic,SND_ASYNC as SyncMusic,SND_NOSTOP as NstopMusic,PlaySound
def PlayMusic(num):
PlaySound(f"Data/Sound/music{num}.wav",LoopMusic|SyncMusic|NstopMusic)
def StopMusic():
PlaySound(None,SyncMusic)
def PlayEffect(effect):
PlaySound(f"Data/Sound/Effects/{effect}.wav",SyncMusic)
if __name__=="__main__":
PlayMusic(2)
PlayEffect("Click")
But this code stops the actual background music played by PlayMusic
when the PlayEffect
function is called .
I tried using thread module but did not get any output...
Upvotes: 0
Views: 16