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

更多相关文章

  1. 如何使用ajax GET或POST方法将数据传递到amazon lambda节点。js
  2. 在each()函数内部调用多个ajax ..然后在完成所有这些操作后执行某
  3. 加载函数加载页面但不能对数据执行任何操作
  4. 绑定和解除相同javascript函数的目的是什么?
  5. Jquery中的队列函数quene()、dequene()、clearQuene()
  6. Ajax_04之jQuery中封装的Ajax函数
  7. 怎么用js或jquery把一个函数b绑定到另一个函数a之后执行
  8. jQuery: 刨根问底 attr and prop两个函数的区别
  9. jQuery ajax问题 - 无法让我的函数工作

随机推荐

  1. 在代码中获取Android(安卓)theme中的attr
  2. Android的CTS测试
  3. 探索 Android(安卓)Q:位置权限
  4. android9.0 系统默认时间修改
  5. Android Studio failed to open by givin
  6. 安卓基础到入门学习(复习笔记)
  7. android:shape的使用2
  8. recycleView的item获取焦点
  9. Android--使用include调用布局
  10. android高版本系统源码下载和编译刷机