How can I autoplay all videos added by video shortcode?
I can make only one of them autoplay if only one has autoplay attribute set to 1, and others to 0, otherwise all are stopped.
4 comments
Comments are closed.
How can I autoplay all videos added by video shortcode?
I can make only one of them autoplay if only one has autoplay attribute set to 1, and others to 0, otherwise all are stopped.
Comments are closed.
I ran into this problem while trying to make HTML videos behave like GIFs. WordPress’s built-in video player uses HTML video elements but does not allow videos to play simultaneously.
Instead of using the default WordPress video player (which is best used for more standard video content), I chose to manually use the
<video>
element via a custom shortcode. For the best compatibility (especially on mobiles) we should also make sure the videos are also muted.After adding the following code, simply use:
And you’ll have a nice video working. To control styling and add (basic) HTML video controls, use something like:
Code
Add to your
functions.php
:I also use the following CSS to resize and center the videos by default:
You could try to use the
shortcode_atts_video
filter:to overwrite the
[video]
shortcode attributes.I have done this with my own video shortcode, in which i changed classes, so I can initiate player with
$('.my-video-shortcode').mediaelementplayer( {pauseOtherPlayers: false} );
It does what I needed 🙂
I realise this post is old however birgire response no longer works
Instead of
which makes sense, it should actually be