private void UpdateButtons() { MediaRouter.RouteInfo route = mMediaRouter.SelectedRoute; MediaItem item = CheckedMediaItem; if (item != null) { mPlayButton.Enabled = route.SupportsControlRequest(MakePlayIntent(item)); } else { mPlayButton.Enabled = false; } mStatisticsButton.Enabled = route.SupportsControlRequest(MakeStatisticsIntent()); }
private void ShowStatistics() { MediaRouter.RouteInfo route = mMediaRouter.SelectedRoute; Intent intent = MakeStatisticsIntent(); if (route.SupportsControlRequest(intent)) { MediaRouterControlRequestCallback callback = new MediaRouterControlRequestCallback(); callback.OnResultEvent += (data) => { Log.Debug(TAG, "Statistics request succeeded: data=" + data); if (data != null) { int playbackCount = data.GetInt( SampleMediaRouteProvider.DATA_PLAYBACK_COUNT, -1); Toast.MakeText(this, "Total playback count: " + playbackCount, ToastLength.Long).Show(); } else { Toast.MakeText(this, "Statistics query did not return any data", ToastLength.Long).Show(); } }; callback.OnErrorEvent += (error, data) => { Log.Debug(TAG, "Statistics request failed: error=" + error + ", data=" + data); Toast.MakeText(this, "Unable to query statistics, error: " + error, ToastLength.Long).Show(); }; Log.Debug(TAG, "Sent statistics request: intent=" + intent); route.SendControlRequest(intent, callback); } else { Log.Debug(TAG, "Statistics request not supported: intent=" + intent); Toast.MakeText(this, "Statistics not supported.", ToastLength.Long).Show(); } }