javascript - 从 blob url 读取数据

标签 javascript xmlhttprequest blob filereader arraybuffer

我已经使用 xhr 预加载了 mp4 视频并将其保存到 blob url

xhr.responseType = 'blob'
// xhr send and get response
var url = URL.createObjectURL(xhr.response);
player.src(url);
// It's worked, it's playable and seekable.
//url = blob url string

现在我需要处理该视频,因此我需要将数据作为 arrayBuffer 获取,当您有 blob url 时如何获取数据(blob 对象) Blob :http://domain/9d0d26c3-b7ba-4302-9186-d23c6ad53bd5

最佳答案

我做了一些研究,因为我也对这个问题感兴趣,我认为唯一的可能性是处理 XHR 请求。我认为这里已经讨论过:How to get a file or blob from an object URL?

如果您有一个 blob,您可以使用 FileReader 将其转换为 ArrayBuffer。但也许以下方法也可行:

xhr.responseType = 'arraybuffer';

关于javascript - 从 blob url 读取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48121910/

相关文章:

javascript - Vue JS this.$set 不更新 react 性

php - mysqli_fetch_assoc to to json 编码数组适用于大多数查询,但不适用于其他查询(尽管查询返回有效结果)

java - 非序列化的 Java 对象可以存储在 mySQL BLob 列中吗?

node.js - 从 Node 读取 pdf 并将其发送到客户端 - 空白页

javascript - 在 Jade 中插入 QML 代码

javascript - 使用 cal-heatmap 显示外部数据时出现问题

javascript - 如何在 FabricJS 上复制/粘贴后保持 IText 可编辑?

c# - 我应该使用哪个 header ? XMLHTTPRequest header 还是 SOAP header ?

javascript - 如何确保FileReader.onload()不刷新页面

javascript - 更新 Blob 名称