这里我有一段用于加载,播放和结束音频文件的代码。代码有2个html5事件。该代码适用于Firefox和IE,但没有音频事件适用于chrome。我正在使用chrome 28.0。请帮我解决一下。
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
// Put the link for any mp3 file in variable 'audiofile' to test the code
var audiofile = "http://www.w3schools.com/html/horse.mp3";
var audio = new Audio();
audio.src = audiofile;
audio.oncanplay = function (){
audio.play();
}
audio.onended = function(){
alert('Playing Done');
}
</script>
</body>
</html>