视频试看5分钟[通俗易懂]

缺陷:用户在控制台能直接拿到视频url地址<!DOCTYPEhtml><html><head><title></title></head><styletype=”text/css”>.videobox{position:relative;width:300px;…

大家好,又见面了,我是你们的朋友全栈君。

缺陷:用户在控制台能直接拿到视频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>
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/125691.html原文链接:https://javaforall.net

(0)
上一篇 2022年4月6日 上午9:40
下一篇 2022年4月6日 上午10:00


相关推荐

  • tomcat无法启动程序 Error filterStart

    tomcat无法启动程序 Error filterStart有时在启动tomcat时,有的应该程序无法启动,tomcat报错信息如下:org.apache.catalina.core.StandardContextstartSEVERE:ErrorfilterStartorg.apache.catalina.core.StandardContextstartSEVERE:Contextstartupfaileddueto…

    2022年7月11日
    18
  • IDEA和eclipse的区别

    IDEA和eclipse的区别1 IDEA 能打开多个工作空间 而 eclipse 一次只能打开一个工作空间 2 IDEA 是一个没有 ctrl s 的 IDE 无需担心保存或代码丢失 可查看代码编写历史 3 idea 使用的是内存空间 会将建立的索引都保存到内存中 而实际占用的 cpu 少 4 eclipse 使用的内存空间相对较少 但占用的 cpu 多 这就导致 eclipse 比较卡的原因

    2026年3月27日
    2
  • SpringBoot自动装配原理分析

    SpringBoot自动装配原理分析先看看SpringBoot的主配置类:里面有一个main方法运行了一个run()方法,在run方法中必须要传入一个被@SpringBootApplication注解的类。@SpringBootApplicationSpringBoot应用标注在某个类上说明这个类是SpringBoot的主配置类,SpringBoot就会运行这个类的main方法来启动SpringBoot项目。那@…

    2022年8月21日
    10
  • 腾讯元宝里的全部应用怎么调出来

    腾讯元宝里的全部应用怎么调出来

    2026年3月13日
    2
  • Linux shell if [ -n ] 正确使用方法「建议收藏」

    Linux shell if [ -n ] 正确使用方法「建议收藏」if[str1=str2]      当两个串有相同内容、长度时为真 if[str1!=str2]     当串str1和str2不等时为真 if[-nstr1]      当串的长度大于0时为真(串非空) if[-zstr1]       当串的长度为0时为真(空串) if[str1]        当串str1为非空时为真

    2022年7月27日
    6
  • 安全狗:云时代的服务器安全守护者

    安全狗:云时代的服务器安全守护者

    2021年9月7日
    70

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号