Esempio n. 1
0
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            string searchQuery = tbxVideoId.Text;

            YouTubeVideo video = new YouTubeVideo(searchQuery);

            lblVideoTitle.Content = video.query;


            System.Uri uri = new System.Uri(video.query);
            wbYouTubePlayer.Source     = uri;
            wbYouTubePlayer.Visibility = System.Windows.Visibility.Visible;
        }
Esempio n. 2
0
        public static void GetVideoInfo(YouTubeVideo searchQuery)
        {
            var videoRequest = ytService.Search.List("snippet");

            videoRequest.Q          = searchQuery.query;
            videoRequest.MaxResults = 20;

            var response = videoRequest.Execute();

            if (response.Items.Count > 0)
            {
                Console.WriteLine(searchQuery.query);
                Random rnd  = new Random();
                int    rand = rnd.Next(0, 19);

                searchQuery.query = "https://www.youtube.com/v/" + response.Items[rand].Id.VideoId;
            }
            else
            {
                searchQuery.query = "No such video.";
            }
        }