Пример #1
0
def _setup_airplay(loop, session, details):
    airplay_service = details.airplay_service()
    airplay_player = player.AirPlayPlayer(loop, session, details.address,
                                          airplay_service.port)
    airplay_http = HttpSession(
        session, 'http://{0}:{1}/'.format(details.address,
                                          airplay_service.port))
    return AirPlayAPI(airplay_http, airplay_player)
Пример #2
0
    def test_play_when_device_not_ready(self):
        self.usecase.airplay_playback_not_ready()

        aplay = player.AirPlayPlayer(self.loop,
                                     '127.0.0.1',
                                     port=self.app.port)
        yield from aplay.play_url(STREAM, position=START_POSITION)

        self.assertEqual(self.no_of_sleeps, 0)
Пример #3
0
    async def test_play_video_no_permission(self):
        self.usecase.airplay_playback_playing_no_permission()

        session = ClientSession(loop=self.loop)
        aplay = player.AirPlayPlayer(self.loop,
                                     session,
                                     '127.0.0.1',
                                     port=self.server.port)

        with self.assertRaises(exceptions.NoCredentialsError):
            await aplay.play_url(STREAM, position=START_POSITION)
Пример #4
0
    async def setUpAsync(self):
        await AioHTTPTestCase.setUpAsync(self)

        # This is a hack that overrides asyncio.sleep to avoid making the test
        # slow. It also counts number of calls, since this is quite important
        # to the general function.
        player.asyncio.sleep = self.fake_asyncio_sleep
        self.no_of_sleeps = 0

        self.session = ClientSession(loop=self.loop)
        http = net.HttpSession(
            self.session, 'http://127.0.0.1:{0}/'.format(self.server.port))
        self.player = player.AirPlayPlayer(self.loop, http)
Пример #5
0
    def test_play_video(self):
        self.usecase.airplay_playback_idle()
        self.usecase.airplay_playback_playing()
        self.usecase.airplay_playback_idle()

        aplay = player.AirPlayPlayer(self.loop,
                                     '127.0.0.1',
                                     port=self.app.port)
        yield from aplay.play_url(STREAM, position=START_POSITION)

        self.assertEqual(self.fake_atv.last_airplay_url, STREAM)
        self.assertEqual(self.fake_atv.last_airplay_start, START_POSITION)
        self.assertEqual(self.no_of_sleeps, 2)  # playback + idle = 3
Пример #6
0
    def __init__(self, loop, session, details):
        """Initialize a new Apple TV."""
        super().__init__()
        self._session = session
        self._daap = DaapSession(session)
        self._requester = DaapRequester(self._daap, details.address,
                                        details.login_id, details.port)

        self._apple_tv = BaseAppleTV(self._requester)
        self._atv_remote = RemoteControlInternal(self._apple_tv)
        self._atv_metadata = MetadataInternal(self._apple_tv)
        self._atv_push_updater = PushUpdaterInternal(loop, self._apple_tv)

        airplay_player = player.AirPlayPlayer(loop, session, details.address)
        self._airplay = AirPlayInternal(airplay_player)
Пример #7
0
    async def test_play_video(self):
        self.usecase.airplay_playback_idle()
        self.usecase.airplay_playback_playing()
        self.usecase.airplay_playback_idle()

        session = ClientSession(loop=self.loop)
        aplay = player.AirPlayPlayer(self.loop,
                                     session,
                                     '127.0.0.1',
                                     port=self.server.port)
        await aplay.play_url(STREAM, position=START_POSITION)

        self.assertEqual(self.fake_device.last_airplay_url, STREAM)
        self.assertEqual(self.fake_device.last_airplay_start, START_POSITION)
        self.assertEqual(self.no_of_sleeps, 2)  # playback + idle = 3

        await session.close()
Пример #8
0
    def __init__(self, loop, session, details):
        """Initialize a new Apple TV."""
        super().__init__()
        self._session = session

        daap_http = HttpSession(
            session, 'http://{0}:{1}/'.format(details.address, details.port))
        self._requester = DaapRequester(daap_http, details.login_id)

        self._apple_tv = BaseAppleTV(self._requester)
        self._atv_remote = RemoteControlInternal(self._apple_tv)
        self._atv_metadata = MetadataInternal(self._apple_tv, daap_http)
        self._atv_push_updater = PushUpdaterInternal(loop, self._apple_tv)

        airplay_player = player.AirPlayPlayer(loop, session, details.address,
                                              details.airplay_port)
        airplay_http = HttpSession(
            session, 'http://{0}:{1}/'.format(details.address,
                                              details.airplay_port))
        self._airplay = AirPlayInternal(airplay_http, airplay_player)
Пример #9
0
def airplay_player_fixture(client_connection):
    yield player.AirPlayPlayer(client_connection)