我使用最新的SoundJS 0.6.1和soundjs-NEXT库测试了项目,结果相同。
在台式机上一切正常,在Android Chrome上存在此问题,并在以下设备上进行了测试:Sony Xperia T,Asus fonepad 7。
实际上我正在使用所谓的Audio Sprites,这是代码
//init
createjs.Sound.initializeDefaultPlugins();
var assetsPath = "./audio/";
var manifest = [{src:"someAudio.mp3", data: {audioSprite: [{id:"sound1"}]}}];
createjs.Sound.alternateExtensions = ["ogg"];
createjs.Sound.addEventListener("fileload", loadSound);
createjs.Sound.registerSounds(manifest, assetsPath);
function loadSound()
{
//
}
//plays without problem, until HTML5 audio tag is used
someItem.addEventListener("mousedown",playSprite,this);
function playSprite()
{
createjs.Sound.play("sound1", {startTime: 1000, duration: 3400});
}
但是,在使用此功能之后(音频标签已经存在于画布所在的同一页面中):
Your browser does not support the audio tag.
//jQuery
$("#audio")[0].src="music.mp3";
$("#audio")[0].load();
$("#someButton").click(function(e)
{
$("#audio")[0].play();
});
我不能用
createjs.Sound.play("sound1", {startTime: 1000, duration: 3400});
它没有错误,只是沉默。