从 blob url 中读取数据

Read data from blob url

我用 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 时如何取回数据(blob 对象)url 斑点: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';