科尔多瓦视频捕捉 - 如何获取blob数据?

时间:2017-08-15 19:25:20

标签: javascript cordova video blob capture

我使用以下代码成功捕获视频流:

        navigator.device.capture.captureVideo(

            //...after recorded vid
            function(mediaFiles) {
                var i, path, len;
                for (i = 0, len = mediaFiles.length; i < len; i += 1) {
                    path = mediaFiles[i].fullPath;
                    app.f7.alert(path);
                }
            },

            //...couldn't get camera
            function() { app.f7.alert('Sorry - your recording device could not be accessed', 'Error'); },

            //...config
            {limit:2}
        );

我无法弄清楚如何获取已保存视频的blob数据。我有文件路径到本地保存的文件,但我需要将数据保存到远程服务器,所以我需要它的数据。

成功回调传递一个封装捕获视频的MediaFile对象,但the docs don't discuss获取其原始数据的任何方法。有谁知道如何实现这一目标?

1 个答案:

答案 0 :(得分:1)

因为 MediaFile 会为您提供有关文件本身的信息,例如

name: The name of the file, without path information. (DOMString)
fullPath: The full path of the file, including the name. (DOMString)
type: The file's mime type (DOMString)
lastModifiedDate: The date and time when the file was last modified. (Date)
size: The size of the file, in bytes. (Number)

MediaFileData 可以访问

codecs: The actual format of the audio and video content. (DOMString)
bitrate: The average bitrate of the content. The value is zero for images. (Number)
height: The height of the image or video in pixels. The value is zero for audio clips. (Number)
width: The width of the image or video in pixels. The value is zero for audio clips. (Number)
duration: The length of the video or sound clip in seconds. The value is zero for images. (Number)

而不是视频的内容。如果您想阅读其内容,请使用MediaFile.fullPath加载它。

要加载视频,请查看可能会让您走上正确轨道的this post