public async void loadDevicesAsync() { this.chromecastCounter = 0; List <ChromecastItem> items = new List <ChromecastItem>(); Debug.WriteLine("Searching for cast devices..."); ObservableCollection <Chromecast> chromecasts = await ChromecastService.Current.StartLocatingDevices("192.168.0.108"); Debug.WriteLine("Found " + chromecasts.Count + " elements"); foreach (Chromecast chromecast in chromecasts) { ChromecastItem item = new ChromecastItem() { DeviceName = chromecast.FriendlyName, DeviceUri = chromecast.DeviceUri, DeviceId = "dev" + this.chromecastCounter++, Device = chromecast }; items.Add(item); Debug.WriteLine("Added cast device " + chromecast.FriendlyName); Debug.WriteLine("\tDevice URI: " + chromecast.DeviceUri); Debug.WriteLine("\tDevice ID: " + item.DeviceId); } this.deviceList.ItemsSource = items; this.spinner.IsActive = false; }
private void deviceList_SelectionChanged(object sender, SelectionChangedEventArgs e) { ChromecastItem item = (ChromecastItem)this.deviceList.SelectedItem; Debug.WriteLine("Device URI to send: " + item.DeviceUri); Debug.WriteLine("\tFriendly name: " + item.DeviceName); this.Frame.Navigate(typeof(MediaControlPage), item.DeviceUri); }