Exemplo n.º 1
0
    def get_state(self):
        volume = kodi_rpc.get_volume()
        muted = kodi_rpc.get_muted()

        player_status = 'stopped'
        player_id = kodi_rpc.get_active_playerid()
        if player_id is not None:
            player_status = 'playing' if kodi_rpc.is_player_playing(
                player_id) else 'paused'

        state = [
            {
                "name": "volume",
                "value": volume
            },
            {
                "name": "muted",
                "value": muted
            },
            {
                "name": "player",
                "value": player_status
            },
        ]

        if utils.cec_available():
            state.append({"name": "power", "value": True})

        return state
Exemplo n.º 2
0
    def get_state(self):
        start = time.time()

        volume = kodi_rpc.get_volume()
        muted = kodi_rpc.get_muted()

        player_status = 'stopped'
        player_id = kodi_rpc.get_active_playerid()
        if player_id is not None:
            player_status = 'playing' if kodi_rpc.is_player_playing(
                player_id) else 'paused'

        state = [
            {
                "name": "volume",
                "value": volume
            },
            {
                "name": "muted",
                "value": muted
            },
            {
                "name": "player",
                "value": player_status
            },
        ]

        if utils.cec_available():
            state.append({"name": "power", "value": True})

        logger.debug(u'Fetching state took {} ms'.format(
            int((time.time() - start) * 1000)))

        return state
Exemplo n.º 3
0
    def adjust_volume(self, volume):
        current_volume = kodi_rpc.get_volume()
        logger.debug('Current volume: {}'.format(current_volume))

        new_volume = max(min(current_volume + volume, 100), 0)
        logger.debug('Adjusting volume to: {}'.format(new_volume))

        kodi_rpc.set_volume(new_volume)
        return True
Exemplo n.º 4
0
    def _test_adjust_volume(self, volume, expected_volume):
        self.handler.handler({
            "type": "command",
            "commandType": "adjustVolume",
            "volume": volume,
        })
        run_one()

        kodi_volume = kodi_rpc.get_volume()
        self.assertEqual(kodi_volume, expected_volume)