Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SoundJS not setting up properly on Firefox? #47

Closed
lukebitts opened this issue Apr 24, 2013 · 7 comments
Closed

SoundJS not setting up properly on Firefox? #47

lukebitts opened this issue Apr 24, 2013 · 7 comments

Comments

@lukebitts
Copy link

I'm using the following version of CreateJS: http://code.createjs.com/createjs-2013.02.12.min.js

My code runs fine on every browser, except Firefox. For some reason, if I upload the files to the server and run from there I get a "TypeError: g is null". If I run locally it works. Again, I don't have this problem on other browsers, even when the files are on the server.

Trying to find a solution to my problem I realized createjs.Sound.activePlugin is a [WebAudioPlugin] and its capabilities are null (that is the g above) whenever I'm accessing the files from the server.

My code is basically this:

var queue = new createjs.LoadQueue();
queue.installPlugin(createjs.Sound);
queue.addEventListener(...);
queue.loadManifest([{id:"sound1",src:"sound/ogg/sound1.ogg|sound/mp3/sound.mp3"}]);

The error is on this function:

c.parsePath = function (a, b, g, f) {
a = a.split(c.DELIMITER);
b = {
    type: b || "sound",
    id: g,
    data: f
};
g = c.getCapabilities();
f = 0;
for (var h = a.length; f < h; f++) {
    var k = a[f],
    m = k.match(c.FILE_PATTERN);
    if (null == m) return !1;
    var p = m[4],
    m = m[5];
    if (g[m] && -1 < c.SUPPORTED_EXTENSIONS.indexOf(m)) return b.name = p, b.src = k, b.extension = m, b
    }
    return null
};

The line with error is the if(g[m]...)

My firefox version is 20.0, I'm running it on Mac

@OJayRobinson
Copy link
Contributor

Hi Luke,
Thanks for the report. I tossed together a test case using the createjs library and the same loading code, and was unable to replicate the issue in firefox 20 on windows or mac. This makes me suspect the issue is happening somewhere else in the code, and seems to be something that is incorrectly telling Sound to set the active plugin to WebAudioPlugin. This could be manually through code, or the browser could be telling Sound that it supports web audio when it does not. The getCapabilities check looks for window.AudioContext and window.webkitAudioContext, so if either of these exist in your project it will make the web audio check return true when it should not.

For a simple test, you might try setting up the PreloadAndPlay example on your server and changing it to load the same createjs min library you are using. If it works, the problem is in the other code. If it does not work, the problem has something to do with the server. Especially if the example works locally.

Hopefully that helps.

@lukebitts
Copy link
Author

I'm not touching either of those, and they are both undefined on the javascript console (even locally, though I didn't expect webkitAudioContext to be defined.) My code really is as simple as the example I posted, but I'll try the PreloadAndPlay and see if that works :)

@lannymcnie
Copy link
Member

The error you mentioned will happen if there is no active Audio plugin. Firefox requires the HTML or Flash plugin - and the HTML plugin will be activated by default. Either your browser is indicating that it can not load HTML audio, or it thinks the plugins were already registered, but there are no plugins available.

In any place in your app are you registering audio plugins with SoundJS?

@lukebitts
Copy link
Author

No, I wasn't. Calling the following worked:
createjs.Sound.registerPlugins([createjs.HTMLAudioPlugin]);

Why other browsers work without this line?

And thanks for the help! :)

@lannymcnie
Copy link
Member

It seems like the parsing is happening before the built-in plugin registering is happening. A call stack would be really helpful to determine why this is happening. Firebug should be able to give you that.

Also, I recommend using this instead:

createjs.Sound.registerPlugins([createjs.WebAudioPlugin, createjs.HTMLAudioPlugin]);

@lukebitts
Copy link
Author

TypeError: g is null
anonymous()    create....min.js (line 4505)
dispatchEvent(b=Object { type="complete", target=[PreloadJS XHRLoader]}, g=undefined)    create....min.js (line 70)
_sendComplete()    create....min.js (line 4099)
_handleTagReady()    create....min.js (line 4801)
anonymous()    create....min.js (line 4505)
return a.apply(b, arguments)    create....min.js (line 4505)

The callstack is not very clear to me, but this is it. My createjs is a "beautified" version of the minified one by the way.

And adding the WebAudioPlugin before the HTMLAudioPlugin gives the same error as before.

@lannymcnie
Copy link
Member

Ah... Seems to me that WebAudio may be falsely reporting that it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants