Commit b211bbac authored by Martin Finkel's avatar Martin Finkel

Start discovery from UI thread

parent dce768ca
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Chromecast"
x:Class="Chromecast.MainPage">
<StackLayout>
<!-- Place new controls here -->
<Label Text="Welcome to Xamarin.Forms!"
<Label Text="Chromecast with libvlc and LibVLCSharp with Xamarin.Forms!"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
</StackLayout>
......
......@@ -12,7 +12,7 @@ namespace Chromecast
{
public partial class MainPage : ContentPage
{
HashSet<RendererItem> _rendererItems = new HashSet<RendererItem>();
readonly HashSet<RendererItem> _rendererItems = new HashSet<RendererItem>();
LibVLC _libVLC;
MediaPlayer _mediaPlayer;
RendererDiscoverer _rendererDiscoverer;
......@@ -22,21 +22,18 @@ namespace Chromecast
InitializeComponent();
}
protected override void OnAppearing()
protected override async void OnAppearing()
{
base.OnAppearing();
Task.Run(async () =>
{
// start chromecast discovery
DiscoverChromecasts();
// start chromecast discovery
DiscoverChromecasts();
// hold on a bit at first to give libvlc time to find the chromecast
await Task.Delay(5000);
// hold on a bit at first to give libvlc time to find the chromecast
await Task.Delay(2000);
// start casting if any renderer found
StartCasting();
});
// start casting if any renderer found
StartCasting();
}
/// <summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment