Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- audio.addEventListener('playing', playingEventHandler);
- function playingEventHandler() {
- audio.removeEventListener("playing", playingEventHandler);
- setTimeout(function() {
- fadeOut(audio, 3000);
- }, 10 * 1000);
- }
- function fadeOut(audio, fadeDuration, initialVolume) {
- var stepSize = (initialVolume || audio.volume) / (fadeDuration / 50);
- var volume = Math.max(0, audio.volume - stepSize);
- audio.volume = volume;
- if(audio.volume > 0) {
- // Keep up going until 11
- setTimeout(function() {
- fadeOut(audio, fadeDuration, initialVolume)
- }, 50);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement