Skip to content

Instantly share code, notes, and snippets.

@AlexArchive
Created April 15, 2014 13:10
Show Gist options
  • Select an option

  • Save AlexArchive/10731281 to your computer and use it in GitHub Desktop.

Select an option

Save AlexArchive/10731281 to your computer and use it in GitHub Desktop.
public class MainForm : Form
{
private readonly YouTubeDownloadService _service = new YouTubeDownloadService();
public class MainForm()
{
_serivce.DownloadProgressChanged += OnDownloadProgressChanged;
}
private void DownloadVideo(string videoLocation, VideoResolution resoloution, VideoCodec codec)
{
var video = service.FetchVideoInformation(videoLocation);
if (video.IsAvailableWithResoloution(resoloution)) {
MessageBox.Show("Video not available in this resoloution");
return;
}
if (video.IsAvailableWithCodec(codec)) {
MessageBox.Show("Video not available in this resoloution");
return;
}
service.DownloadVideoAsync(
video: video,
path: "C:\Users\Alex\Desktop\video.mp4",
resolution: VideoResolution._240p,
codec: VideoCodec.MP4
);
}
private void OnDownloadProgressChanged(Video video, int progress)
{
var userControl =
videoListView.Controls.OfType<VideoItem>().FirstOrDefault(c => c.VideoLocation == video.VideoLocation);
if (userControl != null)
{
userControl.ProgressBar.Progress = progress;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment