Check if soundfiles exist for jeopardy music
This commit is contained in:
parent
649a714bb3
commit
be4fd828c0
4
music.py
4
music.py
|
@ -1,5 +1,6 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
from PySide import phonon
|
from PySide import phonon
|
||||||
|
|
||||||
|
@ -19,7 +20,10 @@ class MusicBox(object):
|
||||||
@classmethod
|
@classmethod
|
||||||
def add_music(clazz, name, media_path):
|
def add_music(clazz, name, media_path):
|
||||||
if name not in clazz.media.iterkeys():
|
if name not in clazz.media.iterkeys():
|
||||||
|
if not os.path.isfile(media_path):
|
||||||
|
return False
|
||||||
clazz.media[name] = phonon.Phonon.MediaSource(media_path)
|
clazz.media[name] = phonon.Phonon.MediaSource(media_path)
|
||||||
|
return True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def play_music(clazz, name):
|
def play_music(clazz, name):
|
||||||
|
|
|
@ -59,7 +59,9 @@ if __name__ == '__main__':
|
||||||
MusicBox.init()
|
MusicBox.init()
|
||||||
for name, path in config["music"].iteritems():
|
for name, path in config["music"].iteritems():
|
||||||
if path:
|
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
|
# create board
|
||||||
board = SeopardyGame(questions, gamestate)
|
board = SeopardyGame(questions, gamestate)
|
||||||
|
|
Loading…
Reference in New Issue