Search code examples
pythonplaysoundwinsound

using winsound, plays error sound instead of chosen sound


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.


Solution

  • 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)