/// <summary> /// Construct a DownloadManager which can add pending downloads, and create threads to start downloading them /// </summary> /// <param name="threadHandler">The main ThreadHandler of the application</param> /// /// <param name="applicationInterface">The frontend interface of the application</param> public DownloadManager(ThreadHandler threadHandler, iGui applicationInterface) { this.threadHandler = threadHandler; this.downloader = new Downloader(threadHandler, applicationInterface, this); this.pendingDownloads = new List <Download>(); this.activeDownloads = new List <Download>(); for (int i = 0; i < 4; i++) { Thread listener = new Thread(WaitForDownload); listener.Name = String.Format("{0} listener created by constructor", i); threadHandler.AddActive(listener); listener.Start(); } //check if downloads folder is there and try to create it if not try { VerifyDownloadDirectory(); } catch { applicationInterface.DisplayMessage("Unable to create downloads directory!"); } }
/// <summary> /// Construct a controller which interfaces with a thread manager, video downloader, and the youtube api to provide the core /// functionalities of the application /// </summary> /// <param name="creator">Normally, "this". Pass in a reference to the form/console that has implemented the iGui interface</param> public MainController(iGui creator) { this.creator = creator; this.threadManager = new ThreadHandler(); this.videoRetriever = new YoutubeGrabber(); this.downloadManager = new DownloadManager(threadManager, creator); this.bitrate = 256; }
/// <summary> /// Verifies that there is a directory set up for downloads /// </summary> /// <param name="threadHandler">The main program's thread manager</param> public Downloader(ThreadHandler threadHandler, iGui callingForm, DownloadManager downloadManager) { this.threadHandler = threadHandler; this.gui = callingForm; this.downloadManager = downloadManager; //check ffmpeg in right place if (!File.Exists(ffmpegPath)) { gui.DisplayMessage("ffmpeg.exe not found in lib folder!"); } }