playing mp3 file in the background of the python application (windows OS)

31 views Asked by At

I'm building a simple space war game using python turtle. I want to play a laser sound every time I fire a missile, so I'm using the command: playsound("laser.mp3) the problem is that my game pause until the end of the sound. how do I make the sound play in the background? I know that for Mac system the command is os.system("afplay laser.mp3&"). What should be the command for Windows?

I try to play the mp3 file in the background of the game but the games keep pausing till the end of the mp3 file

1

There are 1 answers

0
Vivek Kumar On

you can use cmd commands using os module:

os.system("start cmd /c {command here}")     # Launches in new command prompt, closes when done

in your case you can use something like:

import os
os.system("start cmd /C \"afplay laser.mp3\"")