Skip to content

Instantly share code, notes, and snippets.

@e96031413
Created January 12, 2020 06:34
Show Gist options
  • Select an option

  • Save e96031413/ec562497e2ac2968cd093f65f199e1d3 to your computer and use it in GitHub Desktop.

Select an option

Save e96031413/ec562497e2ac2968cd093f65f199e1d3 to your computer and use it in GitHub Desktop.
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