pygame.mixer.music.unload()
import os
import pygame
import time
sound_place = r"C:\Users\ghostiki\Desktop\test.ogg"
pygame.mixer.init()
pygame.mixer.music.load(sound_place)
pygame.mixer.music.play()
while pygame.mixer.music.get_busy():
time.sleep(1)
pygame.mixer.music.unload()
os.remove(r"C:\Users\ghostiki\Desktop\test.ogg")
def play(file_path):
pygame.mixer.init()
pygame.mixer.music.load(file_path)
pygame.mixer.music.play()
while pygame.mixer.music.get_busy(): # if True, the melody is being played
time.sleep(1)
play('path_to_file/file.ogg') # dancing dancing dancing...