视频标签的 XMLHttpRequest? [英] XMLHttpRequest for Video Tag?

查看:31
本文介绍了视频标签的 XMLHttpRequest?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有人尝试使用来自 XHR 请求的二进制数据作为视频文件的内容?

Has anyone tried using binary data from an XHR request to be the content of a video file?

推荐答案

在支持 Blob 的浏览器中,您可以执行以下操作并使用 generate,给定 req 是一个 新的 XMLHttpRequest:

In Blob-supporting browsers, you can do the following and use a generate, given req is a new XMLHttpRequest:

var some_video_element = ...;
req.onload = function () {
    var blob_uri = URL.createObjectURL(this.response);
    some_video_element.appendChild(document.createElement("source"))
        .src = blob_uri;
};
req.responseType = "blob";
req.open(...);
req.send(null);

请参阅 Google Chrome 的此解决方法,直到responseType = "blob" 已实现.

Refer to this workaround for Google Chrome until responseType = "blob" is implemented.

这篇关于视频标签的 XMLHttpRequest?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆