html代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>soundJs的应用</title>
<script src="soundjs-0.6.0.min.js"></script>
</head>
<body>
<div>
<h1 id="status">播放</h1>
</div>
<script src="sound.js"></script>
</body>
</html>
js代码:
var displayStatus;
displayStatus=document.getElementById("status");
src="3.mp4";
createjs.Sound.alternateExtensions=["mp4"];
createjs.Sound.addEventListener("fileload",playSound);
createjs.Sound.registerSound(src);
displayStatus.innerHTML="等待加载...";
function playSound(e){
soundInstance=createjs.Sound.play(e.src);
displayStatus.innerHTML="播放资源:"+ e.src;
}