Audio fadeouts/fadeins?

contemplatecast
14 Sept 2016, 09:21

I'm really new to javascript. I can load audio in a passage using the html audio tag but I can't figure out how to implement audio fade outs and fade ins.

Is there any option for this.?


TwoCupsofSugar
18 Sept 2016, 20:47

I did manage to make a small bit of code that works with the html audio tag to control audio fade outs the only problem is that it requires the function to be pasted in each and every section it is used in even when it is used in a master section. Squiffy for some strange cannot access a function or a variable if it exists in another section. Either way the code works, but it's a clunky implementation in my opinion.

    function fadeOut(mySound){
    var myAudio = document.getElementById(mySound);
    if(myAudio.volume > 0.005){
    myAudio.volume -= 0.005;
    setTimeout(function(){fadeOut(mySound);},20);
    }
    else{ myAudio.pause();
    }
    }
    fadeOut("Audio");    

thetruespin
19 Sept 2016, 10:17

Can't you just add the Javascript function to the main index HTML template, and then call via individual sections?

That's how I usually manage sound.