/** * Updates the displayed presentation to enable a secondary screen if it has * been selected in the {@link MediaRouter} for the * {@link MediaRouter#ROUTE_TYPE_LIVE_VIDEO} type. If no screen has been * selected by the {@link MediaRouter}, the current screen is disabled. * Otherwise a new {@link SamplePresentation} is initialized and shown on * the secondary screen. */ public void UpdatePresentation() { // Get the selected route for live video var selectedRoute = mMediaRouter.GetSelectedRoute(MediaRouteType.LiveVideo); // Get its Display if a valid route has been selected Display selectedDisplay = null; if (selectedRoute != null) { selectedDisplay = selectedRoute.PresentationDisplay; } /* * Dismiss the current presentation if the display has changed or no new * route has been selected */ if (mPresentation != null && mPresentation.Display != selectedDisplay) { mPresentation.Dismiss(); mPresentation = null; mButton.Enabled = false; mTextStatus.SetText(Resource.String.secondary_notconnected); } /* * Show a new presentation if the previous one has been dismissed and a * route has been selected. */ if (mPresentation == null && selectedDisplay != null) { // Initialise a new Presentation for the Display mPresentation = new SamplePresentation(this, selectedDisplay); mPresentation.DismissEvent += delegate(object sender, EventArgs e) { if (sender == mPresentation) { mPresentation = null; } }; // Try to show the presentation, this might fail if the display has // gone away in the mean time try { mPresentation.Show(); mTextStatus.Text = Resources.GetString(Resource.String.secondary_connected, selectedRoute.Name); mButton.Enabled = true; ShowNextColor(); } catch (WindowManagerInvalidDisplayException ex) { // Couldn't show presentation - display was already removed mPresentation = null; Console.WriteLine(ex); } } }
protected override void OnStop() { base.OnStop(); // Dismiss the presentation when the activity is not visible. if (mPresentation != null) { mPresentation.Dismiss(); mPresentation = null; } }
/** * Updates the displayed presentation to enable a secondary screen if it has * been selected in the {@link MediaRouter} for the * {@link MediaRouter#ROUTE_TYPE_LIVE_VIDEO} type. If no screen has been * selected by the {@link MediaRouter}, the current screen is disabled. * Otherwise a new {@link SamplePresentation} is initialized and shown on * the secondary screen. */ public void UpdatePresentation () { // Get the selected route for live video var selectedRoute = mMediaRouter.GetSelectedRoute (MediaRouteType.LiveVideo); // Get its Display if a valid route has been selected Display selectedDisplay = null; if (selectedRoute != null) selectedDisplay = selectedRoute.PresentationDisplay; /* * Dismiss the current presentation if the display has changed or no new * route has been selected */ if (mPresentation != null && mPresentation.Display != selectedDisplay) { mPresentation.Dismiss (); mPresentation = null; mButton.Enabled = false; mTextStatus.SetText (Resource.String.secondary_notconnected); } /* * Show a new presentation if the previous one has been dismissed and a * route has been selected. */ if (mPresentation == null && selectedDisplay != null) { // Initialise a new Presentation for the Display mPresentation = new SamplePresentation (this, selectedDisplay); mPresentation.DismissEvent += delegate (object sender, EventArgs e) { if (sender == mPresentation) { mPresentation = null; } }; // Try to show the presentation, this might fail if the display has // gone away in the mean time try { mPresentation.Show (); mTextStatus.Text = Resources.GetString (Resource.String.secondary_connected, selectedRoute.Name); mButton.Enabled = true; ShowNextColor (); } catch (WindowManagerInvalidDisplayException ex) { // Couldn't show presentation - display was already removed mPresentation = null; Console.WriteLine (ex); } } }
protected override void OnStop () { base.OnStop (); // Dismiss the presentation when the activity is not visible. if (mPresentation != null) { mPresentation.Dismiss (); mPresentation = null; } }