如何在窗口8 metro应用程序中保存捕获video文件?

这些是捕获video和保存video的代码。 但它不保存video内容。 它给出了错误信息

JavaScript运行时错误:types不匹配

它来saveVideofunctioncopyAsync方法。

 function captureVideo() { var cam = Windows.Media.Capture.CameraCaptureUI(); cam.videoSettings.allowTrimming = true; cam.videoSettings.format = Windows.Media.Capture.CameraCaptureUIVideoFormat.mp4; cam.videoSettings.maxResolution = Windows.Media.Capture.CameraCaptureUIMaxVideoResolution.standardDefinition; cam.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.video).then(function (file) { if (file) { photoBlobUrl = URL.createObjectURL(file, { oneTimeOnly: true }); var myVideo = document.getElementById("videoId"); myVideo.src = photoBlobUrl; myVideo.play(); } else { } }); } function saveVideo() { var output; var input; var outputStream; var picturesLib = Windows.Storage.KnownFolders.picturesLibrary; picturesLib.createFileAsync("v1.mp4", Windows.Storage.CreationCollisionOption.replaceExisting). then(function(file) { return file.openAsync(Windows.Storage.FileAccessMode.readWrite); }).then(function (stream) { outputStream = stream; output = stream.getOutputStreamAt(0); input = photoBlobUrl; return Windows.Storage.Streams.RandomAccessStream.copyAsync(input, output); }).then(function() { return output.flushAsync(); }).done(function() { input.close(); output.close(); outputStream.close(); }); } 

    StorageFile通常表示已保存的文件。 如果您在拍摄照片后查看StorageFile.Path ,应该是这样的:

     C:\Users\[username]\AppData\Local\Packages\[appname]\TempState\picture003.jpg 

    由于文件已保存,您可以将其移动或复制到不同的位置,如下所示:

     storageFile.moveAsync(Windows.Storage.KnownFolders.picturesLibrary) 

    我希望这有帮助。