使用高级自定义字段Wordpress静音视频

使用高级自定义字段Wordpress静音视频,wordpress,youtube,advanced-custom-fields,oembed,Wordpress,Youtube,Advanced Custom Fields,Oembed,我正在尝试将在我的网站上作为介绍背景播放的视频静音。我有我需要的所有属性,但我不知道如何使声音静音。思想? // 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 s

我正在尝试将在我的网站上作为介绍背景播放的视频静音。我有我需要的所有属性,但我不知道如何使声音静音。思想?
// 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; ?>
//获取iframe HTML
$iframe=get_字段('slider_video');
//使用preg_match查找iframe src
preg_match('/src=“(.+?)”/”,$iframe,$matches);
$src=$matches[1];
//向iframe src添加额外参数
$params=数组(
“控件”=>0,
‘hd’=>1,
“自动隐藏”=>1,
“自动播放”=>1,
“showinfo”=>0
);
$new\u src=add\u query\u arg($params,$src);
$iframe=str_replace($src,$new_src,$iframe);
//向iframe html添加额外属性
$attributes='frameborder=“0”';
$iframe=str_replace('>','.$attributes'>',$iframe);
//echo$iframe
echo$iframe;
?>

看起来你在使用Youtube?如果是这样,您似乎需要使用Javascript来实现这一点。请参见此处接受的答案:


基本上,您需要在页面加载时运行一个脚本,通过ID选择iframe并在其上运行.mute()方法。

看起来您正在使用Youtube?如果是这样,您似乎需要使用Javascript来实现这一点。请参见此处接受的答案:

基本上,您需要在页面加载上运行一个脚本,该脚本通过ID选择iframe并在其上运行.mute()方法