Reputation: 13
I am using winsound to play a swoosh sound:
winsound.PlaySound("D:\GamesImade\pythonpong\bounce.wav", winsound.SND_ASYNC)
When I run it with my IDE it works. But if I run the exe file by itself it doesn't work, it plays the windows error sound.
Upvotes: 1
Views: 3098
Reputation: 11
I had a line of code that was supposed to run at a certain point and the code was accurately recognizing when the sound was supposed to be played, but it was only playing a windows error sound.
I changed the code from:
winsound.PlaySound("sound.wav", winsound.SND_ASYNC)
To:
winsound.PlaySound('C:/Users/username/OneDrive/Desktop/Project Folder/sound.wav', winsound.SND_ASYNC)
So, like the answer I switched the slashes around, but kept the SND_ASYNC
and that runs in the program.
Upvotes: 1
Reputation: 28640
try changing the flag shown below and also the backslash to forward slash
winsound.PlaySound("D:\GamesImade\pythonpong\bounce.wav", winsound.SND_ASYNC)
to
winsound.PlaySound("D:/GamesImade/pythonpong/bounce.wav", winsound.SND_FILENAME)
Upvotes: 0