Home > OS >  auto play video element in html reactJs
auto play video element in html reactJs

Time:11-02

I tried this code to implement the autoplay video feature without the control bars but the issue that I faced was, the video was not autoplaying after refreshing the page. this project is in react. even after adding an autoplay attribute, the video is not autoplaying. what's the mistake am I doing?

I expect it to be autoplaying even after refreshing the page

I tried this code to implement the autoplay video feature without the control bars but the issue that I faced was, the video was not autoplaying after refreshing the page. this project is in react. even after adding an autoplay attribute, the video is not autoplaying. whats the mistake am I doing?

<video  id="coinSaverIcon"  autoPlay playsInline>
<source src={coinsaverIcon} type="video/webm" />
</video>

CodePudding user response:

You can add muted property

<video  id="coinSaverIcon"  autoPlay playsInline muted>
   <source src={coinsaverIcon} type="video/webm" />
</video>

CodePudding user response:

In some browsers autoplay (Chromium for example) is not allowed anymore. Furthermore you shouldn't implement this kind of features for accessiblity issues.

https://www.w3schools.com/tags/att_video_autoplay.asp https://www.a11yproject.com/posts/never-use-auto-play/

  • Related