Website developer Wordpress

Vimeo embed won’t autoplay, what to do?

Vimeo embed won’t autoplay, what to do?

If you are using ACF, you need to choose field type “oEmbed”

You will need to add

and your php code


$video=$row['video'] ;
      
preg_match('/src="(.+?)"/', $video, $matches);
$src = $matches[1];


// add extra params to iframe src
$params = array(
    'playsinline' => 1,
				'controls'    => 0,
				'hd'  => 1,
				'autoplay' => 1,
				'background' => 1,
				'loop' => 1,
				'byline' => 0,
				'title' => 0,
                                'muted' => 1
);

$new_src = add_query_arg($params, $src);

$video = str_replace($src, $new_src, $video);


// add extra attributes to iframe html
$attributes = 'frameborder="0"';

$video = str_replace('>', ' ' . $attributes . '>', $video);
echo $video;

So it is important to set up autoplay to 1, loop to 1

Leave a Reply