private void OnClick(object sender, EventArgs e) { int startIndex = ParseInt(startIndexEditText.Text, 0); int startTimeMillis = ParseInt(startTimeEditText.Text, 0) * 1000; bool autoplay = autoplayCheckBox.Checked; bool lightboxMode = lightboxModeCheckBox.Checked; Intent intent = null; if (sender == playVideoButton) { intent = YouTubeStandalonePlayer.CreateVideoIntent(this, DeveloperKey.Key, VideoId, startTimeMillis, autoplay, lightboxMode); } else if (sender == playPlaylistButton) { intent = YouTubeStandalonePlayer.CreatePlaylistIntent(this, DeveloperKey.Key, PlaylistId, startIndex, startTimeMillis, autoplay, lightboxMode); } else if (sender == playVideoListButton) { intent = YouTubeStandalonePlayer.CreateVideosIntent(this, DeveloperKey.Key, VideoIds, startIndex, startTimeMillis, autoplay, lightboxMode); } if (intent != null) { if (CanResolveIntent(intent)) { StartActivityForResult(intent, StartStandalonePlayerRequest); } else { // Could not resolve the intent - must need to install or update the YouTube API service. YouTubeInitializationResult.ServiceMissing.GetErrorDialog(this, ResolveServiceMissingRequest).Show(); } } }
public void OnClick(View v) { int startIndex = 0; Int32.TryParse(startIndexEditText.Text.ToString(), out startIndex); int startTimeMillis = 0; Int32.TryParse(startTimeEditText.Text.ToString(), out startTimeMillis); startTimeMillis *= 1000; bool autoplay = autoplayCheckBox.Checked; bool lightboxMode = lightboxModeCheckBox.Checked; Intent intent = null; if (v == playVideoButton) { intent = YouTubeStandalonePlayer.CreateVideoIntent( this, DeveloperKey.DEVELOPER_KEY, VIDEO_ID, startTimeMillis, autoplay, lightboxMode); } else if (v == playPlaylistButton) { intent = YouTubeStandalonePlayer.CreatePlaylistIntent(this, DeveloperKey.DEVELOPER_KEY, PLAYLIST_ID, startIndex, startTimeMillis, autoplay, lightboxMode); } else if (v == playVideoListButton) { intent = YouTubeStandalonePlayer.CreateVideosIntent(this, DeveloperKey.DEVELOPER_KEY, VIDEO_IDS, startIndex, startTimeMillis, autoplay, lightboxMode); } if (intent != null) { if (CanResolveIntent(intent)) { StartActivityForResult(intent, REQ_START_STANDALONE_PLAYER); } else { // Could not resolve the intent - must need to install or update the YouTube API service. YouTubeInitializationResult.ServiceMissing .GetErrorDialog(this, REQ_RESOLVE_SERVICE_MISSING).Show(); } } }