如何将iframe vimeo静音

时间:2015-02-13 14:08:17

标签: javascript iframe vimeo-api

我已经尝试了所有可能找到的解决方案,但我似乎无法将我的iframe vimeo视频静音。我在头部引用了“//f.vimeocdn.com/js/froogaloop2.min.js”。我在页面底部使用以下javascript ...

<script type="text/javascript">
var iframe = document.getElementById('vimeo_player');
var player = $f( iframe );

 player.addEvent('ready', function() {
     player.api('setVolume', 0); 
 });
</script>

您可以在此处查看我的尝试:http://walkinthedog.com/video-test/

非常感谢任何帮助。

2 个答案:

答案 0 :(得分:1)

在你的vimeo embed中使用来自api的setVolume .. player.api('setVolume',0);它会是这样的......

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<script src="//f.vimeocdn.com/js/froogaloop2.min.js"></script>
<iframe id="vimeo_player" src="http://player.vimeo.com/video/4415083?  title=0&amp;byline=0&amp;portrait=0&amp;color=d01e2f&amp;autoplay=1" width="500" height="281"  frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
    <script>
      var iframe = $('#vimeo_player')[0],
        player = $f(iframe),
        status = $('.status');

        player.addEvent('ready', function() {
            player.api('setVolume', 0);
        });
    </script>

答案 1 :(得分:0)

使用最新版本,可以获得更简单的解决方案:

<iframe id="vimeo_player" src="http://player.vimeo.com/video/4415083?autoplay=1" width="500" height="281"  frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<script src="https://player.vimeo.com/api/player.js"></script> 
<script>
    var player = new Vimeo.Player(document.getElementById("vimeo_player"));
    player.on('play', function() {
        player.setVolume(0)
    });
</script>