Exemple #1
0
    def execute(self):
        super(XBMCRequest, self).execute()

        if self.action == constants.REQUEST_XBMC_ACTION_GET:
            if self.cmd == 'player':
                self.answer = xbmcremote.getActivePlayer()
            if self.cmd == 'volume':
                self.answer = xbmcremote.getVolume()

        if self.action == constants.REQUEST_XBMC_ACTION_SET:
            if self.cmd == 'notification':
                self.answer = xbmcremote.showNotification(self.request['params'][0], self.request['params'][1])
            if self.cmd == 'playpause':
                self.answer = xbmcremote.playPause()
            if self.cmd == 'stop':
                self.answer = xbmcremote.stop()
            if self.cmd == 'next':
                self.answer = xbmcremote.next()
            if self.cmd == 'previous':
                self.answer = xbmcremote.previous()
            if self.cmd == 'volume':
                self.answer = xbmcremote.setVolume(int(self.request['params'][0]))
            if self.cmd == 'volup':
                self.answer = xbmcremote.volumeUp()
            if self.cmd == 'voldown':
                self.answer = xbmcremote.volumeDown()

        if self.action == constants.REQUEST_XBMC_ACTION_CMD:
            self.answer = xbmcremote.sendCommand(self.cmd)

        answer = {"type":self.type, self.action:self.cmd, "answer":self.answer}
        return answer
Exemple #2
0
def fade(task, timeInSecs, endColor, startColor=None):

    if task is not None and task.state != constants.CMD_STATE_STARTED:
        raise RuntimeError("the thread, which is responsible for this fade has an invalid state: "+str(task.state))
    if timeInSecs <= 0:
        raise ValueError("time cannot be 0 or below: "+str(timeInSecs))

    startVolume = 0
    ##timeInSecs = 20
    if config.ENABLE_XBMC_REMOTE:
        startVolume = xbmcremote.getVolume()

    if startColor is None:
        startColor = datatypes.Color(led.COLOR[0].R, led.COLOR[0].G, led.COLOR[0].B)

    currentColor = datatypes.Color(startColor.R, startColor.G, startColor.B)

    startTime = time.time()

    secondsPassed = 0.0
    lastVolume = startVolume

    while ((task is not None and (task.isStarted() and (task.thread is None or task.thread.isStarted()))) and secondsPassed <= timeInSecs):
        secondsPassed = time.time() - startTime
        #interpolate new color
        utils.interpolateColor(startColor, endColor, secondsPassed/timeInSecs, currentColor)
        
        #fade step filters
        for f in server.CurrentFilters:
            f.onFadeStep(timeInSecs, startColor, endColor, secondsPassed/timeInSecs)

        time.sleep(config.DELAY)
        #print startColor," ", endColor, "     ", secondsPassed/timeInSecs
        led.setColor(currentColor)

    #fade end filters
    for f in server.CurrentFilters:
        f.onFadeEnd(timeInSecs, startColor, endColor)