Advertisement
Tyler_Elric

Untitled

Dec 20th, 2012
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. from os import listdir as osld
  2. from pygame import mixer, font, display, event, quit
  3. display.init()
  4. font.init()
  5. mixer.init()
  6.  
  7. def listdir(d):
  8. for fn in osld:
  9. yield "{}/{}".format(d,fn)
  10.  
  11. def load_song(fn):
  12. return mixer.music.load(fn)
  13.  
  14. songs,playing = [load_song(fn) for fn in listdir('music')],True
  15. arial = font.SysFont("Arial",10)
  16. window = display.set_mode((320,240))
  17. running = True
  18.  
  19. while running:
  20. for event in event.get():
  21. if event.type==pygame.QUIT:
  22. running=False
  23. elif event.type==pygame.KEYDOWN:
  24. if event.key==pygame.SPACE:
  25. if playing:
  26. mixer.pause()
  27. else:
  28. mixer.unpause()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement