コード例 #1
0
def process_command(request_path, params):
    """
    queue: Queue() of PlexCompanion.py
    """
    if params.get('deviceName') == 'Alexa':
        convert_alexa_to_companion(params)
    LOG.debug('Received request_path: %s, params: %s', request_path, params)
    if request_path == 'player/playback/playMedia':
        # We need to tell service.py
        action = 'alexa' if params.get('deviceName') == 'Alexa' else 'playlist'
        state.COMPANION_QUEUE.put({'action': action, 'data': params})
    elif request_path == 'player/playback/refreshPlayQueue':
        state.COMPANION_QUEUE.put({
            'action': 'refreshPlayQueue',
            'data': params
        })
    elif request_path == "player/playback/setParameters":
        if 'volume' in params:
            js.set_volume(int(params['volume']))
        else:
            LOG.error('Unknown parameters: %s', params)
    elif request_path == "player/playback/play":
        js.play()
    elif request_path == "player/playback/pause":
        js.pause()
    elif request_path == "player/playback/stop":
        js.stop()
    elif request_path == "player/playback/seekTo":
        js.seek_to(int(params.get('offset', 0)))
    elif request_path == "player/playback/stepForward":
        js.smallforward()
    elif request_path == "player/playback/stepBack":
        js.smallbackward()
    elif request_path == "player/playback/skipNext":
        js.skipnext()
    elif request_path == "player/playback/skipPrevious":
        js.skipprevious()
    elif request_path == "player/playback/skipTo":
        skip_to(params)
    elif request_path == "player/navigation/moveUp":
        js.input_up()
    elif request_path == "player/navigation/moveDown":
        js.input_down()
    elif request_path == "player/navigation/moveLeft":
        js.input_left()
    elif request_path == "player/navigation/moveRight":
        js.input_right()
    elif request_path == "player/navigation/select":
        js.input_select()
    elif request_path == "player/navigation/home":
        js.input_home()
    elif request_path == "player/navigation/back":
        js.input_back()
    elif request_path == "player/playback/setStreams":
        state.COMPANION_QUEUE.put({'action': 'setStreams', 'data': params})
    else:
        LOG.error('Unknown request path: %s', request_path)
コード例 #2
0
ファイル: playback.py プロジェクト: jpereas/plexkodiconnect
def threaded_playback(kodi_playlist, startpos, offset):
    """
    Seek immediately after kicking off playback is not reliable.
    """
    player = Player()
    player.play(kodi_playlist, None, False, startpos)
    if offset and offset != '0':
        i = 0
        while not player.isPlaying():
            sleep(100)
            i += 1
            if i > 100:
                LOG.error('Could not seek to %s', offset)
                return
        js.seek_to(int(offset))