当前位置:网站首页 > 后端开发 > 正文

视频试看5分钟

缺陷:用户在控制台能直接拿到视频url地址

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    <title>视频试看</title>
</head>
<style type="text/css">
  *{
    margin: 0;
    padding: 0;
  }
  .videobox{
    position: relative;
    width: 100%;
  }
  .videobox video{ width: 100%;  }
  .zhezhao{
    position: absolute;
    background: #000;
    width: 100%;
    top: 0;
    bottom: 0;
    display: none;
    z-index: 9;
    cursor: pointer;
  }
  .shikanjieshu{
    color: #fff;
    position: absolute;
    width: 100%;
    top: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
  }
  .chongxinkaishibox{
    text-align: center;
    font-size: 12px;
  }
  .chongxinkaishibox img{
    width: 30px;
  }
</style>
<body>
<!--   https://y1pindao.com/app/img/mp4/afd83049775b55c1f9e93132d9ff1e3f.mp4 -->
    <div class="videobox">
      <video src="https://y1pindao.com/app/img/mp4/afd83049775b55c1f9e93132d9ff1e3f.mp4"  poster="loading.gif" controls preload="auto" id="player"></video>
      <div class="zhezhao">
        <div class="shikanjieshu">
          <div class="chongxinkaishibox">
            <img src="chongxinkaishi.png" />
            <div>试看结束,点击重新开始</div>
          </div>
        </div>
      </div>
    </div>

    <script type="text/javascript">
         let num = 60*5;
         let pl=document.getElementById("player");  
         pl.addEventListener("timeupdate",function(){
            if(parseInt(pl.currentTime)>=num){
              pl.pause()
              document.getElementsByClassName('zhezhao')[0].style.display = 'block';
              console.log(pl)
              pl.setAttribute('src','')
            }
         })
          document.getElementsByClassName("zhezhao")[0].addEventListener('click',function(){
            console.log('重新开始')
            document.getElementsByClassName('zhezhao')[0].style.display = 'none';
            pl.setAttribute('src','https://y1pindao.com/app/img/mp4/afd83049775b55c1f9e93132d9ff1e3f.mp4')
            pl.currentTime=0;
            pl.play();
          })
    </script>
</body>
</html>
到此这篇视频试看5分钟的文章就介绍到这了,更多相关内容请继续浏览下面的相关推荐文章,希望大家都能在编程的领域有一番成就!

版权声明


相关文章:

  • 【标准文件免费下载】国家标准和行业标准 良心网站推荐2024-11-22 22:54:04
  • 从零开始学理财(内容详实)2024-11-22 22:54:04
  • 主数据管理系统2024-11-22 22:54:04
  • 老司机珍藏的130个网站,没人的时候偷偷看!2024-11-22 22:54:04
  • 有哪些广告联盟值得推荐2024-11-22 22:54:04
  • 中国有34个省市自治区(342个市)2024-11-22 22:54:04
  • 不错的磁力网站2024-11-22 22:54:04
  • 一区即将要洗的DVD片子2024-11-22 22:54:04
  • 追求极致音质?20个顶级无损音乐下载平台推荐2024-11-22 22:54:04
  • 精品手机看片神器电影网址导航网站2024-11-22 22:54:04
  • 全屏图片