【发布时间】:2015-09-29 00:26:14
【问题描述】:
我使用最新的 SoundJS 0.6.1 以及 soundjs-NEXT 库测试了项目,得到了相同的结果。
在台式机上一切正常,我在 Android Chrome 上遇到了这个问题,在以下设备上进行了测试:Sony Xperia T、Asus fonepad 7。
其实我用的是所谓的音频精灵,这里是代码
//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});
}
但是在使用这个之后(音频标签已经存在于画布所在的同一页面中):
<!--HTML -->
<audio width="100%" height="30%" id="audio">
<source src="" type="audio/mp3">
Your browser does not support the audio tag.
</audio>
//jQuery
$("#audio")[0].src="music.mp3";
$("#audio")[0].load();
$("#someButton").click(function(e)
{
$("#audio")[0].play();
});
我不能用
createjs.Sound.play("sound1", {startTime: 1000, duration: 3400});
它没有错误,只是沉默。
【问题讨论】:
标签: jquery html html5-audio createjs soundjs