码迷,mamicode.com
首页 > 编程语言 > 详细

javascript实现blob加密视频源地址的方法

时间:2020-03-28 16:24:34      阅读:481      评论:0      收藏:0      [点我收藏+]

标签:rev   bsp   poster   nbsp   create   upload   pre   html   please   

javascript实现blob加密视频源地址的方法

 一、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>

javascript实现blob加密视频源地址的方法

标签:rev   bsp   poster   nbsp   create   upload   pre   html   please   

原文地址:https://www.cnblogs.com/shemmor/p/12587740.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!