Created
December 28, 2012 13:37
-
-
Save letoh/4397922 to your computer and use it in GitHub Desktop.
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
| #!/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