I need to play a video (auto playing) regardless of any browser or devices. Below code is working fine in Desktops (Chrome, Opera, Firefox and Safari); but, in mobile phones it is not loading in iPhone (showing controls) and in some android phones (not even controls)
I have tried adding attributes autoplay
with muted
and playsinline
, also tried to force play with JavaScript.
Here is the HTML:
<video autoplay playsinline loop muted poster="about-poster.png">
<source
src="about-video.mp4"
type="video/mp4"
/>
<p>
Your browser doesn't support HTML5 video. You can find our
logo video
<a href="about-video.mp4">here</a> instead.
</p>
</video>
This is the JavaScript code:
window.addEventListener("DOMContentLoaded", function() {
var media = document.querySelector("video");
if (media.paused) {
media.play();
} else {
media.play();
}
});
I want to autoplay the video in every browser and every devices, and I could use some help.
Thanks.