zoukankan      html  css  js  c++  java
  • 实现dom中video对象的时间戳控件

    功能:自定义视频播放器中的时间戳控件。

    
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>时间戳</title>
        <style>
            *{
                margin: 0;
                padding: 0;
            }
    
            div{
                 400px;
                height: 400px;
                border: 1px dashed #000;
                padding-left: 110px;
                box-sizing: border-box;
                margin: 100px auto;
            }
    
            button{
                 80px;
                height: 50px;
                margin-left: 10px;
                margin-top: 80px;
            }
            span{
                display: inline-block;
                font-size: 50px;
                margin-left: 30px;
                margin-top: 80px;
            }
        </style>
    
        <script>
           window.onload = function () {
    
              let start = document.getElementById("start");
              let end = document.getElementById("end");
              let timestamp = document.getElementById("text");
              let timer = null;
              // 用于控制时间戳的时间
              let seconds = 0;
              let minutes = 0;
              start.onclick = function () {
                 // 禁用开始按钮,启用结束按钮
                 start.disabled = true;
                 end.disabled = false;
                 timer = setInterval(function () {
                    minutes = seconds / 60;
                    // 当分钟数为一位数时
                    if (minutes < 10) {
                       // 当秒数也为一位数时
                       if (seconds%60 < 10)
                          timestamp.innerHTML = `0${Math.floor(minutes).toString()}:0${(seconds%60).toString()}`;
                       // 当秒数为两位数时
                       else if (seconds%60 >= 10)
                          timestamp.innerHTML = `0${Math.floor(minutes).toString()}:${(seconds%60).toString()}`;
    
                    }
                    else if (minutes >= 10) {
                       // 当秒数也为两位数时
                       if (seconds%60 < 10)
                          timestamp.innerHTML = `${Math.floor(minutes).toString()}:0${(seconds%60).toString()}`;
                       // 当秒数为两位数时
                       else if (seconds%60 >= 10)
                          timestamp.innerHTML = `${Math.floor(minutes).toString()}:${(seconds%60).toString()}`;
                    }
                    seconds++;
                 },1000);
    
              };
              end.onclick = function () {
                 // 禁用结束按钮,启用开始按钮
                 end.disabled = true;
                 start.disabled = false;
                 clearInterval(timer);
              }
           };
        </script>
    </head>
    <body>
    <div>
        <button id="start">开始</button>
        <button id="end">结束</button>
        <br>
        <span id="text">00:00</span>
    </div>
    
    
    
    </body>
    </html>
    
    
    
  • 相关阅读:
    Oracle11g备份与恢复-手工备份与恢复
    undo段及区的状态和使用
    图解一个事务操作流程
    Oracle11g备份与恢复
    undo表空间概述-1
    事务的隔离级别
    事务概述
    系统改变号(SCN)详解
    实例崩溃恢复原理--检查点队列的作用
    Oracle-检查点队列
  • 原文地址:https://www.cnblogs.com/TomHe789/p/12782820.html
Copyright © 2011-2022 走看看