• 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)
  • Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    Can you please let me know how you are adding the videos to the AMP version? Do let us know so that we will get back to you accordingly.

    Thread Starter lehren

    (@lehren)

    Since it is a video-only website, the videos are added as a link at the beginning of the post, the theme picks it and renders the wp-embed block on the front-end.

    But as soon as the page is rendered in AMP, the filter for autoplay does not apply to it, you can check using the link provided in our initial comment.

    Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    Can you please let me know which theme you are using at your end right now? So that we will re-create it and let you know back accordingly.

    Thread Starter lehren

    (@lehren)

    We use Vlog theme by Meks.

    Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    Thanks for letting me know. We will re-create it at our end and get back to you shortly.

    Thread Starter lehren

    (@lehren)

    We look ahead to your response.

    Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    We are unable to re-create it with the current info. Can you please share the active plugins list with the version? So that we will check it using that and get back to you shortly.

    Thread Starter lehren

    (@lehren)

    Hi Ahmed,

    This is really easy to recreate.

    1. Install Vlog theme by Meks.
    2. Install AMPforWP plugin.
    3. Create a video post by adding a Dailymotion Video URL.
    4. See the AMP version of the post.
    5. The AMP page renders the video using an iframe embed but does not autoplay.

    We just want a method that can be used to force autoplay on video embeds in the AMP version.

    The iframe SRC just needs to append ?autoplay=1 at the end of the video url.

    FYI, list of plugins we use:
    Accelerated Mobile Pages
    Entry Views
    Meks Easy Ads Widget
    Meks Easy Social Share
    Meks Flexible Shortcodes
    Meks Time Ago
    Redux
    Series
    Vlog Buddy

    Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    Thanks for sharing it, We will check using it and get back to you shortly.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘How to Add Autoplay Parameter for Video Embeds?’ is closed to new replies.