How to play / pause song using javascript

<script>

   

    function play(){

        var audio = document.getElementById("myaduio");

        audio.play();

        document.getElementById("play").style.display="none";

        document.getElementById("pause").style.display="block";

       

    }

 

    function pause(){

        var audio = document.getElementById("myaduio");

        audio.pause();

 

        document.getElementById("play").style.display="block";

        document.getElementById("pause").style.display="none";

 

    }

</script>

 

<audio id="myaduio">

<source src="youraudiofile.mp3" type="audio/mpeg">

</audio>

 

<input type="button" value="Play" id="play" onclick="play()">

<input style="display:none;" type="button" value="Pause" id="pause" onclick="pause()">



Explore Our YouTube Tutorials

Dive into our YouTube tutorials to access high-quality learning content on web development, design, and technology. Each video is crafted to provide clear guidance and hands-on knowledge for skill development.

 


Upgrade Your Skills with Our Courses

Choose the right course and start building your future with practical skills.

Web Development

Learn HTML, CSS, JavaScript, and PHP to build modern, responsive websites and real-world projects.

Enroll Now See Full Details

Breadboard Learning

Understand electronics basics with hands-on breadboard projects and circuit building techniques.

Enroll Now See Full Details

AI Training

Step into AI with real-world applications, automation tools, and smart development techniques.

Enroll Now See Full Details