javascript - Cordova 视频捕获 - 如何获取 blob 数据?

标签 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获取其原始数据的任何方式。有人知道如何实现这一点吗?

最佳答案

因为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这可能会让您走上正轨。

关于javascript - Cordova 视频捕获 - 如何获取 blob 数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45700081/

相关文章:

将图像和音频加入结果视频

javascript - 尝试循环 HTML5 视频数组

PHP - 优化加载过程

java - 获取Javascript标签内容

javascript - 使用 Cordova 的 Android 本地通知插件

ios - UIWebView 中 WebSQL/SQLite 数据库的最大大小(phonegap)

ios - 手机间隙 : cannot open iOS 6 native maps application

html - 我应该在我的 HTML5 视频源标签中为 MP4 指定什么编解码器?

javascript - CanActivate,动态 url 解析器(多个嵌套动态段)

javascript - 如何在 JavaScript 中不按 Enter 来消除警报