1

I have a code which plays sound and a timer that decreases overtime but the problem is I don't know how to play the sound while the timer counts down.

    seconds = 10

for i in range(seconds):
    print(str(seconds-i) + " seconds remaining \n")
    t.sleep(1)
playsound('music.mp3')
stop
  • 29
  • 1
  • 1
    Does this answer your question? [How can I play looping music in the background as other functions are being performed?](https://stackoverflow.com/questions/73629675/how-can-i-play-looping-music-in-the-background-as-other-functions-are-being-perf) – Arifa Chan Sep 18 '22 at 12:10
  • nope, not at all – stop Sep 18 '22 at 14:45
  • Ok, do you want it plays the music only on start of counting then stops when it's done? – Arifa Chan Sep 18 '22 at 14:54
  • Well, you can start from mixer in pygame module. import the module, init the mixer, load the sound, play the sound before loop, and stop the sound in loop when the loop ends. – Arifa Chan Sep 18 '22 at 16:26

0 Answers0