-
-
Notifications
You must be signed in to change notification settings - Fork 646
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
Audio subsystem fails if the first type it tries doesn't work #153
Comments
Thank you for the feedback, the way I see how to address this is through the audio init string as actually melonJS will try to initialize the audio using the specify format, using the specified priority (if you rather specify also modifying soundLoadError to revert to another audio format, is yes probably a good idea ;) |
I agree that'd be another improvement if the order of that string affected the priority, rather than the priority being hard-coded inside melonjs. It doesn't fix this issue in the general case though. Since e.g. a different browser might respond maybe/probably to both mp3 and ogg and then fail on the ogg file, so there'd be no one audio init string that worked for all browsers.
Yeah, that seems like the most robust way to address this issue (though it might also be the trickiest to implement cleanly). Affecting the format priority through the order of the init string as you suggest, or by trying the 'probably's before the 'maybe's as I suggested initially both might be sensible things to do, but even then you could still have this problem that for some browser the first format that does actually ends up getting tried doesn't work. |
@sporksmith |
… order of requested audio format was used as a priority (see #153)
I just added back the lost feature, where the order specified in the initialization string is used to define the format detection priority. Could you pull the last version and give it a try ? |
Pulled the latest. Yes, changing the init string from "mp3, ogg" to "ogg, mp3" now causes it to try ogg first and not fall over for this browser. Again though, I don't think this really addresses the underlying issue since for any given game there'll still be a fixed priority that will be tried for all browsers, and things will go badly if the first format tried doesn't work. |
@sporkmisth For the next step an easy way is probably to as well store the CanPlayType and do one first loop for the "probably" type, and if nothing found, a second one for the rest. |
…c support type, and prioritize codec being `probaby` supported
this last commit should do the trick, let me know what you think :) |
the test on 'probably' in the second loop can safely be removed, since anyway we will stop at the first one if any of the codec can 'probably' be played
closing this one, as I don't see any further issue following the last change |
Haven't had a chance to test it, but yeah this looks reasonable. Thanks! Just to play devil's advocate though, if some browser returns 'probably' for, say, 'wav' and 'maybe' for everything else, it'd probably be preferred to actually try loading the compressed files before falling back to 'wav'. I realize that's a messier change to make though, so possibly not worth worrying about until when/if it actually comes up. |
The short version:
audio.canPlayType
in Chromium on Ubuntu returns 'maybe' for 'mp3', and 'probably' for other extensions. If 'mp3' was a format given tome.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)
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 todetectCapabilities
:Which gives this output on the console:
A couple reasonable solutions I see are to 1) modify
getSupportedAudioFormat
and/orobj.detectCapabilities
to prioritize formats reported as 'probably' over those reported as 'maybe', and/or 2) modifysoundLoadError
to try other (possibly) supported formats if the preferred one fails to load.The text was updated successfully, but these errors were encountered: