示例#1
0
def playSound():
    # Gah this is so hacky.
    sound_dir = os.path.join(os.path.dirname(desklib.__file__), '../media')
    sound_files = [f for f in os.listdir(sound_dir) if 'mp3' in f]
    filename = random.choice(sound_files)
    the_file = os.path.join(sound_dir, filename)
    sh.afplay(the_file)
def play_sound():
    volume = 2
    if config.get('Options', 'sound_volume') == 'low':
        volume = .3
    if config.get('Options', 'sound_volume') == 'high':
        volume = 4
    # TODO make this a configurable
    sh.afplay('-q 1 -v {} /System/Library/Sounds/Hero.aiff'.format(volume))
示例#3
0
def play_mp3(mp3_file):
    print('<playing...', end='', flush=True)
    p = afplay(mp3_file, _bg=True)
    try:
        p.wait()
        print('done>')
    except (KeyboardInterrupt, sh.SignalException_SIGTERM) as e:
        p.terminate()
        print('cancelled>')
        return False

    return True
示例#4
0
def play_mp3(mp3_file):
    print('<playing...', end='', flush=True)
    p = sh.afplay(mp3_file, _bg=True)
    try:
        p.wait()
        print('done>')
    except KeyboardInterrupt:
        p.terminate()
        print('cancelled>')
        return False

    return True
示例#5
0
def play_mp3(mp3_file):
    print('<playing...', end='', flush=True)
    p = afplay(mp3_file, _bg=True)
    try:
        p.wait()
        print('done>')
    except KeyboardInterrupt:
        p.terminate()
        print('cancelled>')
        return False

    return True
示例#6
0
def play_mp3(mp3_file):
    print('<playing...', end='', flush=True)
    p = afplay(mp3_file, _bg=True)
    try:
        p.wait()
        print('done>')
    except (KeyboardInterrupt, sh.SignalException_SIGTERM) as e:
        p.terminate()
        print('cancelled>')
        return False

    return True