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"); audio.play();
play audio in javascripts
var audio = new Audio('Agar_Tum_Saath_Ho_FULL_AUDIO_Song.mp3'); audio.play();
play audio javascripts
var bMusic = new Audio('Agar_Tum_Saath_Ho_FULL_AUDIO_Song.mp3') bMusic.play()
play a sound wiith js
var audio = new Audio('Agar_Tum_Saath_Ho_FULL_AUDIO_Song.mp3'); audio.play();
play sound in javascript
<script> function play() { var audio = new Audio('https://www.yourdomainname.net/media/hinndi/Agar_Tum_Saath_Ho_FULL_AUDIO_Song.mp3'); audio.play(); } </script> <button onclick-"play();">PLAY MY AUDIO</button>
javascript play audio
//play audio with from html audio element: document.getElementById('song_name').play(); //play audio with out html audio tag var myAudio = new Audio('Agar_Tum_Saath_Ho_FULL_AUDIO_Song.mp3'); myAudio.play();
<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"> </audio>
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. </audio> <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> <script> var fetchSongNm= document.getElementById("song_name"); function play() { fetchSongNm.play(); } function pause() { fetchSongNm.pause(); } </script>
I hope you get an idea about javascript play sound onclick.
I would like to have feedback on my infinityknow.com 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.