1

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.

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
SahilM
  • 118
  • 2
  • 13

2 Answers2

2

Try this code it will run the background music continuously till the app is running

mixer.music.play(-1)
Gaurav Kulkarni
  • 190
  • 1
  • 14
0

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.

Ayush Raj
  • 294
  • 3
  • 14