import pygame
pygame.mixer.init()
pygame.mixer.music.load("myFile.Mp3")
pygame.mixer.music.play(-1) # note -1 for playing in loops
# do whatever
# when ready to stop do:
pygame.mixer.pause()
If you want to unpause:
pygame.mixer.unpause()
I have a question about pygame! I have the same pygame setting as above my question: When I click the main python code How can I keep this constantly playing in the background instead of stopping when I start Main.py?
I tried the code above but: it It starts when I boot up the Raspberry pi 4B but Stops playing when I click Main.py.