Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> HTML

Thuộc tính paused của Video trong HTML DOM


Thuộc tính paused của đối tượng Video trong HTML DOM trả về một boolean (true/false) cho biết video đang phát hay không.

Cú pháp

Trả về giá trị boolean:

mediaObject.paused

Ví dụ

Ví dụ minh họa thuộc tính HTML DOM Video paused:

<!DOCTYPE html> <html> <head> <title>HTML DOM Video paused</title> <style>    * {       padding: 2px;       margin:5px;    }    form {       width:70%;       margin: 0 auto;       text-align: center;    }    input[type="button"] {       border-radius: 10px;    }    .dimLight {       background-color: #000;    } </style> </head> <body>    <form class="dimLight" id="formSelect">       <fieldset>          <legend>HTML-DOM-Video-paused</legend>          <div onclick="getTrackDetails()">          <video id="demo" width="320" controls><source    src='https://www.tutorialspoint.com/html5/foo.mp4' type="video/mp4"></video><br>          </div></fieldset></form> <script>    var formSelect = document.getElementById("formSelect");    var demo = document.getElementById("demo");    demo.autoplay = true;    function getTrackDetails() {       if(demo.paused)          formSelect.classList.add('dimLight');       else          formSelect.classList.remove('dimLight');    } </script> </body> </html>

Kết quả

Trước khi nhấn vào video để tạm dừng:

Thuộc tính paused của Video trong HTML DOM

Sau khi nhấn vào video để tạm dừng:

Thuộc tính paused của Video trong HTML DOM