Jump to content

[BUG] Loading and Audio File With Query Paramaters


Vithar
 Share

Recommended Posts

I found a bug with loading audio files, and I am not a github member, so I couldn't report it there. If you add a query parameter after the audio URL, it is not removed from the extension variable, and will cause the canPlayAudio(extension) check to fail.

 

Example

 

url = 'Audio/mySong.mp3?v=1'

 

extension will be: 'mp3?v=1' but should be just 'mp3'

getAudioURL: function (urls) {        var extension;        if (typeof urls === 'string') { urls = [urls]; }        for (var i = 0; i < urls.length; i++)        {            extension = urls[i].toLowerCase();            extension = extension.substr((Math.max(0, extension.lastIndexOf(".")) || Infinity) + 1);                            if (this.game.device.canPlayAudio(extension))            {                return urls[i];            }        }        return null;    }

to fix this, I added a quick check, but there might be a more optimized way of doing this.

if(extension.indexOf("?") >= 0){        extension = extension.substr(0, extension.indexOf("?"));} 
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...