What creates t...">

Rails Video Autoplay Attribute

I use video_tagto display a video, for example:

<%= video_tag "tech4.mp4", autoplay: true %>

What creates the HTML that looks like this:

<video src="(big source file)" autoplay="autoplay"></video>

autoplayworks in Firefox, but not in Chrome or Safari. I realized that autoplay works when I change the HTML (in the browser) to:

<video src="(big source file)" autoplay></video>

How can I get this conclusion from video_tag? I tried :autoplay, autoplay: '', autoplay: nilbut nothing works.

+4
source share
2 answers

I just tried:

autoplay: :autoplay,
loop: :loop,

on Chrome 46.0.2490.86 and Safari 9.0.1, and it works.

It produces:

<video autoplay="autoplay" loop="loop" ...
+2
source

I found this solution

<%= video_tag(["video.mp4"], :size => "320x240", :autoplay => true, :loop => true) %>

I know this is a long time. Hope this helps others who have the same problem.

+1
source

Source: https://habr.com/ru/post/1599170/


All Articles