Skip to content

Instantly share code, notes, and snippets.

@illume
Created October 14, 2019 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save illume/807b7e567dd4840b26450882ecbe5a01 to your computer and use it in GitHub Desktop.
Save illume/807b7e567dd4840b26450882ecbe5a01 to your computer and use it in GitHub Desktop.
How to play midi music with pygame.mixer.music.
# midimusic.py
# curl -O https://upload.wikimedia.org/wikipedia/commons/5/55/MIDI_sample.mid
import time, sys, pygame
pygame.mixer.init()
pygame.mixer.music.load('MIDI_sample.mid')
pygame.mixer.music.play()
while pygame.mixer.music.get_busy():
print('Still playing :)')
time.sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment