Skip to content

The soundjs play failed when the source url is a RESTFUL api #306

Open

Description

@void-soul

Issue Details

  • Version used

Latest SoundJS 1.0.2
https://cdnjs.cloudflare.com/ajax/libs/SoundJS/1.0.2/soundjs.min.js

Whats happening:

When playing a sound from a RESTFUL api, the instanse's playstate is null (sometimes it's failed)

Demo here:
https://codepen.io/d925529/pen/gjomKd

Activity

  1. self-assigned this
    on Jul 30, 2018
  2. lannymcnie commented on Jul 30, 2018

    @lannymcnie
    Member

    This is mostly likely caused by the file path for your sound containing a query string (specifically "?"). This isn't incorrect, but PreloadJS/SoundJS doesn't accept it as a valid file path.

    Info for solving this:
    The PATH_PATTERN for PreloadJS is

    /^(?:(\w+:)\/{2}(\w+(?:\.\w+)*\/?))?([\/.]*?(?:[^?]+)?\/)?((?:[^\/?]+)\.(\w+))(?:\?(\S+)?)?$/
    

    Specifically, the _parsePath method returns false when it encounters this path.

    https://upload.emeker.com/?key=9398bd6f43b350cf72cf2e6155e31cb5e1cbf2ba.mp3&token=8fd185e927258830f9ed828d1bada179c8aeaeed159ccc1c906cc20667a44728d0afe7b579c49975911c3bb6ad06aace:3c9b6ad38729e04071de1377d5214589&name=bgm.mp3
    

    A saved RegExr pattern is here: https://regexr.com/3t6d0
    [Updated Link: https://regexr.com/343kr]

    Just accepting the query string may cause issues with other parts of PreloadJS/SoundJS, so it will need to be tested thoroughly.

  3. tjutasi commented on May 26, 2020

    @tjutasi

    I run into a similar problem, but the regexr link above takes me to the default page on regexr.
    Does happened something with this since 2018 ?

  4. lannymcnie commented on May 26, 2020

    @lannymcnie
    Member

    Nothing has changed in the library (see discussion here)

    The RegExr pattern can be found here: https://regexr.com/343kr - not sure why the old one no longer works.

  5. tjutasi commented on May 26, 2020

    @tjutasi

    Thank you, that regex patter doesn't work for me either, but removing the ? exclusion from the original pattern did the job.
    Will we see something about this consortium on createjs.com ? or here ? the slack link is not valid anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions