Added exception handling for sound playing dependencies

This commit is contained in:
Bob Mottram 2013-07-20 10:55:03 +01:00
parent a7a2de1d24
commit cfc23718ed
1 changed files with 12 additions and 6 deletions

View File

@ -937,13 +937,19 @@ class MyForm(QtGui.QMainWindow):
if 'linux' in sys.platform:
# Note: QSound was a nice idea but it didn't work
if '.mp3' in soundFilename:
subprocess.call(["gst123", soundFilename],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
try:
subprocess.call(["gst123", soundFilename],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
except:
print "WARNING: gst123 must be installed in order to play mp3 sounds"
else:
subprocess.call(["aplay", soundFilename],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
try:
subprocess.call(["aplay", soundFilename],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
except:
print "WARNING: aplay must be installed in order to play WAV sounds"
elif sys.platform[0:3] == 'win':
# use winsound on Windows
import winsound