从blob url读取数据

时间:2018-01-05 22:03:01

标签: javascript xmlhttprequest blob filereader arraybuffer

我用xhr预加载mp4视频并将其保存到blob网址

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对象) 斑点:http://domain/9d0d26c3-b7ba-4302-9186-d23c6ad53bd5

1 个答案:

答案 0 :(得分:1)

我已做过一些研究,因为我也在这个问题上进行了调查,我认为唯一的可能性是XHR请求。我认为这已经在这里讨论了:How to get a file or blob from an object URL?

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

xhr.responseType = 'arraybuffer';
相关问题