转载于:https://blog.csdn.net/arvin0/article/details/81030345
"ZD_010101a_1" 为声音库链接
testSound(); var myInstance; function testSound() { createjs.Sound.stop(); // myInstance = playSound("ZD_010101a_1"); myInstance = createjs.Sound.play("ZD_010101a_1", createjs.Sound.INTERRUPT_EARLY, 0, 0, 2); myInstance.on("complete", handleSoundComplete); myInstance.on("loop", handleSoundLoop); myInstance.on("failed", handleSoundFailed); // myInstance.play({interrupt:createjs.Sound.INTERRUPT_ANY, loop:2, pan:0.5}); function handleSoundComplete(event) { } function handleSoundLoop(event) { // myInstance.volume = myInstance.volume * 0.5; } function handleSoundFailed(event) { } }
myInstance = createjs.Sound.play("ZD_010101a_1", createjs.Sound.INTERRUPT_EARLY, 0, 0, 2);
其中2是重复的次数
2.通过按钮控制声音暂停
myInstance.paused = true;
3.通过按钮控制声音继续播放
myInstance.paused = false;