If I want to change opacityof <div>irregularly over time, I can use CSS animationand @keyframes:
.myDiv {
animation: myAnimation 10s linear;
}
@keyframes myAnimation {
0% {opacity: 1;}
80% {opacity: 1;}
81% {opacity: 0.99;}
100% {opacity: 0;}
}
}
But what if I want to change an volumeelement of an element <audio class="my-audio">irregularly over time in the same way?
I know that I can start with:
var myAudio = document.getElementsByClassName('my-audio')[0];
myAudio.volume = 1.0;
But how can I change volumeto 0.99when the 81%sound clip was playing and gradually fading to volumebefore 0.0when the 100%sound clip was playing?
Is there javascript syntax for this kind of auditory transition, or am I looking for something that doesn't exist yet?
source
share