Пример #1
0
        public async void ConnectToChromecastAndLaunchApplicationOnceAndJoinIt()
        {
            var chromecast = await TestHelper.FindChromecast();

            var client = new ChromecastClient();
            var status = await client.ConnectChromecast(chromecast);

            status = await client.LaunchApplicationAsync("B3419EF5");

            var firstLaunchTransportId = status.Applications[0].TransportId;

            status = await client.LaunchApplicationAsync("B3419EF5");

            Assert.Equal(firstLaunchTransportId, status.Applications[0].TransportId);
        }
Пример #2
0
        public async void TestLoadingAndStoppingMedia()
        {
            AutoResetEvent _autoResetEvent = new AutoResetEvent(false);

            var chromecast = await TestHelper.FindChromecast();

            var client = new ChromecastClient();
            await client.ConnectChromecast(chromecast);

            var status = await client.LaunchApplicationAsync("B3419EF5");

            var media = new Media
            {
                ContentUrl = "https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/DesigningForGoogleCast.mp4"
            };

            MediaStatus mediaStatus;

            //We are setting up an event to listen to status change. Because we don't know when the video has started to play
            client.GetChannel <IMediaChannel>().StatusChanged += async(object sender, EventArgs e) =>
            {
                if (client.GetChannel <IMediaChannel>().Status.First().PlayerState == PlayerStateType.Playing)
                {
                    mediaStatus = await client.GetChannel <IMediaChannel>().StopAsync();

                    _autoResetEvent.Set();
                }
            };

            mediaStatus = await client.GetChannel <IMediaChannel>().LoadAsync(media);

            //This checks that within 5000 ms we have loaded video and were able to pause it
            Assert.True(_autoResetEvent.WaitOne(5000));
        }
Пример #3
0
        public async void ConnectToChromecastAndLaunchApplicationAThenLaunchApplicationB()
        {
            var chromecast = await TestHelper.FindChromecast();

            var client = new ChromecastClient();
            var status = await client.ConnectChromecast(chromecast);

            status = await client.LaunchApplicationAsync("A9BCCB7C"); //Youtube

            var firstLaunchTransportId = status.Applications[0].TransportId;
            await client.DisconnectAsync();

            status = await client.ConnectChromecast(chromecast);

            status = await client.LaunchApplicationAsync("B3419EF5"); //My sample Application

            Assert.NotEqual(firstLaunchTransportId, status.Applications[0].TransportId);
        }
Пример #4
0
        public async void ConnectToChromecastAndLaunchApplicationTwiceWithoutJoining()
        {
            var chromecast = await TestHelper.FindChromecast();

            var client = new ChromecastClient();
            var status = await client.ConnectChromecast(chromecast);

            status = await client.LaunchApplicationAsync("B3419EF5");

            var firstLaunchTransportId = status.Applications[0].TransportId;
            await client.DisconnectAsync();

            status = await client.ConnectChromecast(chromecast);

            status = await client.LaunchApplicationAsync("B3419EF5", false);

            Assert.Equal(firstLaunchTransportId, status.Applications[0].TransportId);
        }
Пример #5
0
        public async void ConnectToChromecastAndLaunchApplication()
        {
            var chromecast = await TestHelper.FindChromecast();

            var client = new ChromecastClient();
            var status = await client.ConnectChromecast(chromecast);

            status = await client.LaunchApplicationAsync("B3419EF5");

            Assert.Equal("B3419EF5", status.Applications[0].AppId);
        }
Пример #6
0
        public async void StartApplicationAThenStartBAndLoadMedia()
        {
            var chromecast = await TestHelper.FindChromecast();

            var client = new ChromecastClient();
            await client.ConnectChromecast(chromecast);

            _ = await client.LaunchApplicationAsync("A9BCCB7C");

            await client.DisconnectAsync();

            await client.ConnectChromecast(chromecast);

            _ = await client.LaunchApplicationAsync("B3419EF5");

            var media = new Media
            {
                ContentUrl = "https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/DesigningForGoogleCast.mp4"
            };

            _ = await client.GetChannel <IMediaChannel>().LoadAsync(media);
        }
Пример #7
0
        public async void TestStoppingApplication()
        {
            var chromecast = await TestHelper.FindChromecast();

            var client = new ChromecastClient();
            await client.ConnectChromecast(chromecast);

            var status = await client.LaunchApplicationAsync("B3419EF5");

            status = await client.GetChannel <ReceiverChannel>().StopApplication(status.Applications[0].SessionId);

            Assert.Null(status.Applications);
        }