Javascript examples for DOM HTML Element:Audio
The currentSrc property returns the URL of the current audio. If no audio is set, an empty string is returned.
This property is read-only.
A String, representing the URL of the current audio.
The following code shows how to Get the URL of the current audio:
<!DOCTYPE html> <html> <body> <audio id="myAudio" controls> <source src="your.ogg" type="audio/ogg"> <source src="your.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>/*from ww w.j a v a 2 s . c o m*/ <button onclick="myFunction()">get the URL of the current audio</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myAudio").currentSrc; document.getElementById("demo").innerHTML = x; } </script> </body> </html>