一种使用jQuery或CSS静音iframe的方法? [英] A way to mute an iframe using jQuery or CSS?

查看:854
本文介绍了一种使用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>


推荐答案

在您的页面中包含此库:https://github.com/vimeo/player-api/tree/master/javascript 就像这样

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,基于http://developer.vimeo.com/player/js-api

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); 
 });

http:// jsfiddle.net/87dsjL8q/

或者,没有外部库:

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

http: //jsfiddle.net/87dsjL8q/1/

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆