def radioControl(action): if(action == 'load'): mpc.loadPlaylist() else: mpc.sysCmd('mpc ' + action) time.sleep(SETTINGS_STATION_READ_WAIT) return mpc.sysCmd('mpc current')
def stationButtonPressed(self): stationSelected = GPIO.input(ROTARY_PIN_BUTTON) if(stationSelected and self.lastLedPos != self.ledPos): self.lastLedPos = self.ledPos mpc.loadPlaylist() mpc.sysCmd('mpc play ' + str(self.ledPos+1)) self.updateLeds()
def deleteStation(id): if (id != 'undefined'): index = int(id) pos = index+1 mpc.sysCmd('mpc del ' + str(pos)) mpc.savePlaylist() return "true" return "false"
def run(self): while(self.__running): current = mpc.sysCmd('mpc current') if(len(current.strip()) == 0): next = self.__player.next() if next is None: self.__running = False else: url = Player.api.get_stream_urls(next)[0] mpc.telnetCmd('clear') mpc.telnetCmd('add ' + str(url)) mpc.telnetCmd('play') time.sleep(3)
def saveStation(id): if (id != 'undefined'): stationUrl = request.forms.url # check if the station is defined index = int(id) stationList = getStationList() stationCount = len(stationList['stations']) if(len(stationUrl) > 5): if(index >= 0): pos = index+1; mpc.sysCmd('mpc del ' + str(pos)) mpc.sysCmd('mpc add ' + stationUrl) if(index >= 0): mpc.sysCmd('mpc move ' + str(stationCount) + ' ' + str(pos)) mpc.savePlaylist() return "true" return "false"
import threading import ConfigParser from bottle import route, run from radio_control import RadioControl radioConfigFile = "radio.ini" config = ConfigParser.RawConfigParser() config.read(radioConfigFile) # Server Settings SETTING_SERVER_IP = config.get('HttpServer', 'server_host') SETTING_SERVER_PORT = int(config.get('HttpServer', 'server_port')) # Start mpc/mpd mpc.loadPlaylist() mpc.sysCmd('mpc play') # Radio Control control = RadioControl() control.setDaemon(True) control.start() # Exit listener for the player def goodbye(): print "Terminating Radio Server" print "Stopping GMusic REST Player" gmusic_rest.exit() print "Stopping Radio Control" control.stop() atexit.register(goodbye)
def editVolume(volume): mpc.sysCmd('mpc volume ' + volume) return volume
def getVolume(): vol = mpc.sysCmd('mpc volume').strip() return vol[8:-1]