void LaunchReceiver() { try { var _castListener = new MyCastListener { ApplicationDisconnected = delegate(int statusCode) { Console.WriteLine("Application disconnected - code {0}", statusCode); Teardown(true); } }; var apiOptionsBuilder = new CastClass.CastOptions.Builder(_selectedDevice, _castListener) .Build(); _apiClient = new GoogleApiClientBuilder(this, this, this) .AddApi(CastClass.API, apiOptionsBuilder) .Build(); _apiClient.Connect(); } catch (Exception e) { Console.WriteLine("Failed LaunchReceiver - {0}", e); } }
void Init () { mediaRouter = MediaRouter.GetInstance (this); mediaRouteSelector = new MediaRouteSelector.Builder ().AddControlCategory (MediaControlIntent.CategoryRemotePlayback) //CastMediaControlIntent.CategoryForCast (APP_ID)) .Build(); mediaRouteButton.RouteSelector = mediaRouteSelector; myMediaRouterCallback = new MyMediaRouterCallback { OnRouteSelectedHandler = (router, route) => { Console.WriteLine ("Route Selected: " + route.Name); var device = CastDevice.GetFromBundle(route.Extras); myCastListener = new MyCastListener(); var apiOptionsBuilder = new CastClass.CastOptions.Builder ( device, myCastListener).SetVerboseLoggingEnabled (true); googleApiClient = new GoogleApiClientBuilder(this) .AddApi (CastClass.API, apiOptionsBuilder.Build()) .AddConnectionCallbacks (this) .AddOnConnectionFailedListener (this) .Build (); googleApiClient.Connect(); }, OnRouteUnselectedHandler = (router, route) => { Console.WriteLine ("Route Unselected: " + route.Name); }, RouteCountChangedHandler = newCount => { mediaRouteButton.Visibility = newCount > 0 ? ViewStates.Visible : ViewStates.Gone; } }; mediaRouter.AddCallback(mediaRouteSelector, myMediaRouterCallback, MediaRouter.CallbackFlagRequestDiscovery); }
void Init() { mediaRouter = MediaRouter.GetInstance(this); mediaRouteSelector = new MediaRouteSelector.Builder().AddControlCategory(MediaControlIntent.CategoryRemotePlayback) //CastMediaControlIntent.CategoryForCast (APP_ID)) .Build(); mediaRouteButton.RouteSelector = mediaRouteSelector; myMediaRouterCallback = new MyMediaRouterCallback { OnRouteSelectedHandler = (router, route) => { Console.WriteLine("Route Selected: " + route.Name); var device = CastDevice.GetFromBundle(route.Extras); myCastListener = new MyCastListener(); var apiOptionsBuilder = new CastClass.CastOptions.Builder( device, myCastListener).SetVerboseLoggingEnabled(true); googleApiClient = new GoogleApiClientBuilder(this) .AddApi(CastClass.API, apiOptionsBuilder.Build()) .AddConnectionCallbacks(this) .AddOnConnectionFailedListener(this) .Build(); googleApiClient.Connect(); }, OnRouteUnselectedHandler = (router, route) => { Console.WriteLine("Route Unselected: " + route.Name); }, RouteCountChangedHandler = newCount => { mediaRouteButton.Visibility = newCount > 0 ? ViewStates.Visible : ViewStates.Gone; } }; mediaRouter.AddCallback(mediaRouteSelector, myMediaRouterCallback, MediaRouter.CallbackFlagRequestDiscovery); }
void LaunchReceiver() { try { var _castListener = new MyCastListener { ApplicationDisconnected = delegate (int statusCode) { Console.WriteLine ("Application disconnected - code {0}", statusCode); Teardown(true); } }; var apiOptionsBuilder = new CastClass.CastOptions.Builder(_selectedDevice, _castListener) .Build(); _apiClient = new GoogleApiClientBuilder(this, this, this) .AddApi (CastClass.API, apiOptionsBuilder) .Build(); _apiClient.Connect(); } catch (Exception e) { Console.WriteLine ("Failed LaunchReceiver - {0}", e); } }