Playing midi on Pygame
The following code will play music.mid located in the current directory
import pygame
pygame.init()
pygame.mixer.music.load("music.mid")
pygame.mixer.music.play()
If you have a simple program that exits after the play instruction, music playback will stop.
you should add the following two lines:
while pygame.mixer.music.get_busy():
pygame.time.wait(1000)
to prevent the program from exiting before the music has finished playing.