private async void btnCast_Click(object sender, EventArgs e) { string url = txtURL.Text; btnCast.Enabled = false; if (url.Length < 10) { MessageBox.Show("Enter a valid URL"); btnCast.Enabled = true; return; } try { if (_chromecastService.ChromeCastClient.Connected) { await _chromecastService.ChromeCastClient.DisconnectChromecast(); } if (!_chromecastService.ChromeCastClient.Connected) { lblStatus.Text = $"Finding {selectedChromecast.FriendlyName} {selectedChromecast.DeviceUri}"; //relocated selected device? var devices = await ChromecastService.StartLocatingDevices(); if (devices.Count == 0) { System.Console.WriteLine("No chromecasts found"); return; } var firstChromecast = devices.Where(x => x.DeviceUri == selectedChromecast.DeviceUri).First(); //this will find the tv await ChromecastService.ConnectToChromecast(firstChromecast); lblStatus.Text = $"Connected to {firstChromecast.FriendlyName} {firstChromecast.DeviceUri}"; //await connect.ContinueWith(t => { // lblStatus.Text = "Connected?"; // Task openPage = OpenWebPage(url); // openPage.ContinueWith(x => // { // lblStatus.Text = "Web page opened?"; // btnCast.Enabled = true; // }); //}); } } catch (Exception ex) { MessageBox.Show(ex.Message); } btnCast.Enabled = true; }
private async Task LoadChromecasts() { try { LoadingChromecasts = true; var ip = LocalIPAddress().ToString(); var foundChromecasts = await _chromecastService.StartLocatingDevices(ip); foreach (var foundChromecast in foundChromecasts) { Chromecasts.Add(foundChromecast); } LoadingChromecasts = false; AnyChromecast = Chromecasts.Any(); } catch (Exception ex) { LoadingChromecasts = false; AnyChromecast = false; Logger.Error(ex); Messenger.Default.Send( new UnhandledExceptionMessage( new PopcornException(LocalizationProviderHelper.GetLocalizedValue <string>("CastFailed")))); CancelCommand.Execute(null); CloseCommand.Execute(null); } }
public ChromecastTester() { _chromecastService = ChromecastService.Current; var device = _chromecastService.StartLocatingDevices().Result; _chromecastService.ConnectToChromecast(device.First()).Wait(2000); }
private async void btnFind_ClickAsync(object sender, EventArgs e) { lbChromeCasts.DisplayMember = "FriendlyName"; lbChromeCasts.ValueMember = "FriendlyName"; _chromecastService = ChromecastService.Current; btnFind.Enabled = false; //ChromecastService.ChromeCastClient.ApplicationStarted += Client_ApplicationStarted; //ChromecastService.ChromeCastClient.VolumeChanged += _client_VolumeChanged; //ChromecastService.ChromeCastClient.MediaStatusChanged += ChromeCastClient_MediaStatusChanged; ChromecastService.ChromeCastClient.ConnectedChanged += ChromeCastClient_Connected; System.Console.WriteLine("Started locating chromecasts!"); var devices = await _chromecastService.StartLocatingDevices(); if (devices.Count == 0) { btnFind.Enabled = true; return; } lblStatus.Text = "Found chromecasts"; lbChromeCasts.Items.Clear(); foreach (var device in devices) { lbChromeCasts.Items.Add(device); } btnFind.Enabled = true; }
private async void LoadChromecasts() { var foundChromecasts = await _chromecastService.StartLocatingDevices(); foreach (var foundChromecast in foundChromecasts) { Chromecasts.Add(foundChromecast); } }
private static async Task DoStuff() { ChromecastService.ChromeCastClient.ApplicationStarted += Client_ApplicationStarted; ChromecastService.ChromeCastClient.VolumeChanged += _client_VolumeChanged; ChromecastService.ChromeCastClient.MediaStatusChanged += ChromeCastClient_MediaStatusChanged; ChromecastService.ChromeCastClient.ConnectedChanged += ChromeCastClient_Connected; System.Console.WriteLine("Started locating chromecasts!"); var devices = await ChromecastService.StartLocatingDevices(); if (devices.Count == 0) { System.Console.WriteLine("No chromecasts found"); return; } var firstChromecast = devices.First(); System.Console.WriteLine("Device found " + firstChromecast.FriendlyName); ChromecastService.ConnectToChromecast(firstChromecast); }
bool CheckChromecast() { Task.Run(async() => { //chromecasts = await ChromecastService.Current.DeviceLocator.LocateDevicesAsync(); chromecasts = await ChromecastService.StartLocatingDevices(); //chromecasts = await ChromecastService.DeviceLocator.LocateDevicesAsync(); Console.WriteLine("LOG checkCompleted"); chromecastChange(chromecasts.Count > 0); }); return(true); }
protected override async void OnCreate(Bundle bundle) { base.OnCreate(bundle); ChromecastService.ChromeCastClient.ConnectedChanged += ChromeCastClient_ConnectedChanged; ChromecastService.ChromeCastClient.ApplicationStarted += ChromeCastClient_ApplicationStarted; var devices = await ChromecastService.StartLocatingDevices(); ChromecastService.ConnectToChromecast(devices.First()); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button>(Resource.Id.MyButton); button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); }; }
public async void SearchChromecast() { var devices = await _chromecastService.StartLocatingDevices(); Assert.True(devices.Count > 0); }
private async void LoadChromecasts() { Chromecasts = await _chromecastService.StartLocatingDevices(); }
private async Task DoStuff() { c_devices = await ChromecastService.StartLocatingDevices(); updateChromecastList(); }