Minor sound work.

This commit is contained in:
karxi 2016-12-03 00:27:34 -05:00
parent 7531260d8f
commit 61bd147b06

View file

@ -2778,17 +2778,29 @@ class MainProgram(QtCore.QObject):
options = self.oppts(sys.argv[1:]) options = self.oppts(sys.argv[1:])
if pygame and pygame.mixer: def doSoundInit():
# we could set the frequency higher but i love how cheesy it sounds # TODO: Make this more uniform, adapt it into a general function.
try: if pygame and pygame.mixer:
pygame.mixer.init() # we could set the frequency higher but i love how cheesy it sounds
pygame.mixer.init() try:
except pygame.error, e: pygame.mixer.init()
print "Warning: No sound! %s" % (e) pygame.mixer.init()
elif not QtGui.QSound.isAvailable(): except pygame.error as err:
print "Warning: No sound! (No pygame/QSound)" print "Warning: No sound! (pygame error: %s)" % err
else: else:
print "Warning: No sound!" # Sound works, we're done.
return
# ... Other alternatives here. ...
# Last resort. (Always 'works' on Windows, no volume control.)
if QtGui.QSound.isAvailable():
# Sound works, we're done.
return
else:
print "Warning: No sound! (No pygame/QSound)"
doSoundInit()
self.widget = PesterWindow(options, app=self.app) self.widget = PesterWindow(options, app=self.app)
self.widget.show() self.widget.show()