0
I made an example:
function play() {
//Fazer animação
}
function pause() {
//Para animação, ficar toda linha roxa;
}
#animacao {
position: relative;
margin: 30px;
}
#bloco {
display: block;
bottom: 0px;
width: 09px;
height: 5px;
background: #9b59b6;
position: absolute;
animation: audio-wave 1.5s infinite ease-in-out;
}
#bloco:nth-child(1) {
left: 00px;
animation-delay: 0.0s;
}
#bloco:nth-child(2) {
left: 11px;
animation-delay: 0.1s;
}
#bloco:nth-child(3) {
left: 22px;
animation-delay: 0.2s;
}
#bloco:nth-child(4) {
left: 33px;
animation-delay: 0.3s;
}
#bloco:nth-child(5) {
left: 44px;
animation-delay: 0.4s;
}
#bloco:nth-child(6) {
left: 55px;
animation-delay: 0.5s;
}
@keyframes audio-wave {
0% {height:5px;transform:translateY(0px);background:#9b59b6;}
25% {height:40px;transform:translateY(20px);background:#3498db;}
/*effect is to animate the height of each span from 5px to 30px*/
/*translateY makes Y axis move down to give the effect that it is growing from the center*/
50% {height:5px;transform:translateY(0px);background:#9b59b6;}
100% {height:5px;transform:translateY(0px);background:#9b59b6;}
}
<div id="animacao">
<div id="bloco"></div>
<div id="bloco"></div>
<div id="bloco"></div>
<div id="bloco"></div>
<div id="bloco"></div>
<div id="bloco"></div>
</div>
<br>
<audio id="player" controls="controls" onclick="this.paused ? this.play() : this.pause();" src="http://ianreah.apphb.com/sounds/movement%20proposition.mp3"> </audio>
I saw another example of the function when she stops the music and plays the music here.
When pausing the music, it should be all purple and not blue.
Before playing the song should get all purple line too.
He can only do animation while the music plays.
Any idea ?
Related/alternative: Get "waves" from sound or music frequency
– Guilherme Nascimento