video autoplay

Permalink
is there a way to make standard video block autoplay?
Cant' find anything online about this, and yet would seem obvious requirement.

deanhawthornthwaite
 
mnakalay replied on at Permalink Reply
mnakalay
Hello,

The standard video block just uses a normal HTML <video> element so to make it autoplay, you can simply copy the block's view.php file to create a template and in your template, around line 22, where it says
<video controls="controls" <?php echo $posterURL ? 'poster="' . $posterURL . '"' : '' ?>


Modify it to say
<video controls="controls" autoplay <?php echo $posterURL ? 'poster="' . $posterURL . '"' : '' ?>


But it is not necessarily a good idea because browsers are more and more blocking autoplay, especially on mobile.

You should read this to have a better idea of what browsers do and a possible strategy to deal with it:https://stackoverflow.com/questions/49822790/html5-video-autoplay-no...
mesuva replied on at Permalink Reply
mesuva
One thing that has caught me out with this a few times is that some browsers will only autoplay a video if it doesn't have any audio track.

There is also another video attribute, muted, that can be added alongside autoplay, but I recall that that wasn't enough last time I tried (maybe because javascript could be used to toggle it once playing). The video itself had to have the audio stripped from it, even if the audio was just silence.

I usehttp://handbrake.fr/ to re-encode videos smaller for the web, and you can also do a video only export.
mnakalay replied on at Permalink Reply
mnakalay
@mesuva is right and it is generally not a good idea anymore to autoplay videos
deanhawthornthwaite replied on at Permalink Reply
deanhawthornthwaite
Hi and thanks both of you for your comments.
Ive added autoplay code to the video view file and it works a treat.

Cant see that this can do any harm as if it doesn't autoplay on some browsers i just live with it. What is puzzling is when i go to various web pages across the net that have video adverting, they all seem to autoplay.