【问题标题】:SoundJS doesn't plays after using usual html5 tag audio player使用通常的 html5 标签音频播放器后,SoundJS 不播放
【发布时间】: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


    【解决方案1】:

    我放弃了 SoundJs 并用完另一个音频库

    https://github.com/pupunzi/jquery.mb.audio

    支持“Audio Sprites”,更加灵活易用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-11
      • 2017-04-12
      • 1970-01-01
      • 2019-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多