Sam Vruggink Sam Vruggink - 24 days ago 14
Python Question

How to play music in background Tkinter with winsound

I am trying to make a program and have the pokemon theme in the background while tkinter is running. But the program doesnt start before the song is over. How can I make that python keeps winsound active while running the rest of the program.'

winsound.PlaySound('song.wav', winsound.SND_ALIAS)


This is what I have. After this the code the whole program starts.

Answer

Use winsound.SND_ASYNC to make the call return immediatly:

winsound.PlaySound('song.wav', winsound.SND_ALIAS | winsound.SND_ASYNC)
Comments