Example #1
0
def radio(url, stop=False):
    # "static variables":
    # radio.radio_on, radio.pid, radio.url
    if not hasattr(radio, "on"):
        radio.on = False    # it doesn't exist yet, so initialize it
    #
    # for cleaning up:
    if stop:
        if radio.on:
            try:
                os.kill(radio.pid, SIGTERM)
            except OSError:
                pass
            radio.on = False
        return
    #
    if radio.on:
        radio(None, stop=True)
    #
    if not radio.on:
        common.play_audio(url)
        sleep(.1)
        radio.pid = common.get_pid_by_name("mplayer")
        radio.on = True
        radio.url = url
        if "slayradio" in url:
            print("Playing:", get_song()['current'])
        #print('# radio on')
    else:
        os.kill(radio.pid, SIGTERM)
        radio.on = False
Example #2
0
def radio(url, stop=False, id=None):
    # "static variables":
    # radio.radio_on, radio.pid, radio.url
    if not hasattr(radio, "on"):
        radio.on = False    # it doesn't exist yet, so initialize it
    radio.id = id
    #
    # for cleaning up:
    if stop:
        if radio.on:
            try:
                os.kill(radio.pid, SIGTERM)
            except OSError:
                pass
            radio.on = False
        return
    #
    if radio.on:
        radio(None, stop=True, id=id)
    #
    if not radio.on:
        common.play_audio(url)
        sleep(.1)
        radio.pid = common.get_pid_by_name(cfg.PLAYER["cmd"])
        radio.on = True
        radio.url = url
        print("Playing:", get_song())
        #print('# radio on')
    else:
        os.kill(radio.pid, SIGTERM)
        radio.on = False
Example #3
0
def play_beep():
    play_audio(cfg.ALERT)