Пример #1
0
        private void Play()
        {
            if (File.Exists(Path.Combine(AudioCache, AudioList[_currentIndex].Id.Value.ToString())))
            {
                PlayFromCache();
                return;
            }

            AudioDownloader.PreDownloaded += Downloader_PreDownloaded;
            AudioDownloader.Downloaded    += Downloader_Downloaded;

            AudioDownloader.Download(Url);
        }
Пример #2
0
        static void Main(string[] args)
        {
            var mp3OutputFolder = "c:/@mp3/";

            var downloader = new AudioDownloader("http://soundcloud.com/skunkfunk/grappig", Guid.NewGuid().ToString(), mp3OutputFolder, false);

            downloader.ProgressDownload += downloader_ProgressDownload;
            downloader.FinishedDownload += downloader_FinishedDownload;
            downloader.Download();


            Console.ReadLine();
        }
Пример #3
0
        private void backgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            AudioDownloader downloader = new AudioDownloader(txturlBox.Text, filename, folder);

            Invoke(new MethodInvoker(delegate
            {
                txtfilenameBox.Text = downloader.OutputName;
            }
                                     ));
            downloader.ProgressDownload += Downloader_ProgressDownload;
            downloader.FinishedDownload += Downloader_FinishedDownload;
            downloader.ErrorDownload    += Downloader_ErrorDownload;
            downloader.Download();
        }
Пример #4
0
        static void Main(string[] args)
        {
            var mp3OutputFolder = Path.Combine(Directory.GetCurrentDirectory(), "Audio");

            var downloader = new AudioDownloader(Path.Combine(Directory.GetCurrentDirectory(), "Binaries"), "https://www.youtube.com/watch?v=enBllfqkMEw", Guid.NewGuid().ToString(), mp3OutputFolder);

            downloader.ProcessObject     = new song();
            downloader.ProgressDownload += downloader_ProgressDownload;
            downloader.FinishedDownload += downloader_FinishedDownload;
            downloader.Download();


            Console.ReadLine();
        }
Пример #5
0
        static void Main(string[] args)
        {
            var mp3OutputFolder = "c:/@mp3/";

            var downloader = new AudioDownloader("https://www.youtube.com/watch?v=clhvCRwUjD4", Guid.NewGuid().ToString(), mp3OutputFolder);

            downloader.ProcessObject     = new song();
            downloader.ProgressDownload += downloader_ProgressDownload;
            downloader.FinishedDownload += downloader_FinishedDownload;
            downloader.Download();


            Console.ReadLine();
        }
Пример #6
0
        public IHttpActionResult streamvideo(string vidid, string title)
        {
            //var mp3OutputFolder = HttpContext.Current.Server.MapPath("/mp3s");
            var mp3OutputFolder = @"C:/Users/Administrator/Desktop/lowdatayt/mp3s/";

            //Models.SearchResult selectedvideo
            Models.SearchResult selectedvideo = new Models.SearchResult()
            {
                vidid = vidid, title = title
            };
            //List<Models.SearchResult> searcheslist
            Boolean alreadydown = false;
            //var di = new DirectoryInfo("C:/Users/Administrator/Desktop/lowdatayt/mp3s");
            var di = new DirectoryInfo("C:/Users/Administrator/Desktop/lowdatayt/mp3s");

            foreach (FileInfo file in di.GetFiles())
            {
                if (selectedvideo.title + ".mp3" == file.Name)
                {
                    alreadydown = true;
                    break;
                }
            }
            if (alreadydown != true)
            {
                var urlToDownload = "https://www.youtube.com/watch?v=" + selectedvideo.vidid;
                var newFilename   = selectedvideo.title;
                //"C:/Users/Administrator/Desktop/lowdatayt/mp3s"
                var downloader = new AudioDownloader(urlToDownload, newFilename, mp3OutputFolder);
                downloader.ProgressDownload += downloader_ProgressDownload;
                downloader.FinishedDownload += downloader_FinishedDownload;
                downloader.Download();

                //var inputFile = new MediaFile { Filename = @"C:/Users/Owen Burns/Desktop/lowdatayt/mp3s/"+selectedvideo.title+".mp3" };
                //var outputFile = new MediaFile { Filename = @"C:/Users/Owen Burns/Desktop/lowdatayt/wavs/" + selectedvideo.title + ".wav" };
                //using (var engine = new Engine())
                //{
                //    engine.Convert(inputFile, outputFile);
                //}
            }
            //"C:/Users/Administrator/Desktop/lowdatayt/mp3s"
            Stream audiostream = File.Open(mp3OutputFolder + selectedvideo.title + ".mp3", FileMode.Open);

            //new code
            MemoryStream memoryStream = new MemoryStream();

            audiostream.CopyTo(memoryStream);
            audiostream.Close();
            var result = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new ByteArrayContent(memoryStream.GetBuffer())
            };

            result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
            {
                FileName = selectedvideo.title + ".mp3"
            };
            result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
            var response = ResponseMessage(result);

            //end new code
            return(response);
        }