HTML DOM 影片 paused 屬性


HTML DOM Video paused 屬性返回一個布林值(true/false),與影片是否正在播放相對應。

語法

以下是語法 −

返回布林值

mediaObject.paused

我們來看一個 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://tutorialspoint.tw/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>

輸出

在點選影片暫停之前 −

在點選影片暫停之後 −

更新於: 18-2月-2021

90 次瀏覽

開啟你的 職業生涯

完成課程獲得認證

現在開始
廣告
© . All rights reserved.