1

I am trying to mute a video that is playing as a intro-background on my website. I have all the attributes I need, but I can't figure out how to mute the sound. Thoughts?

// get iframe HTML
$iframe = get_field('slider_video');


// use preg_match to find iframe src
preg_match('/src="(.+?)"/', $iframe, $matches);
$src = $matches[1];


// add extra params to iframe src
$params = array(
'controls'    => 0,
'hd'        => 1,
'autohide'    => 1,
'autoplay' => 1,
'showinfo' => 0
);

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

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


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

$iframe = str_replace('></iframe>', ' ' . $attributes . '></iframe>',      $iframe);


// echo $iframe
echo $iframe;

?>
<?php endif; ?>
toolbox3
  • 116
  • 9

1 Answers1

0

add

$params = array(
'muted' => 1,
);
Lowlowlow
  • 11
  • 2
  • 1
    This answer was reviewed in the [Low Quality Queue](https://stackoverflow.com/help/review-low-quality). Here are some guidelines for [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer). Code only answers are **not considered good answers**, and are likely to be downvoted and/or deleted because they are **less useful** to a community of learners. It's only obvious to you. Explain what it does, and how it's different / **better** than existing answers. [From Review](https://stackoverflow.com/review/low-quality-posts/32341632) – Trenton McKinney Jul 28 '22 at 14:17