Html video autoplay Safari

Video auto play is not working in Safari and Chrome desktop browser

The best fix I could get was adding this code just after the

document.getElementById['vid'].play[];

...not pretty but somehow works.

UPDATE Recently many browsers can only autoplay the videos with sound off, so you'll need to add muted attribute to the video tag too

...

After using jQuery play[] or DOM maniupulation as suggested by the other answers, it was not still working [Video wasn't autoplaying] in the Chrome for Android [Version 56.0].

As per this post in developers.google.com, From Chrome 53, the autoplay option is respected by the browser, if the video is muted.

So using autoplay muted attributes in video tag enables the video to be autoplayed in Chrome browsers from version 53.

Excerpt from the above link:

Muted autoplay for video is supported by Chrome for Android as of version 53. Playback will start automatically for a video element once it comes into view if both autoplay and muted are set[...]

  • Muted autoplay is supported by Safari on iOS 10 and later.
  • Autoplay, whether muted or not, is already supported on Android by Firefox and UC Browser: they do not block any kind of autoplay.

Google just changed their policy for autoplay videos, it has to be muted

You can check here

so just add muted

Video liên quan

Chủ Đề