【问题标题】:Mute Video with Advanced Custom Fields Wordpress使用高级自定义字段 Wordpress 静音视频
【发布时间】:2017-02-06 20:18:17
【问题描述】:

我正在尝试将在我的网站上作为介绍背景播放的视频静音。我拥有我需要的所有属性,但我不知道如何使声音静音。想法?

// 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; ?>

【问题讨论】:

    标签: wordpress youtube advanced-custom-fields oembed


    【解决方案1】:

    看起来您正在使用 Youtube?如果是这样,您似乎需要使用 Javascript 来完成此操作。在此处查看接受的答案:

    YouTube: How to present embed video with sound muted

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

    【讨论】:

      猜你喜欢
      • 2013-11-25
      • 2017-08-28
      • 2012-08-10
      • 2015-01-21
      • 2017-05-01
      • 1970-01-01
      • 2018-09-02
      • 2016-09-07
      • 2018-06-07
      相关资源
      最近更新 更多