Try to play sound on all unix systems
sys.platform == 'linux' excludeds other unix systems, for example FreeBSD
This commit is contained in:
parent
0d70352460
commit
5152611ad7
|
@ -767,26 +767,30 @@ def play_sound_file(path_to_soundfile):
|
||||||
except Exception:
|
except Exception:
|
||||||
log.exception('Sound Playback Error')
|
log.exception('Sound Playback Error')
|
||||||
|
|
||||||
elif sys.platform == 'linux':
|
elif sys.platform == 'darwin':
|
||||||
if app.config.get('soundplayer') == '':
|
if not HAS_SOUND:
|
||||||
def _oss_play():
|
log.error('NSSound not available')
|
||||||
sndfile = wave.open(path_to_soundfile, 'rb')
|
|
||||||
nc, sw, fr, nf, _comptype, _compname = sndfile.getparams()
|
|
||||||
dev = oss.open('/dev/dsp', 'w')
|
|
||||||
dev.setparameters(sw * 8, nc, fr)
|
|
||||||
dev.write(sndfile.readframes(nf))
|
|
||||||
sndfile.close()
|
|
||||||
dev.close()
|
|
||||||
app.thread_interface(_oss_play)
|
|
||||||
return
|
return
|
||||||
player = app.config.get('soundplayer')
|
|
||||||
command = build_command(player, path_to_soundfile)
|
|
||||||
exec_command(command)
|
|
||||||
elif sys.platform == 'darwin' and HAS_SOUND:
|
|
||||||
sound = NSSound.alloc()
|
sound = NSSound.alloc()
|
||||||
sound.initWithContentsOfFile_byReference_(path_to_soundfile, True)
|
sound.initWithContentsOfFile_byReference_(path_to_soundfile, True)
|
||||||
sound.play()
|
sound.play()
|
||||||
|
|
||||||
|
elif app.config.get('soundplayer') == '':
|
||||||
|
def _oss_play():
|
||||||
|
sndfile = wave.open(path_to_soundfile, 'rb')
|
||||||
|
nc, sw, fr, nf, _comptype, _compname = sndfile.getparams()
|
||||||
|
dev = oss.open('/dev/dsp', 'w')
|
||||||
|
dev.setparameters(sw * 8, nc, fr)
|
||||||
|
dev.write(sndfile.readframes(nf))
|
||||||
|
sndfile.close()
|
||||||
|
dev.close()
|
||||||
|
app.thread_interface(_oss_play)
|
||||||
|
|
||||||
|
else:
|
||||||
|
player = app.config.get('soundplayer')
|
||||||
|
command = build_command(player, path_to_soundfile)
|
||||||
|
exec_command(command)
|
||||||
|
|
||||||
def get_global_show():
|
def get_global_show():
|
||||||
maxi = 0
|
maxi = 0
|
||||||
for account in app.connections:
|
for account in app.connections:
|
||||||
|
|
Loading…
Reference in New Issue