Skip to content

Commit

Permalink
[#153] Simplify the format check loop in getSupportedAudioFormat()
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Oster committed Feb 24, 2013
1 parent 38f0b59 commit 57bc938
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions src/audio/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,28 +64,18 @@
// check for sound support by the browser
if (me.sys.sound) {
var ext = "";
var i = 0;
// do a first loop and check for codec with
// the 'probably' canPlayType first
for (; i < len; i++) {
for (var i = 0; i < len; i++) {
ext = requestedFormat[i].toLowerCase().trim();
// check extension against detected capabilities
if (obj.capabilities[ext] &&
obj.capabilities[ext].canPlay &&
obj.capabilities[ext].canPlayType === 'probably') {
// get only the first valid OR first 'probably' playable codec
(result === "" || obj.capabilities[ext].canPlayType === 'probably' ||
) {

This comment has been minimized.

Copy link
@melonjs

melonjs Feb 24, 2013

Collaborator

@parasyte I did not try yet, but is this last OR "||" intentional ? Mistake or js Voodoo ?:)

This comment has been minimized.

Copy link
@parasyte

parasyte Feb 24, 2013

Collaborator

oops! mistake for sure! nice catch

result = ext;
break;
}
}
// loop again and check for all the rest ('maybe')
i = 0;
for (; i < len; i++) {
ext = requestedFormat[i].toLowerCase().trim();
// check extension against detected capabilities
if (obj.capabilities[ext] &&
obj.capabilities[ext].canPlay) {
result = ext;
break;
if (obj.capabilities[ext].canPlayType === 'probably') {
break;
}
}
}
}
Expand Down

0 comments on commit 57bc938

Please sign in to comment.