Ejemplo n.º 1
0
        private async void FillListView()
        {
            await Task.Run(new Action(() =>
            {
                UpdateStatus("Loading download information, please wait ...");

                foreach (VideoOnlyStreamInfo info in video.VideoSettings.VideoOnlyStreamInfo.OrderByDescending(a => a.VideoQuality.MaxHeight))
                {
                    Core.Utils.YouTubeVideoViewItem item = core.GenerateYouTubeVideoViewItem(video);

                    item.DownloadSettings.DownloadStreamInfo = info;
                    item.DownloadSettings.DownloadStreamType = 1;

                    item.Text = $"{info.VideoQuality.Label} ({info.VideoResolution.Width} x {info.VideoResolution.Height})";
                    item.SubItems.Add(info.VideoCodec);
                    item.SubItems.Add($"{Math.Round(info.Size.MegaBytes, 2)} MB");
                    item.SubItems.Add(info.Container.Name);

                    item.Group = downloadTypesListView.Groups[0];

                    Invoke(new Action(() => { downloadTypesListView.Items.Add(item); }));
                }

                foreach (AudioOnlyStreamInfo info in video.VideoSettings.AudioOnlyStreamInfo.OrderByDescending(a => a.Bitrate.KiloBitsPerSecond))
                {
                    Core.Utils.YouTubeVideoViewItem item = core.GenerateYouTubeVideoViewItem(video);

                    item.DownloadSettings.DownloadStreamInfo = info;
                    item.DownloadSettings.DownloadStreamType = 2;

                    item.Text = $"{Math.Round(info.Bitrate.KiloBitsPerSecond, 3)} kb/s";
                    item.SubItems.Add(info.AudioCodec);
                    item.SubItems.Add($"{Math.Round(info.Size.MegaBytes, 2)} MB");
                    item.SubItems.Add(info.Container.Name);

                    item.Group = downloadTypesListView.Groups[1];

                    Invoke(new Action(() => { downloadTypesListView.Items.Add(item); }));
                }
            }));

            UpdateStatus("Loaded all information.");
        }