尝试使用SoundJS和jQuery's可选择,但声音不;我不在萤火虫上工作

Trying to use SoundJS and jQuery's selectable but the sound doesn't work on firefox

本文关键字:声音 工作 萤火虫 可选择 SoundJS jQuery      更新时间:2023-09-26

这是我的问题,我试图使用SoundJS(我以前使用过几次的库)和jQuery的Selectable库,第二部分是Selectable的所有功能都在工作,SoundJS功能只在GOOGLE CHROME上工作,在Opera中"有时"工作(如果我将声音更改为.ogg格式)。

现在,在SoundJS文档中,说我可以使用"creatjs.Sound.alternateExtensions =["ogg"]或mp3,这就是我实际工作的方式:mp3文件,它们在firefox中"更改"为.ogg…但这次它不起作用…所以,我将把函数留在这里,这样你就可以看到发生了什么,并帮助我。

谢谢。

    function creandoSonido()
{
    createjs.Sound.alternateExtensions = ["ogg"];
    var manifestSonidoMal = [{ id:"idSonidoMal", src: sonidoMal}];
    createjs.Sound.registerManifest(manifestSonidoMal, "");
    console.log(manifestSonidoMal);
    var manifestSonidoBien = [{ id:"idSonidoBien", src: sonidoBien}];
    createjs.Sound.registerManifest(manifestSonidoBien, "");
}
function sonidoIncorrecto()
{
    createjs.Sound.play("idSonidoMal");
}
function sonidoCorrecto()
{
    createjs.Sound.play("idSonidoBien");
}

当然,在必要的时候,我会调用函数"sonidoCorrecto()"answers"sonidIncorrecto())"来播放它

谢谢。

Firefox有一个已知的问题(在SoundJS文档中指出),它将无法播放mp3。目前的解决方法是将.ogg作为主要声音文件,并将alternateExtensions设置为mp3。还要注意,ogg和mp3文件都需要在同一个文件夹中。

最后一点,你没有正确使用清单。这样会更有效率:

var manifest = [{ id:"idSonidoMal", src: sonidoMal},
              { id:"idSonidoBien", src: sonidoBien}];
createjs.Sound.registerManifest(manifest , "");

希望能有所帮助。