How to play audio using javascript?

Today, We want to share with you play audio javascript.In this post we will show you javascript audio stop, hear for audio html we will give you demo and example for implement.In this post, we will learn about Download Play Mp3 Music with an example.

Playing Music using JavaScript

play sound javascript

var audio = new Audio("hindi/Agar_Tum_Saath_Ho_FULL_AUDIO_Song.mp3");;

play audio in javascripts

var audio = new Audio('Agar_Tum_Saath_Ho_FULL_AUDIO_Song.mp3');;

play audio javascripts

var bMusic = new Audio('Agar_Tum_Saath_Ho_FULL_AUDIO_Song.mp3')

play a sound wiith js

var audio = new Audio('Agar_Tum_Saath_Ho_FULL_AUDIO_Song.mp3');;

play sound in javascript

function play() {
  var audio = new Audio('');;
<button onclick-"play();">PLAY MY AUDIO</button>

javascript play audio

//play audio with from html audio element: 

//play audio with out html audio tag
var myAudio = new Audio('Agar_Tum_Saath_Ho_FULL_AUDIO_Song.mp3');;

<audio controls>
<source src="Agar_Tum_Saath_Ho_FULL_AUDIO_Song.ogg" type="audio/ogg">
<source src="Agar_Tum_Saath_Ho_FULL_AUDIO_Song.mp3" type="audio/mpeg">


The following is a sample script that can play a song_name file.

<audio controls id="song_name">
<source src="Agar_Tum_Saath_Ho_FULL_AUDIO_Song.mp3" type="audio/mpeg">
Your browser does not support the audio element.

<p>Click the buttons to play or pause the song_name.</p>

<button onclick="play()" type="button">Play </button>
<button onclick="pause()" type="button">Pause</button>

var fetchSongNm= document.getElementById("song_name");
function play() {;

function pause() {

I hope you get an idea about javascript play sound onclick.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.