How to Add Autoplay Parameter for Video Embeds?
-
Hi Team,
The plugin is great but we are facing challenges with making our videos play automatically on page load.
For non-amp pages, we have created a filter to add “?autoplay=1” at the end of the embed URLs which makes it work there, but the snippet does not work for AMP pages.
Can you please help with what can be done to control the AMP query parameters if we want to autoplay Dailymotion videos embedded within the post?
For your reference, here is the snippet that works flawlessly with non-amp pages:
function force_autoplay($code){ if(strpos($code, 'dailymotion.com') !== false){ $return = preg_replace('@embed/([^"&]*)@', 'embed/$1?autoplay=1', $code); return '<div class="embed-container">' . $return . '</div>'; } return '<div class="embed-container">' . $code . '</div>'; } add_filter( 'embed_oembed_html', 'force_autoplay');The page I need help with: [log in to see the link]
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
The topic ‘How to Add Autoplay Parameter for Video Embeds?’ is closed to new replies.