Audio play() Method - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Audio

Description

The play() method starts playing the current audio.

Parameters

None

Return Value

No return value

An audio player with play and pause buttons:

Demo Code

ResultView the demo in separate window

<!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  w ww.  jav a  2 s.c o  m*/

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myAudio");
    document.getElementById("demo").innerHTML = "Start: " + x.played.start(0) + " End: " + x.played.end(0);
}
</script>

</body>
</html>

Related Tutorials