// Reproduce the previous video in the playlist.
        void BtnPrevious_TouchUpInside(object sender, EventArgs e)
        {
            int currentIndex = PlayerView.PlaylistIndex;

            // There is no previous video if we reached to the beggining of the list.
            if (currentIndex == 0)
            {
                return;
            }

            // Play previous video in the playlist.
            PlayerView.PreviousVideo();

            // Highlight the current video in Table View.
            var newIndex  = currentIndex - 1;
            var indexPath = NSIndexPath.FromRowSection(newIndex, 0);

            TblVideos.SelectRow(indexPath, true, UITableViewScrollPosition.Top);

            // Enable the next button because maybe we are not longer in the last video of the playlist.
            EnableButton(BtnNext);

            // Disable the Previous button if we reach to the beggining of the playlist.
            if (newIndex == 0)
            {
                DisableButton(BtnPrevious);
            }
        }
Ejemplo n.º 2
0
 public Object GuardarVideos(List <TblVideos> List)
 {
     try
     {
         BDVideosUSAVEntitiesModelSolicitudes Model = new BDVideosUSAVEntitiesModelSolicitudes();
         foreach (var item in List)
         {
             TblVideos Video = Model.TblVideos.FirstOrDefault(v => v.IdYoutube == item.IdYoutube);
             if (Video == null)
             {
                 Model.TblVideos.Add(item);
                 Model.SaveChanges();
             }
             else
             {
                 Video.NombreVideo = item.NombreVideo;
                 Video.Descripcion = item.Descripcion;
                 Video.Photo       = item.Photo;
                 //agregar numero de visitas;
                 Model.SaveChanges();
             }
         }
         return("Videos Guardados Correctamente");
     }
     catch (Exception ex)
     {
         return(ex);
     }
 }
        // Search for videos with user suggestion.
        void SearchForVideos()
        {
            indicatorView.StartAnimating();

            Task.Run(async() =>
            {
                // Get videos that result from user suggestion
                var result = await YouTubeManager.SharedInstance.GetVideos(search);
                videos.AddRange(result);
                InvokeOnMainThread(() =>
                {
                    // Show videos on TableView
                    TblVideos.ReloadData();
                    indicatorView.StopAnimating();
                });
            });
        }
        // Retrives the playlist from YouTube.
        void GetPlaylist()
        {
            // We validate if we are already getting the playlist
            // to avoid a duplicate call.
            if (isPlaylistRequested)
            {
                return;
            }

            isPlaylistRequested = true;

            indicatorView.StartAnimating();

            Task.Run(async() =>
            {
                // Retrives the playlist from YouTube.
                var result = await YouTubeManager.SharedInstance.GetVideos(playlist);
                videos.AddRange(result);
                InvokeOnMainThread(() =>
                {
                    // Show new videos in TableView
                    TblVideos.ReloadData();
                    indicatorView.StopAnimating();
                    isPlaylistRequested = false;

                    // Enable the Player View to start playing videos from Playlist.
                    if (firstLoad)
                    {
                        // Try using this method once, due it reloads the whole view.
                        // If you want to play another video from Playlist,
                        // use PlayVideoAt method.
                        PlayerView.LoadPlaylistById(playlist.Id);
                        firstLoad = false;
                    }
                });
            });
        }