<html>
<title>test</title>
<body bgcolor="Silver">
<audio id='audio1' src="audio.ogg" controls></audio>
<script>
var audio = document.getElementById('audio1');
var mediaElement = audio;
function playaudio() {
mediaElement.play();
}
audio.oncanplaythrough = function() {
document.title = 'ready_to_play';
}
audio.onended = function(e) {
document.title = 'ended';
}
</script>
<button id="button1" onclick="playaudio()">Click me</button>
</body>
</html>