uwp如何下载对应的网上链接的文件啊
uwp吧
全部回复
仅看楼主
level 2
梁毓颖 楼主
链接:http://ws.stream.qqmusic.qq.com/C100003HIv074OhPZt.m4a?fromtag=0&guid=126548448
代码:
string v = "http://ws.stream.qqmusic.qq.com/C100003HIv074OhPZt.m4a?fromtag=0&guid=126548448"
var coverpic_file = await KnownFolders.MusicLibrary.CreateFileAsync("smg.m4a", CreationCollisionOption.FailIfExists);
var httpWebRequest = HttpWebRequest.CreateHttp(v);
HttpWebResponse response = (HttpWebResponse)await httpWebRequest.GetResponseAsync();
Stream resStream = response.GetResponseStream();
using (var stream = await coverpic_file.OpenAsync(FileAccessMode.ReadWrite))
{
await resStream.CopyToAsync(stream.AsStreamForWrite());
}
response.Dispose();
我发现用这个链接打开的网址不会直接发送音频文件啊,所以生成的文件是无效的。如图:
有没有大佬知道该怎么来获取这个文件吗?
2018年05月14日 15点05分 1
level 2
梁毓颖 楼主
Uri source = new Uri(v);
var file = await KnownFolders.MusicLibrary.CreateFileAsync("smg.m4a", CreationCollisionOption.FailIfExists);
BackgroundDownloader downloader = new BackgroundDownloader();
DownloadOperation download = downloader.CreateDownload(source, file);
await download.StartAsync();
好吧,我找到解决方法了
2018年05月14日 16点05分 2
level 9
你是要搞企鹅音乐的第三方播放器么[滑稽]
2018年05月20日 01点05分 3
差不多吧,UWP的期中项目我选了音乐播放器,用企鹅的链接,用网易云的外表[滑稽]
2018年05月25日 04点05分
@梁毓颖 我也想弄一个,用wpf来做[滑稽]
2018年05月25日 05点05分
1