Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to play music with python?
#Method(1)Using system default player
import os
os.system('test.mp3')
#Method(2)Using pygame
import pygame
pygame.mixer.init()
pygame.mixer.music.set_volume(1.0)
while True:
if not pygame.mixer.music.get_busy():
pygame.mixer.music.load('test.mp3')
pygame.mixer.music.play()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment