Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from os import listdir as osld
- from pygame import mixer, font, display, event, quit
- display.init()
- font.init()
- mixer.init()
- def listdir(d):
- for fn in osld:
- yield "{}/{}".format(d,fn)
- def load_song(fn):
- return mixer.music.load(fn)
- songs,playing = [load_song(fn) for fn in listdir('music')],True
- arial = font.SysFont("Arial",10)
- window = display.set_mode((320,240))
- running = True
- while running:
- for event in event.get():
- if event.type==pygame.QUIT:
- running=False
- elif event.type==pygame.KEYDOWN:
- if event.key==pygame.SPACE:
- if playing:
- mixer.pause()
- else:
- mixer.unpause()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement