当前位置: 移动技术网 > IT编程>开发语言>JavaScript > javascript实现blob加密视频源地址

javascript实现blob加密视频源地址

2019年08月07日  | 移动技术网IT编程  | 我要评论

一、html代码:

<video id="my-video" class="video-js" playsinline controls preload="auto" controlslist="nodownload" controlslist="nofullscreen" width="100%" height="240"
           poster="upload/moviepic/2019-08-02/1564739500xyzp.png" data-setup="{}">
        <source src="" type="video/mp4">
        <source src="" type="video/ogg">
        <source src="" type="video/webm">
        <p class="vjs-no-js"> to view this video please enable javascript, and consider upgrading to a web browser that <a href="http://videojs.com/html5-video-support/" target="_blank">supports html5 video</a> </p>
    </video>

二、javascript代码:

 <script type="text/javascript">
    var video = document.getelementbyid("my-video");
    window.url = window.url || window.webkiturl;
    var xhr = new xmlhttprequest();
    var play_url = 'test.mp4';
    xhr.open("get", play_url, true);
    xhr.responsetype = "blob";
    xhr.onload = function() {
    if (this.status == 200) {
    var blob = this.response;
    console.log(blob);
    video.onload = function(e) {
    window.url.revokeobjecturl(video.src);
    };
    video.src = window.url.createobjecturl(blob);
    }
    }
    xhr.send();
  </script>

三、效果图如下:

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网