本文介绍了一种使用jQuery或CSS静音iframe的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用jQuery或CSS来静音iframe的音频?

Is there a way to mute the audio of an iframe using jQuery or CSS?

这是我需要静音的iframe

This is the iframe I need to mute

<iframe src="http://player.vimeo.com/video/4415083?api=1;title=0&amp;byline=0&amp;portrait=0&amp;color=d01e2f&amp;autoplay=1" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>


推荐答案

在您的页面中包含此库:就像这样

Include this library in your page: https://github.com/vimeo/player-api/tree/master/javascript like this

< script src =// f.vimeocdn.com/js/froogaloop2.min.js\"></script>

此代码将向vimeo播放器发送API调用,以便在播放器准备就绪后将音量设置为0,基于

This code will send an API call to vimeo player to set the volume to 0 once the player is ready, based on http://developer.vimeo.com/player/js-api

// you may need another way of getting reference to the iframe:
var iframe = document.getElementsByTagName('iframe')[0];
var player = $f( iframe );

 player.addEvent('ready', function() {
     player.api('setVolume', 0); 
 });

或者,没有外部库:

iframe.contentWindow.postMessage('{"method":"setVolume", "value":0}','*');

这篇关于一种使用jQuery或CSS静音iframe的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 02:51