js 请求媒体文件, 通过video播放

var xhr = new XMLHttpRequest();
xhr.open("get", "lib/test.rar", true);
xhr.responseType = "blob";
xhr.onload = function() {
    if (this.status == 200) {
        var blob = this.response;
        $('video')[0].src=window.URL.createObjectURL(blob);
    }
};
xhr.send();

关键词  XMLHttpRequest, blob  createObjectURL  

posted @ 2017-11-06 13:56  在路上的少年  阅读(833)  评论(0)    收藏  举报