HTML 5 Video “autoplay” not automatically starting in CHROME

后端 未结 9 508
死守一世寂寞
死守一世寂寞 2020-11-30 02:51

I have the following code:

9条回答
  •  迷失自我
    2020-11-30 03:35

    Try this:

    
    

    And put this js after that:

    window.addEventListener('load', async () => {
      let video = document.querySelector('video[muted][autoplay]');
      try {
        await video.play();
      } catch (err) {
        video.controls = true;
      }
    });
    

提交回复
热议问题