Check if soundfiles exist for jeopardy music

master
Sebastian Lohff 10 anni fa
parent 649a714bb3
commit be4fd828c0

@ -1,5 +1,6 @@
from __future__ import print_function
import os
import sys
from PySide import phonon
@ -19,7 +20,10 @@ class MusicBox(object):
@classmethod
def add_music(clazz, name, media_path):
if name not in clazz.media.iterkeys():
if not os.path.isfile(media_path):
return False
clazz.media[name] = phonon.Phonon.MediaSource(media_path)
return True
@classmethod
def play_music(clazz, name):

@ -59,7 +59,9 @@ if __name__ == '__main__':
MusicBox.init()
for name, path in config["music"].iteritems():
if path:
MusicBox.add_music(name, path)
if not MusicBox.add_music(name, path):
print("Error: Could not load music %s (file %s)" % (name, path), file=sys.stderr)
sys.exit(1)
# create board
board = SeopardyGame(questions, gamestate)

Caricamento…
Annulla
Salva