Skip to content

Instantly share code, notes, and snippets.

@letoh
Created December 28, 2012 13:37
Show Gist options
  • Select an option

  • Save letoh/4397922 to your computer and use it in GitHub Desktop.

Select an option

Save letoh/4397922 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import pygame
from pygame import mixer as mixer
import sys
if len(sys.argv) == 1:
sys.exit()
try:
pygame.init()
mixer.init(44100) #raises exception on fail
SONG_END = pygame.USEREVENT + 1
print 'load', sys.argv[1]
mixer.music.set_endevent(SONG_END)
mixer.music.load(sys.argv[1])
mixer.music.play()
while True:
for event in pygame.event.get():
if event.type == SONG_END:
mixer.quit()
pygame.quit()
sys.exit(0)
except Exception as e:
print "failed", e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment