want to play audio and it should be stop after 10 seconds inHtml and javascript?

I am new in Html5 and javascript I want to play audio clip when i open html page and it should be stop after 10 seconds and display message that Audio play successfully.

for simple audio play in html5 as below

<!DOCTYPE html>

<audio controls>
  <source src="kill_bill.mp3" type="audio/mpeg">
Your browser does not support the audio element.
setInterval(function(), 10000);

$.each($('audio'), function () { this.stop(); alert('Audio Stop Successfully'); });




A setTimeout seems more appropriate :

var audio = document.createElement("audio");
audio.src = "sound.mp3";

audio.addEventListener("canplaythrough", function () {
            alert("Audio Stop Successfully");
}, false); 


first of all pay attention, automatic play won't work under iOS; as Apple prevents it to be possible; as for stopping audio, I always suggest to use mediaelement library, which supports non HTML5 browsers and has a complete interface to start/stop audio playback

Need Your Help

Multiple headers for a table wx Python

python wxpython wx

Howdi folks, I have recently started dabbling in WX widgets using Python and would like to seek some direction on a task I want to achieve. The challenge here is to have a table with multiple headers

Shannon's Entropy calculation

matlab statistics probability information-theory

I have a probability distribution that defines the probability of occurrence of n possible states.