New Blog Post

Sound and music with pygame

pip install pygame Sound import pygame if __name__ == ‘__main__’: pygame.mixer.init() sound = pygame.mixer.Sound(“./sound.wav”) channel = sound.play() while channel.get_busy(): pygame.time.wait(100) print(“Playing…”) print(“Finished.”)   Music import pygame if __name__ == ‘__main__’: pygame.mixer.init() pygame.mixer.music.load(“./sound.mp3”) pygame.mixer.music.play() while pygame.mixer.music.get_busy(): pygame.time.wait(100) # ms print(“Playing…”) print(“Finished.”)