Reputation: 128
I have been trying to run sound in background while App is running. I am Arch Linux and Python 3.8 I have tried playsound as like this
playsound('music.mp3', False)
but I get error saying system not supported. I have also tried pygame following way:
from pygame import mixer
mixer.init()
mixer.music.load("music.mp3")
mixer.music.play()
But I get error pygame.error: Unrecognized audio format
. Is there any other way I can run music in background some task is executing on GUI with tkinter. The program will run on arch and Ubuntu.
Upvotes: 1
Views: 1456
Reputation: 304
Try this:
mixer.music.play(-1)
And if you want your background music to be stopped in 10s then add this too:
gui_name.after(10000, mixer.music.stop)
Hope it will help you.
Upvotes: 0
Reputation: 220
Try this code it will run the background music continuously till the app is running
mixer.music.play(-1)
Upvotes: 2