0
votes

I have a video banner that I am wanting to autoplay. It is working in firefox, but only autoplays in chrome when I click a dud link ("#") on my page. It won't work in chrome when I simply reload either.

I am aware that it has to be muted for autoplay to work, and I also tried the playsinline attribute, setting it to true.

Here is my html.erb

<%= video_tag "type.mp4", mute: true, autoplay: :autoplay, loop: true, playsinline: true, preload: :auto, class: "banner_video", id: 'vid' %>

and here is what it produces

<video mute="true" autoplay="autoplay" loop="loop" playsinline="true" preload="auto" class="banner_video" id="vid" src="/assets/type-09d61a30abad860f1bed67840988a7464a7c88ef1bcf075fabbdb51f0e71dc75.mp4"></video>

This is apparently a common problem based off of other posts on stack overflow, but the muted and playsinline attributes seems to work for everybody else.

Does anybody know what could be keeping the video from autoplaying in chrome???

1
the attribute it muted not mute, and mute, autoplay, loop, controls, and playsinline are binary (so present=true, missing=false) - Offbeatmammal
Woooow... It was the typo 🤦🏻‍♂️ - Michael Villarreal
However, the video does not even show up in safari, if you happen to know that one... - Michael Villarreal
my guess is that it'll be a format/encoding issue if it works in Chrome but not Safari (note that Safari on Windows isn't supported any more). Can you share a link to a video showing the issue? - Offbeatmammal

1 Answers

0
votes

Chrome will not autoplay videos if not muted, The way you are setting the conditions of the video may be the issue. Try this.

<video class="banner_video" id="vid" 
             autoplay muted loop>
    <source src="(The Source Of Your Video)" type="video/mp4">
</video>