XMLHttpRequest for Video Tag?
Ha开发者_开发技巧s anyone tried using binary data from an XHR request to be the content of a video file?
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);
Refer to this workaround for Google Chrome until responseType = "blob"
is implemented.
精彩评论