def player_cmd(request): if not player.playing(): request.session.flash(u"А плеер то не играет!") return HTTPFound(location=request.route_url('player')) cmd = request.matchdict["cmd"] if cmd=="pause": player.pause() elif cmd=="stop": player.stop() elif cmd=="seek_left": player.seek(-5) elif cmd=="seek_right": player.seek(5) elif cmd=="snd_up": player.volume(5) elif cmd=="snd_down": player.volume(-5) else: request.session.flash(u"Не знаю что за команда") return HTTPFound(location=request.route_url('player'))
def main(): print((sys.version)) #get presets getPresets() writePresets() inp = inputs.inputs() stations = radioTime.Stations() menuList = ("Radio", "USB", "Settings") menuListSel = "Radio" stationListSel = "" activeStation = player.getInformation()["Station"] activePage = "Menu" activePageLast = "Menu" #init done, fade to main prog visu.explosion() #update screen and handle events running = True while running: action = inp.getInput() #Menu ---------------------------------------------------------------- if activePage == "Menu": activeItem = menuList.index(menuListSel) if action == "up": activeItem -= 1 if activeItem < 0: activeItem = 0 elif action == "down": activeItem += 1 if activeItem >= len(menuList): activeItem = len(menuList) - 1 elif action == "enter": if menuListSel == "Radio": activePage = "StationSelect" if activeStation == "" else "Radio" else: activePage = menuListSel elif action == "back": activePage = activePageLast menuListSel = menuList[activeItem] visu.menu1(menuList, activeItem) #Radio --------------------------------------------------------------- elif activePage == "Radio": if action == "up": player.volume(2) elif action == "down": player.volume(-2) elif action == "enter": activePage = "StationSelect" elif action == "back": activePage = "Menu" info = player.getInformation() if info["Station"] == "": info["Station"] = activeStation if info["Station"] != activeStation: try: url = stations.stations[activeStation] del stations.stations[activeStation] stations.stations[info["Station"]] = url activeStation = info["Station"] stationListSel = activeStation except: pass visu.radio(activeStation, info["Text"], info["Volume"], info["WLAN"]) #StationSelect ------------------------------------------------------- elif activePage == "StationSelect": nameList = list(stations.stations.keys()) nameList.sort(key=lambda x: x.lower()) #Case In-sensitive try: activeItem = nameList.index(stationListSel) except: activeItem = 0 if action == "up": activeItem -= 1 if activeItem < 0: activeItem = 0 elif action == "down": activeItem += 1 if activeItem >= len(stations.stations): activeItem = len(stations.stations) - 1 elif action == "enter": if activeStation != stationListSel: activeStation = stationListSel stations.updateUrl(activeStation) player.play(stations.stations[activeStation]) activePage = "Radio" elif action == "back": activePage = "Menu" if activeStation == "" else "Radio" stationListSel = nameList[activeItem] visu.menu2(nameList, activeItem) #USB ----------------------------------------------------------------- elif activePage == "USB": if action == "up": x = 0 #volume up elif action == "down": x = 0 #volume down elif action == "enter": activePage = "SongSelect" elif action == "back": activePage = "Menu" if action == "none": visu.usb() #Settings ------------------------------------------------------------ elif activePage == "Settings": if action == "up": x = 0 #foo elif action == "down": x = 0 #foo elif action == "enter": x = 0 #foo elif action == "back": activePage = "Menu" if action == "none": visu.settings()