private async void LoadVideos(string userId) { var muchos = await _ytManager.GetChannelIdAsync(userId); var filmiki = await _ytManager.GetVideosFromChannelAsync(muchos); // New colletion YtVideos.Clear(); List <YTVideo> xx = new List <YTVideo>(); foreach (SearchResult searchResult in filmiki) { var tmpobj = new YTVideo() { videoId = searchResult.Id.VideoId, channelId = searchResult.Snippet.ChannelId, publishDdate = searchResult.Snippet.PublishedAt ?? new DateTime(1900, 1, 1), title = searchResult.Snippet.Title, thumbnail = searchResult.Snippet.Thumbnails.Default__?.Url ?? "empty" }; YtVideos.Add(tmpobj); } }
private List <YTVideo> ProcessSearchResults(IList <SearchResult> searchResults) { List <YTVideo> templist = new List <YTVideo>(); // Add each result to the appropriate list, and then display the lists of // matching videos, channels, and playlists. foreach (var searchResult in searchResults) { switch (searchResult.Id.Kind) { case "youtube#video": YTVideo tmpobj = new YTVideo() { VideoId = searchResult.Id.VideoId, ChannelId = searchResult.Id.ChannelId, Author = searchResult.Snippet.ChannelTitle, Provider = "youtube", PublishedAt = searchResult.Snippet.PublishedAt ?? new DateTime(1900, 1, 1), Title = searchResult.Snippet.Title, Thumbnails = new List <YTThumbnail>() { new YTThumbnail() { size = "Default", url = searchResult.Snippet.Thumbnails.Default__?.Url ?? "empty" }, new YTThumbnail() { size = "Medium", url = searchResult.Snippet.Thumbnails.Medium?.Url ?? "empty" }, new YTThumbnail() { size = "High", url = searchResult.Snippet.Thumbnails.High?.Url ?? "empty" }, new YTThumbnail() { size = "Maxres", url = searchResult.Snippet.Thumbnails.Maxres?.Url ?? "empty" }, new YTThumbnail() { size = "Standard", url = searchResult.Snippet.Thumbnails.Standard?.Url ?? "empty" } } }; // Add video object to list templist.Add(tmpobj); break; } } return(templist); }
private void ListViewItem_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) { YTVideo video = (YTVideo)YoutubeSearchDisplay.SelectedItem; if (video == null) { return; } Process.Start(video.URL); }
private void VideoIdChangedHandler(object sender, EventBusArgs busargs) { try { YTVideo ytVideo = (YTVideo)busargs.Item; //xxx.ExecuteScriptAsync("XloadVideoById", ytVideo.videoId); } catch (Exception ex) { var cosik = ""; } }
private void OnValidatedLink(object sender, RunWorkerCompletedEventArgs eventargs) { _isValidated = _validateLinkService.Validated; if (_isValidated) { _links.Add(_singleLink); _pasteCoreService.getVideoData(_singleLink); _video = _pasteCoreService.video; Video = _video; _eventAggregator.Publish(new VideoAddedEventArgs(Video), action => { Task.Factory.StartNew(action); }); } }
private async void LoadVideos(string userId, string channelId) { List <SearchResult> filmiki; var muchos = await _ytManager.GetChannelIdForUserAsync(userId); if (!ReferenceEquals(muchos, null)) { filmiki = await _ytManager.GetVideosFromChannelAsync(muchos); } else { filmiki = await _ytManager.GetVideosFromChannelAsync(channelId); } if (ReferenceEquals(filmiki, null)) { return; } // New colletion YtVideos.Clear(); List <YTVideo> xx = new List <YTVideo>(); Random rnd = new Random(); foreach (SearchResult searchResult in filmiki) { var tmpobj = new YTVideo() { videoId = searchResult.Id.VideoId, channelId = searchResult.Snippet.ChannelId, publishDdate = searchResult.Snippet.PublishedAt ?? new DateTime(1900, 1, 1), title = searchResult.Snippet.Title, thumbnail = searchResult.Snippet.Thumbnails.Default__?.Url ?? "empty", description = searchResult.Snippet.Description, rating = rnd.Next(0, 5), // creates a number between 1 and 6 isAvailableOffline = true, category = "default" }; YtVideos.Add(tmpobj); } }
private async Task LoadDataCollection() { var youtubeService = new YouTubeService(new BaseClientService.Initializer() { ApiKey = "AIzaSyB1OOSpTREs85WUMvIgJvLTZKye4BVsoFU", ApplicationName = this.GetType().ToString() }); var searchListRequest = youtubeService.Search.List("snippet"); searchListRequest.Q = YoutubeSearchBar_Textbox.Text; searchListRequest.MaxResults = 50; // Call the search.list method to retrieve results matching the specified query term. var searchListResponse = await searchListRequest.ExecuteAsync(); videos = new List <YTVideo>(); foreach (var searchResult in searchListResponse.Items) { switch (searchResult.Id.Kind) { case "youtube#video": YTVideo video = new YTVideo(); video.Title = searchResult.Snippet.Title; video.Author = searchResult.Snippet.ChannelTitle; video.URL = $"https://www.youtube.com/watch?v={searchResult.Id.VideoId}"; byte[] imageBytes = new WebClient().DownloadData(searchResult.Snippet.Thumbnails.Default__.Url); using (MemoryStream ms = new MemoryStream(imageBytes)) { var imageSource = new BitmapImage(); imageSource.BeginInit(); imageSource.StreamSource = ms; imageSource.EndInit(); // Assign the Source property of your image video.Thumbnail = new Image { Source = imageSource }; } videos.Add(video); break; } } }
public String GetHtmlContent(string searchText, String data, String sense, Object source, Dictionary <String, String> uniqueLinks) { searchText = HttpUtility.UrlDecode(searchText); if (sense == "movie") { searchText += " trailer"; } data = "1|10"; if (source == null) { source = this.GetSource(searchText, data); } if (source == null) { throw new ArgumentNullException("Source is NULL"); } this.videos = source as List <YTVideo>; if (source == null) { throw new InvalidCastException("Source is not of correct type"); } bool hasData = false; String html = String.Empty; html += " <td id=\"tdYouTube\" style=\"width: 100%;vertical-align: top\">"; html += " <table style=\"width: 100%\" cellpadding=\"0\" cellspacing=\"0\">"; html += " <tr>"; html += " <td style=\"border-bottom: dotted 1px Silver; width: 100%; color: Black; font-family: Calibri;font-size: 16px;\">"; //html += " <b>Y</b>outube "; html += " <a href=\"http://youtube.com\" style=\"font-size:small;color:green;text-decoration:none;font-family:Calibri\">"; html += " source: youtube.com"; html += " </a>"; html += " </td>"; html += " </tr>"; for (int index = 0; index < 1; index++)//this.videos.Count { hasData = true; YTVideo video = this.videos[index]; html += " <tr>"; html += " <td style=\"padding-bottom: 3px;\">"; if (index == 0) { html += String.Format("<object width=\"100%\" height=\"150px\"><param name=\"movie\" value=\"http://www.youtube.com/v/{0}&hl=en&fs=1&\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/{0}&hl=en&fs=1&\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"100%\" height=\"150px\"></embed></object><br />", video.Id); } html += " <a target=\"_blank\" href=\"" + video.UrlLink + "\" style=\"color:Blue;font-family: Calibri; font-size: medium\">"; html += video.Title; html += " </a><br />"; html += " <span style=\"font-family: Calibri; font-size: small\">"; //html += video.Description; html += " </span>"; html += " </td>"; html += " </tr>"; hasData = true; } // html += " <tr><td style=\"height: 3px\"> </td></tr>"; html += " </table>"; html += " </td>"; return(hasData ? html : String.Empty); }
public VideoAddedEventArgs(YTVideo video) { Video = video; }