Example #1
0
        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();
                }
            }
        }
        void Play(string id)
        {
            int  startIndex;
            int  startTimeMillis;
            bool autoplay;
            bool lightboxMode;

            int.TryParse(startIndexEditText.Text, out startIndex);
            int.TryParse(startTimeEditText.Text, out startTimeMillis);
            startTimeMillis *= 1000;
            autoplay         = autoplayCheckBox.Checked;
            lightboxMode     = lightboxModeCheckBox.Checked;
            var intent = YouTubeStandalonePlayer.CreateVideoIntent(this, DeveloperKey.Key, id, startTimeMillis, autoplay, lightboxMode);

            StartActivityForResult(intent, RegStartStandalonePlayer);
        }
Example #3
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            //   base.OnActivityResult(requestCode, resultCode, data);

            if (requestCode == StartStandalonePlayerRequest && resultCode != Result.Ok)
            {
                var errorReason = YouTubeStandalonePlayer.GetReturnedInitializationResult(data);
                if (errorReason.IsUserRecoverableError)
                {
                    errorReason.GetErrorDialog(this, 0).Show();
                }
                else
                {
                }
            }
        }
Example #4
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            if (requestCode == StartStandalonePlayerRequest && resultCode != Result.Ok)
            {
                var errorReason = YouTubeStandalonePlayer.GetReturnedInitializationResult(data);
                if (errorReason.IsUserRecoverableError)
                {
                    errorReason.GetErrorDialog(this, 0).Show();
                }
                else
                {
                    var errorMessage = string.Format(GetString(Resource.String.error_player), errorReason);
                    Toast.MakeText(this, errorMessage, ToastLength.Long).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();
                }
            }
        }
 public void OnPlayYoutubeButtonClicked(YoutubeVideoClickEventArgs e)
 {
     try
     {
         if (AppSettings.StartYoutubeAsIntent)
         {
             Intent intent = YouTubeStandalonePlayer.CreateVideoIntent((Activity)MainContext, AppSettings.YoutubeKey, e.NewsFeedClass.Youtube);
             ((Activity)MainContext).StartActivity(intent);
         }
         else
         {
             ((HomeActivity)MainContext).OpenNewsFeedItem(e.NewsFeedClass);
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
 protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
 {
     base.OnActivityResult(requestCode, resultCode, data);
     if (requestCode == REQ_START_STANDALONE_PLAYER && resultCode != Result.Ok)
     {
         YouTubeInitializationResult errorReason =
             YouTubeStandalonePlayer.GetReturnedInitializationResult(data);
         if (errorReason.IsUserRecoverableError)
         {
             errorReason.GetErrorDialog(this, 0).Show();
         }
         else
         {
             string errorMessage =
                 string.Format(GetString(Resource.String.error_player), errorReason.ToString());
             Toast.MakeText(this, errorMessage, ToastLength.Short).Show();
         }
     }
 }
Example #8
0
        private void OnClick(object sender, EventArgs e)
        {
            Intent intent = null;

            if (sender == playVideoButton)
            {
                intent = YouTubeStandalonePlayer.CreateVideoIntent(this, DeveloperKey.Key, VideoId, 0, false, false);// 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();
                }
            }
        }