簡體   English   中英

未捕獲的類型錯誤:無法在 resumeVideo 讀取 null 的屬性“播放”

[英]Uncaught TypeError: Cannot read property 'play' of null at resumeVideo

請幫助我理解為什么我在控制台上收到這個錯誤,我使用谷歌瀏覽器。

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>

    <video width="600" id"vid">
      <source src="Video/caballeroCorriendo.mp4" type="video/mp4">
    </video>

    <button onclick="intervalo();">Iniciar</button>

    <script src="vid.js"></script>
  </body>
</html>

這是js:

var video = document.getElementById("vid");

function resumeVideo(){
  video.play();
}

function intervalo(){
  tiempoParar = setInterval(tiempo, 1000/30);
  resumeVideo();
}

var segundos;

function tiempo(){
  segundos = video.currentTime;
  console.log(segundos);
}

我對 currentTime 屬性有同樣的問題

在您的情況下,您沒有正確分配元素的 ID 屬性:

id"vid"更改為id="vid"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM