如何在Firefox、IE的SoundJS中正确设置位置

How to set position correctly in SoundJS for Firefox, IE

本文关键字:设置 位置 SoundJS Firefox IE      更新时间:2023-09-26

我正在尝试使用SoundJS来播放sn mp3文件并寻找特定的位置。我正在使用:

instance.setPosition(10000);

它在Google Chrome中正常工作。但在Mozilla Firefox中,我听到声音从正确的位置播放,第二个声音也从另一个位置播放。

在Internet Explorer中,声音会从头开始播放。

这是一个jsFiddle(带有自动播放声音),这里是完整的javascript:

createjs.Sound.registerPlugins([createjs.WebAudioPlugin, createjs.HTMLAudioPlugin, createjs.FlashPlugin]);
createjs.Sound.addEventListener("fileload", handleLoad);
createjs.Sound.registerSound("http://ivdemo.chaseits.co.uk/enron/20050204-4026(7550490)a.mp3", "sound");
function handleLoad(event) {
    var instance = createjs.Sound.play("sound");
    var ten = document.getElementById('ten-secs');
    ten.addEventListener('click', function (event) {
        instance.setPosition(10000);
    });
}

我在Firefox和IE上做错了什么?

正如我在您的另一个问题中所评论的,SoundJS的早期版本中存在一个错误,应该在github上的最新版本中修复。您可以使用TestSuite示例自己测试这种行为。

很好地使用了jsfiddle来演示这个问题,由

希望能有所帮助。