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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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