【发布时间】:2014-09-27 21:03:14
【问题描述】:
我想知道如何从 URI 下载 MP4 视频文件并将其保存到 Windows Phone 8.1 上的媒体库中。 如果它可以在通用应用程序中工作,那就太好了 - 但不是必须的。
我发现此代码可将图像保存到相机胶卷 - 我是否使用 *.mp4 以相同的方式将其保存到视频库?我可以将下载流(不确定这是否有意义)交给该功能吗?
StorageFolder testFolder = await StorageFolder.GetFolderFromPathAsync(@"C:\test");
StorageFile sourceFile = await testFolder.GetFileAsync("TestImage.jpg");
StorageFile destinationFile = await KnownFolders.CameraRoll.CreateFileAsync("MyTestImage.jpg");
using (var sourceStream = await sourceFile.OpenReadAsync())
{
using (var sourceInputStream = sourceStream.GetInputStreamAt(0))
{
using (var destinationStream = await destinationFile.OpenAsync(FileAccessMode.ReadWrite))
{
using (var destinationOutputStream = destinationStream.GetOutputStreamAt(0))
{
await RandomAccessStream.CopyAndCloseAsync(sourceInputStream, destinationStream);
}
}
}
}
【问题讨论】:
标签: c# download windows-phone-8.1 mp4 win-universal-app