-
-
Notifications
You must be signed in to change notification settings - Fork 653
Description
The short version: audio.canPlayType in Chromium on Ubuntu returns 'maybe' for 'mp3', and 'probably' for other extensions. If 'mp3' was a format given to me.audio.init, we get an error when trying to load the mp3, and then audio completely falls over. If we fell back to the other supported audio types it would work.
More specifically, I ran into this when going through the tutorial (using tutorial_final from the git repo, modified to use an un-minified build of the current melonJS)
Uncaught melonJS: failed loading stomp.mp3 melonJS-0.9.5.js:6833
I can get through the tutorial by changing the call to me.audio.init to pass only 'ogg', and not 'mp3'. But, to further investigate, I added some logging to detectCapabilities:
obj.detectCapabilities = function () {
// init some audio variables
var a = document.createElement('audio');
if (a.canPlayType) {
for (var c in obj.capabilities) {
var canPlay = a.canPlayType(obj.capabilities[c]);
console.log('capability', c, canPlay);
// convert the string to a boolean
obj.capabilities[c] = (canPlay !== "" && canPlay !== "no");
// enable sound if any of the audio format is supported
me.sys.sound |= obj.capabilities[c];
}
}Which gives this output on the console:
capability mp3 maybe melonJS-0.9.5.js:6951
capability ogg probably melonJS-0.9.5.js:6951
capability m4a probably melonJS-0.9.5.js:6951
capability wav probably
A couple reasonable solutions I see are to 1) modify getSupportedAudioFormat and/or obj.detectCapabilities to prioritize formats reported as 'probably' over those reported as 'maybe', and/or 2) modify soundLoadError to try other (possibly) supported formats if the preferred one fails to load.