Created
January 12, 2020 06:34
-
-
Save e96031413/ec562497e2ac2968cd093f65f199e1d3 to your computer and use it in GitHub Desktop.
How to play music with python?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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