Home > Software engineering >  Video is not playing automatically in React JS
Video is not playing automatically in React JS

Time:01-06

Hy, I want to play videos automatically without controls. because I'm using it as a website banner background. Please point out what I have done wrong. I'm using chrome browser.

  <video
          autoPlay
          // playsinline
          autoplay
          muted
          loop
          className="stakingNft"
        >
        <source src="\assets\video\landing.mp4" type="video/mp4" />  
  </video>

--------------------------------

  <video
          autoPlay
          playsinline
          autoplay
          muted
          loop
          className="stakingNft"
        >
        <source src="\assets\video\landing.mp4" type="video/mp4" />  
  </video>

CodePudding user response:

Here is the codesandbox

autoPlay might be defined twice and in small case that's the reason I think.

CodePudding user response:

Looks like there's issue in path of video. You used backward slash instead of forward slash.

Here is the reference: https://stackblitz.com/edit/react-xbfng5?file=src/App.js


  • Related