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); }
private void lbChromeCasts_SelectedIndexChanged(object sender, EventArgs e) { var box = sender as ListBox; selectedChromecast = (Chromecast)box.SelectedItem; lblChromeCastName.Text = selectedChromecast.FriendlyName; txtURL.Enabled = true; }
public CastApp(ChromecastOptions chromecast) { _chromecast = new Chromecast { DeviceUri = new Uri("https://" + chromecast.Ip), FriendlyName = chromecast.Name }; ChromecastService.ChromeCastClient.ApplicationStarted += Client_ApplicationStarted; //ChromecastService.ChromeCastClient.VolumeChanged += _client_VolumeChanged; ChromecastService.ChromeCastClient.MediaStatusChanged += ChromeCastClient_MediaStatusChanged; ChromecastService.ChromeCastClient.ConnectedChanged += ChromeCastClient_Connected; }
private static async Task AsyncBabyAsyn() { ChromecastService.ChromeCastClient.ApplicationStarted += Client_ApplicationStarted; ChromecastService.ChromeCastClient.VolumeChanged += _client_VolumeChanged; ChromecastService.ChromeCastClient.MediaStatusChanged += ChromeCastClient_MediaStatusChanged; ChromecastService.ChromeCastClient.ConnectedChanged += ChromeCastClient_Connected; var chromecast = new Chromecast { DeviceUri = new Uri("http://192.168.178.158:8009"), FriendlyName = "Google Home" }; ChromecastService.ConnectToChromecast(chromecast); }
private async void Cast(object sender, EventArgs e) { string action = await DisplayActionSheet("Select device to cast to", "Cancel", null, chromecastWrapper.GetChromecastOptions()); if (action == "Cancel" || action == null) { return; } Chromecast chromecast = chromecastWrapper.SelectChromecast(action); await chromecastWrapper.LoadMedia(sourceUrl, videoPlayer.Position.TotalSeconds); await chromecastWrapper.ChromecastService.ConnectToChromecast(chromecast); }
public async Task <ObservableCollection <Chromecast> > LocateDevicesAsync() { using (var deviceLocator = new SsdpDeviceLocator()) { var foundDevices = await deviceLocator.SearchAsync("urn:dial-multiscreen-org:device:dial:1", TimeSpan.FromMilliseconds(5000)); foreach (var foundDevice in foundDevices) { var fullDevice = await foundDevice.GetDeviceInfo(); Uri myUri; Uri.TryCreate("https://" + foundDevice.DescriptionLocation.Host, UriKind.Absolute, out myUri); var chromecast = new Chromecast { DeviceUri = myUri, FriendlyName = fullDevice.FriendlyName }; DiscoveredDevices.Add(chromecast); } } return(DiscoveredDevices); }
public async Task ConnectToChromecast(Chromecast chromecast) { ConnectedChromecast = chromecast; await ChromeCastClient.ConnectChromecast(chromecast.DeviceUri); }
public void ConnectToChromecast(Chromecast chromecast) { ConnectedChromecast = chromecast; ChromeCastClient.ConnectChromecast(chromecast.DeviceUri); }