Fokrule
Fokrule

Reputation: 854

Video is not playing automatically in any browser except Mozilla Firefox

I am using WordPress. I have added video tag in the widget, but that added video is not playing in any browser except Mozilla Firefox.

I got some information that Chrome does not allow auto play anymore. But in my case the video is also not playing in iPhone, iPad, Mac, Opera browser and Chrome.

Here is my video code:

<div id="v-id">
 <video id="myvideo" autoplay="autoplay" width="100%" 
 height="100%"  loopplaysinline class="video-background " loop controls>
  <source src="https://ridgebackbusinessservices.com/wp- 
  content/uploads/2018/04/TDME-Project-1-final-v2.mp4" type="video/mp4" />
  <source src="movie.ogg" type="video/ogg" />
Your browser does not support the video tag.
</video>
</div>

If I do this in the console that play the video document.getElementById('myvideo').play();

But if I add this js code in the footer or header it doesn't work.

I have added that JavaScript code like this:

$( document ).ready(function() {
    $( "#v-id" ).load(function() {
    document.getElementById('myvideo').play();
    });
});

I have seen some question and answer in the Stack Overflow about this, but none of those worked.

Upvotes: 1

Views: 323

Answers (1)

Beginner
Beginner

Reputation: 9125

when i tried giving muted it worked in codpen remove the muted it will not autoplay. but without giving muted in stackoverflow snippet it worked. Try checking in your local . let me know whether muted was the issue

<video width="320" height="240" controls autoplay muted>
  <source src="http://techslides.com/demos/sample-videos/small.mp4" type="video/mp4">
  Your browser does not support the video tag.
</video>

Upvotes: 1

Related Questions