/// <summary> /// Creates a new form to show download percentage /// </summary> /// <param name="url"></param> private void RunDownload(string url) { if (isValidUrl(url)) { loadThumbNail(url.Split('=')[1]); string dir; string title = GetTitle(url.Split('=')[1]); vidTitle.Text = "Title: " + title; FormStatus childForm = new FormStatus(); ProgressBar progBar = childForm.getProgressBar(); childForm.setTitle(title); if (mp3RadioBtn.Checked) { dir = openFileLocation("mp3"); childForm.Show(); Thread audioThread = new Thread(() => Downloader.startDownloadAudioThread("mp3", url, dir, ref progBar, ref childForm)); audioThread.SetApartmentState(ApartmentState.STA); audioThread.Start(); } else if (mp4RadioBtn.Checked) { dir = openFileLocation("mp4"); childForm.Show(); Thread videoThread = new Thread(() => Downloader.startDownloadVideoThread("mp3", url, dir, ref progBar, ref childForm)); videoThread.SetApartmentState(ApartmentState.STA); videoThread.Start(); } else { dir = openFileLocation("wav"); } } }
/// <summary> /// Creates a new form to show download percentage /// </summary> /// <param name="url"></param> private void RunDownload(string url) { if (isValidUrl(url)) { loadThumbNail(url.Split('=')[1]); string dir; string title = GetTitle(url.Split('=')[1]); vidTitle.Text = "Title: " + title; FormStatus childForm = new FormStatus(); ProgressBar progBar = childForm.getProgressBar(); childForm.setTitle(title); if (mp3RadioBtn.Checked) { dir = openFileLocation("mp3"); childForm.Show(); Thread audioThread = new Thread(() => Downloader.startDownloadAudioThread("mp3", url, dir, ref progBar,ref childForm)); audioThread.SetApartmentState(ApartmentState.STA); audioThread.Start(); } else if (mp4RadioBtn.Checked) { dir = openFileLocation("mp4"); childForm.Show(); Thread videoThread = new Thread(() => Downloader.startDownloadVideoThread("mp3", url, dir, ref progBar,ref childForm)); videoThread.SetApartmentState(ApartmentState.STA); videoThread.Start(); } else { dir = openFileLocation("wav"); } } }