def radio_loop(now, key_value): global currently_tuned switch_channel(key_value) # change radio channel get_mpd_info(now) if app_states["play"] == 1: if mpd.stat() != "play" or currently_tuned != app_states["channel"]: mpd.play(app_states["channel"]) else: if mpd.stat() == "play": mpd.stop() if key_value == "KEY_PLAYPAUSE": play_pause(now)
def radio_loop(now,key_value): global currently_tuned switch_channel(key_value) # change radio channel get_mpd_info(now) if app_states["play"] == 1: if mpd.stat() != "play" or currently_tuned != app_states["channel"]: mpd.play(app_states["channel"]) else: if mpd.stat() == "play": mpd.stop() if key_value == "KEY_PLAYPAUSE": play_pause(now)
def restore_tones(): global app_states global prev_app_states if os.path.exists('appstates.sav'): print("restoring states") with open('appstates.sav') as data_file: try: app_states = json.load(data_file) except: print "unable to load json file" audio.switch_input(app_states["input"]) if app_states["play"] == 0: mpd.stop() else: mpd.play(app_states["channel"]) prev_app_states["play"] = app_states["play"] app_states["changed"] = True
def restore_tones(): global app_states global prev_app_states if os.path.exists('appstates.sav'): print("restoring states") with open('appstates.sav') as data_file: try: app_states = json.load(data_file) except: print"unable to load json file" audio.switch_input(app_states["input"]) if app_states["play"] == 0: mpd.stop() else: mpd.play(app_states["channel"]) prev_app_states["play"] = app_states["play"] app_states["changed"] = True
def switch_channel(key_value): changed = False if key_value == "KEY_UP": if app_states["channel"] != num_radio_channels: app_states["channel"] = app_states["channel"] + 1 else: app_states["channel"] = 0 changed = True elif key_value == "KEY_DOWN": if app_states["channel"] != 0: app_states["channel"] = app_states["channel"] - 1 else: app_states["channel"] = num_radio_channels changed = True if re.search("KEY_[0-9]+", key_value): regex = re.search("KEY_([0-9]+)", key_value) app_states["channel"] = int(regex.group(1)) - 1 changed = True if changed == True: app_states["play"] = 1 prev_app_states["play"] = 0 mpd.play(app_states["channel"]) app_states["play"] == 1 prev_app_states["play"] == 0