private void VideoData(string link, bool playlist = false) { var video = youTube.GetAllVideos(link); // gets a Video object with info about the video var resolutions = video.Where(j => j.AdaptiveKind == AdaptiveKind.Video && j.Format == VideoFormat.Mp4).Select(j => j.Resolution); var bitRates = video.Where(j => j.AdaptiveKind == AdaptiveKind.Audio).Select(j => j.AudioBitrate); foreach (var val in resolutions) { Quality.Invoke((MethodInvoker)(() => Quality.Items.Add(val))); } foreach (var val in bitRates) { AudioQuality.Invoke((MethodInvoker)(() => AudioQuality.Items.Add(val))); } if (Quality.Items.Count > 0) { Quality.Invoke((MethodInvoker)(() => Quality.Sorted = true)); Quality.Invoke((MethodInvoker)(() => Quality.SelectedIndex = 0)); AudioQuality.Invoke((MethodInvoker)(() => AudioQuality.Sorted = true)); AudioQuality.Invoke((MethodInvoker)(() => AudioQuality.SelectedIndex = 0)); Vid.Invoke((MethodInvoker)(() => Vid.Enabled = true)); VidTitle.Invoke((MethodInvoker)(() => VidTitle.Text = video.ToList()[0].Title)); } if (playlist) { Status.Text = listVidsIds.Count + " Videos"; } else { Status.Text = "Single Video"; } }
private void disableVid() { Quality.Invoke((MethodInvoker)(() => Quality.Items.Clear())); AudioQuality.Invoke((MethodInvoker)(() => AudioQuality.Items.Clear())); Vid.Invoke((MethodInvoker)(() => Vid.Enabled = false)); Vid.Invoke((MethodInvoker)(() => VidTitle.Text = "")); selectedAudioQuality = ""; selectedVideoQality = ""; }