Need help exporting game that plays sound file

45 views Asked by At

I was making a Tetris-like game, and I would like my friends to try it so I'm going to export it as an .exe file, but I'm playing the track in the background this way:

winsound.PlaySound('C:/Users/User/folder/project/tetris/tetrismusic.wav', 
                   winsound.SND_LOOP + winsound.SND_ASYNC)

I don't know if there is a way to play the file another way that doesn't involve the path. I've also tried:

winsound.Playsound('tetrismusic.wav', winsound.SND_LOOP + winsound.SND_ASYNC))

But it gives out an error saying the file can't be played.

1

There are 1 answers

1
Ali Samji On

Try putting a ./ before the filename.

winsound.Playsound('./tetrismusic.wav', winsound.SND_LOOP + winsound.SND_ASYNC))

Or — alternatively — add the SND_FILENAME flag.

winsound.Playsound('tetrismusic.wav', winsound.SND_LOOP + winsound.SND_ASYNC + winsound.SND_FILENAME))

Checking the docs, it seems the Playsound function is assuming that tetrismusic.wav is a sound alias.