DownloadOperation的下载速度问题

时间:2018-07-18 17:30:04

标签: c# uwp httpclient

我在Windows Store上有一个UWP(通用Windows平台)应用程序,这个应用程序不过是我的DownloadOperation类在互联网上的音频/视频下载器。

DownloadOperation的速度非常慢,无论互联网速度如何。

当音频/视频大小小于5MB的平均值时,与文件大小大于30-40 MB的文件相比,下载速度非常慢。但是我的总下载速度是每秒千字节。

我有时会从任务管理器应用程序中下载这种速度,有时会使用我的网络工具。使用HttpClient而不是DownloadOperation进行了尝试,但这对我的情况没有任何影响。

示例代码:

        string source =
            @"https://r1---sn-nv47lnes.googlevideo.com/videoplayback?id=o-AF3ULlrgm4d4p8IDGAzJbL8LUsQ7xOkiD5zYJAiTJGTT&mv=m&mt=1531996353&ms=au,onr&mn=sn-nv47lnes,sn-4g5ednly&mm=31,26&ip=213.14.6.130&pl=22&itag=17&gir=yes&requiressl=yes&initcwndbps=493750&source=youtube&ei=K2lQW4uRNYyRgAOi7rPYDA&lmt=1385600724132940&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,expire&ipbits=0&fexp=23709359,23745105&fvip=1&clen=2754619&dur=268.329&c=WEB&key=yt6&mime=video/3gpp&expire=1532018060&signature=9DB761B443EAB96C65E69BAF1A3923D9E64093C4.4AAF9E5E8CA43E0426D59ECFFF9D84638AA8DD81&ratebypass=yes";
        StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync("omansak.mp4", CreationCollisionOption.GenerateUniqueName);
        BackgroundDownloader backgroundDownloader = new BackgroundDownloader();
        DownloadOperation downloadOperation = backgroundDownloader.CreateDownload(new Uri(source), file);
        await downloadOperation.StartAsync().AsTask(new Progress<DownloadOperation>(operation =>
        {
            BackgroundDownloadProgress currentProgress = downloadOperation.Progress;
            if (currentProgress.TotalBytesToReceive > 0)
            {
                var percent = (int)(currentProgress.BytesReceived * 100 / currentProgress.TotalBytesToReceive);
                button1.Content = percent.ToString() + "-" + currentProgress.TotalBytesToReceive.ToString();
            }

        }));

例如,此下载代码在DownloadOperation花费40秒,但通常平均3秒。 下载文件时如何使用最大网络(即最大互联网速度)?

0 个答案:

没有答案
相关问题