Exemplo n.º 1
0
 private void enableButtons(bool enabled)
 {
     downloadMP3Button.Enabled   = enabled;
     downloadVideoButton.Enabled = enabled;
     buttonGetTitle.Enabled      = enabled;
     progressIndicator.updateProgress("", 0);
 }
Exemplo n.º 2
0
        public async Task <bool> convertMp4ToMp3(string mp4FilePath, string outputFilePath)
        {
            bool success = false;

            try
            {
                IConversion conversion = Conversion.ExtractAudio(mp4FilePath, outputFilePath);
                conversion.OnProgress += (sender, args) =>
                {
                    int percent = (int)(Math.Round(args.Duration.TotalSeconds / args.TotalLength.TotalSeconds, 2) * 100);
                    indicator.updateProgress("Converting to MP3: ", percent);
                };
                IConversionResult result = await conversion.Start();

                File.Delete(mp4FilePath);
                indicator.updateProgress("Conversion Done! ", 100);
                success = true;
            }
            catch (Xabe.FFmpeg.Exceptions.ConversionException e)
            {
                MessageBox.Show("An error has occurred at: " + outputFilePath + "\n" + e.Message);
            }
            return(success);
        }
        public async Task <string> getYouTubeMediaTitle(string url)
        {
            try
            {
                indicator.updateProgress("Getting video data: ", 0);
                var client = new YoutubeClient();
                var video  = await client.Videos.GetAsync(url);

                var title = video.Title.ToString();
                title = replaceInvalidChars(title);
                indicator.updateProgress("Video data retrieved: ", 100);
                return(title);
            }
            catch (Exception e)
            {
                MessageBox.Show("An error has occurred: " + e.Message);
                indicator.updateProgress("", 0);
            }
            return("");
        }