Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fade in/out sound playing in 2 different Divs

JQuery has nice visual fadeIn/fadeOut functions that work on different elements such as div. I need the same thing for sound.

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?

like image 911
user556634 Avatar asked Nov 24 '25 14:11

user556634


1 Answers

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.

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


Example usage with fadeTo function,

$('<div/>').fadeTo({
     duration: 1000,
     step: function(now, fx){
        var volume = now * 100;
        player.setVolume(volume)
     }
},1);
like image 99
Jim Jose Avatar answered Nov 27 '25 04:11

Jim Jose



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!