mp3文件下载不完整 [英] Incomplete mp3 File Downloads

查看:145
本文介绍了mp3文件下载不完整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:
我可以访问必须登录的网站并且该网站使用表单身份验证.一旦我获得身份验证,就可以下载想要的歌曲.但是,在我可以下载歌曲之前,必须先填写此调查表.我只有几个问题,但很烦人,主要是因为我正在下载的歌曲尚未听到.所以我开始写一个应用程序.问题是我下载的音乐.我编写了程序,并且可以正常工作,但最终结果不错.每个音乐文件中都有某种可听见的伪像.
请听这两首歌的开头,以便在此处

The Problem:
I have access to a website where I must log on and the site uses forms authentication.Once I am authenticated, I can download a song I want. But, before I can download a song, I must first fill out this survey. I it only a few questions but it is very irritating, mostly because the songs I am downloading, I have not yet heard. So I started to write an app. The problem is the music I download. I wrote the program and it works, but the end results sux. Every music file has some type of audible artifact in it.
Please listen to the beginning of these two songs to get an idea here and here.

Ok here is the code. Redactions are only company names and ips. I believe it has something to do with encoding. Please Help. Now for the code:

try
{
    webRequest = (HttpWebRequest)HttpWebRequest.Create(downloadWebsiteString + currentFileInt.ToString());
    webRequest.CookieContainer = cookieContainer;
    webRequest.Credentials = CredentialCache.DefaultCredentials;
    webResponse = (HttpWebResponse)webRequest.GetResponse();
    fileSizeInt = (int)webResponse.ContentLength;
    this.Invoke(new UpdateOverallProgressCallback(this.UpdateOverallProgress), new object[] { currentFileInt });
    if (webResponse.Headers["Content-Disposition"].Contains(@"filename=""""") == true)
    {
        webResponse.Close();
        webRequest = null;
        this.Invoke(new UpdateFileFinishCallback(this.UpdateFileFinish), new object[] { currentFileInt, false });
    }
    else
    {
        contentDisposition = new ContentDisposition(webResponse.Headers["Content-Disposition"]);
        receiveStream = webResponse.GetResponseStream();
        inputStreamReader = new StreamReader(receiveStream, System.Text.Encoding.Default);
        bufferChar = new Char[2048];
        bytesReadInt = inputStreamReader.Read(bufferChar, 0, bufferChar.Length);
        bytesReadRunningInt = bytesReadInt;
        fileStream = new FileStream(folderString + "\\" + currentFileInt.ToString() + "_" + contentDisposition.FileName, FileMode.Create);
        binaryWriter = new BinaryWriter(fileStream, System.Text.Encoding.Default);
        while (bytesReadInt > 0)
        {
            binaryWriter.Write(bufferChar);
            this.Invoke(new UpdateFileProgressCallback(this.UpdateFileProgress), new object[] { bytesReadRunningInt, fileSizeInt });
            bytesReadInt = inputStreamReader.Read(bufferChar, 0, bufferChar.Length);
            bytesReadRunningInt += bytesReadInt;
        }
    }
}


问题必须出在缓冲区大小或字符编码上.就像我说的那样,所有其他功能都运行良好.有什么想法吗.
<罢工>不要对我的风格ash之以鼻,否则我应该使用它.我可以使用它(减去工件)来工作,请帮我解决这些问题.
感谢所有人.


The problem has to be with the buffer size or the character encoding. Like I said, all other features work well enough. Any thoughts.
P.S. Don''t bash me about my style of this or I should have used that. I got it to work using this (minus the artifacts), just help me with those please.
Thanks to all.

推荐答案

看看以下链接:

如何进行同步和异步Web下载 [
Have a look at this link:

How to do Synchronous and Asynchronous web downloads[^]

Good luck!


这篇关于mp3文件下载不完整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆