在2个不同的Div中播放/淡出声音
JQuery has nice visual fadeIn/fadeOut functions that work on different elements such as div
. I need the same thing for sound.
JQuery具有很好的视觉fadeIn / fadeOut函数,可以处理不同的元素,如div。声音需要同样的东西。
More precisely, if two YouTube iFrame API players are playing from within 2 different div
, is there a way to fadeIn/fadeOut the sound between them?
更确切地说,如果两个YouTube iFrame API播放器正在从2个不同的div中播放,有没有办法淡出/淡出它们之间的声音?
2 个解决方案
#1
6
Try something like this,
尝试这样的事情,
$('<div/>').animate({ left: 100 }, {
duration: 1000,
step: function(now, fx){
var volume = now;
player.setVolume(volume)
}
});
the step
function will give you a callback on every change of the val and you can call the youtube player to set the volume.
step函数会在每次更改val时给你一个回调,你可以调用youtube播放器来设置音量。
I am not sure how fast the youtube player can respond to the volume set... but this method allows you to have jquery tween
effects just like in a div
我不确定youtube播放器能够以多快的速度响应音量集...但是这个方法允许你像在div中那样使用jquery补间效果
Example usage with fadeTo
function,
使用fadeTo函数的示例,
$('<div/>').fadeTo({
duration: 1000,
step: function(now, fx){
var volume = now * 100;
player.setVolume(volume)
}
},1);
更多相关文章
- 如何使用ajax GET或POST方法将数据传递到amazon lambda节点。js
- 在each()函数内部调用多个ajax ..然后在完成所有这些操作后执行某
- 加载函数加载页面但不能对数据执行任何操作
- 绑定和解除相同javascript函数的目的是什么?
- Jquery中的队列函数quene()、dequene()、clearQuene()
- Ajax_04之jQuery中封装的Ajax函数
- 怎么用js或jquery把一个函数b绑定到另一个函数a之后执行
- jQuery: 刨根问底 attr and prop两个函数的区别
- jQuery ajax问题 - 无法让我的函数工作