Exemplo n.º 1
0
        public static async Task <YouTubeController> LaunchYouTube(this ChromeCastClient client)
        {
            client.Channels.Add(new YouTubeChannel(client));
            var controller = new YouTubeController(client);
            await controller.LaunchApplication();

            return(controller);
        }
Exemplo n.º 2
0
        private async void loadChromecast(Uri uri)
        {
            ObservableCollection <Chromecast> chromecasts = await ChromecastService.Current.StartLocatingDevices("192.168.0.108");

            this.chromecast = chromecasts.First((Chromecast c) => { return(c.DeviceUri == uri); });
            if (this.chromecast == null)
            {
                Debug.WriteLine("There was an error connecting to the chromecast.");
                return;
            }

            ChromecastService.Current.ChromeCastClient.ConnectedChanged += async delegate { if (this.controller == null)
                                                                                            {
                                                                                                this.controller = await ChromecastService.Current.ChromeCastClient.LaunchYouTube();
                                                                                            }
            };
            ChromecastService.Current.ChromeCastClient.ApplicationStarted +=
                async delegate {
                while (this.controller == null)
                {
                    await Task.Delay(200);
                }

                await ExecuteOnUiThread(() => {
                    this.enableAll();
                    this.volumeSlider.Value = ChromecastService.Current.ChromeCastClient.Volume.level * 100.0;
                });

                this.applicationStarted = true;
            };
            ChromecastService.Current.ConnectToChromecast(chromecast);
        }