Music wave form animation as Music is played .

 MUSIC WAVE FORM ANIMATION AS MUSIC IS PLAYED.


                                                           


                                                                This is simple web development program that will start animation as music is played and stop the animation as music is stop playing. We have used JavaScript code for adding events in our code. If you see this program carefully you will find we have designed such output with very simple logic. If you like this program then share this code with your friend and Subscribe 👍 our Blog for any latest updates.




 PROGRAM SOURCE CODE :)





<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Creating wave In HTML</title>

<!-------------------CSS Styling Part ----------------------------->

<style type="text/css">

    *{
        margin0;
        padding0;
        box-sizingborder-box;
    }

    #main{
        width100vw;
        height100vh;
        background-color#000;
        displayflex;
        justify-contentcenter;
        align-itemscenter;
    }

    #center{
        width70vw;
        height60vh;
        displaygrid;
        place-items:center;
    }

    ul{
        displayinline-flex;
    }  


    li{
        list-style-type:none;
        width0.8rem;
        height20rem;
        background-color#000;
        margin1.2rem;
        border-radius10rem;
        transform-originbottom;
    }


    .k{
        animation: ud 1s linear infinite;
    }

    @keyframes ud{

        0%{
            transformscale(0);
        }

        50%{
            transformscale(1);
        }

        100%{
            transformscale(0);
        }
    }

#s1{
    background-color:#ff0000;
    animation-delay.1s
}

#s2{
    background-color#0000FF ;
    animation-delay.2s
}

#s3{
    background-color:rgb(2,179,32);
    animation-delay.3s
}

#s4{
    background-color#FF00FF ;
    animation-delay.4s
}

#s5{
    background-color:#ffff;
    animation-delay.5s
}

#s6{
    background-color#FA8072
    animation-delay.6s;
}

#s7{
    background-color#FFFF00 ; 
    animation-delay.7s;
}

#s8{
    background-color:#7FFF00 ; 
    animation-delay.8s;
}

audio{
    displaynone;
}
#btn{
    margin3rem auto;
    padding1rem 3rem;
    text-aligncenter;
    font-size2rem;
    font-familyVerdana, Geneva, Tahomasans-serif;
    color#fff;
    background-colorblue;
    cursorpointer;
    outlinenone;
}

</style>


</head>
<body>
    <div id="main">
        <div id="center">
            <ul>
                <li id="s1"></li>
                <li id="s2"></li>
                <li id="s3"></li>
                <li id="s4"></li>
                <li id="s5"></li>
                <li id="s6"></li>
                <li id="s7"></li>
                <li id="s8"></li>
            </ul>
            <button type="submit" id="btn">Play</button>
        </div>
        <audio src="../sounds/Song4.mp3" controls></audio>
    </div>
    <script>

        song = document.querySelector('audio');

        l = document.querySelectorAll('li');

        b = document.getElementById('btn');

        var isplaying = false;

        let i;

        let playmusic = () =>{
            isplaying = true;
            song.play();
            b.innerText = "Pause";
            event.target.setAttribute("title","Pause");
            for(i=0i<l.lengthi++)
            {
                l[i].classList.add('k');
            }
        }

        let pausemusic = () =>{
            isplaying = false;
            song.pause();
            b.innerText = "Play";
            event.target.setAttribute("title","Play");
            for(i=0i<l.lengthi++)
            {
              l[i].classList.remove('k');
            }
        }

        b.addEventListener("click",function(){
            isplaying ? pausemusic() : playmusic();
        })

    </script>
</body>
</html>






OUPTPUT :)






( NOTE : - While executing program you have to replace links of images , audio's  or video's in this program by your links. So take care of it ! )