Created
April 15, 2014 13:10
-
-
Save AlexArchive/10731281 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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