Skip to content
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

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

Open
void-soul opened this issue Jul 30, 2018 · 4 comments
Open

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

void-soul opened this issue Jul 30, 2018 · 4 comments
Assignees

Comments

@void-soul
Copy link

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

@lannymcnie lannymcnie self-assigned this Jul 30, 2018
@lannymcnie
Copy link
Member

lannymcnie commented Jul 30, 2018

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.

@tjutasi
Copy link

tjutasi commented May 26, 2020

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 ?

@lannymcnie
Copy link
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.

@tjutasi
Copy link

tjutasi commented May 26, 2020

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants