p5.js-sound icon indicating copy to clipboard operation
p5.js-sound copied to clipboard

LoadSound CORS

Open zehuichen123 opened this issue 5 years ago • 8 comments

Nature of issue?

  • [ ] Found a bug
  • [ ] Existing feature enhancement
  • [√] New feature request

Most appropriate sub-area of p5.js?

  • [ ] Color
  • [ ] Core/Environment/Rendering
  • [ ] Data
  • [ ] Events
  • [ ] Image
  • [ ] IO
  • [ ] Math
  • [ ] Typography
  • [ ] Utilities
  • [ ] WebGL
  • [ ] Other (specify if possible)

Which platform were you using when you encountered this?

  • [ ] Mobile/Tablet (touch devices)
  • [ ] Desktop/Laptop
  • [ ] Others (specify if possible)

Details about the bug:

  • p5.js version:
  • Web browser and version:
  • Operating System:
  • Steps to reproduce this:

Feature enhancement details:

New feature details:

When I using loadSound from p5.sound, I met CORS error. I was wondering if p5.js can support loading music from online url.

zehuichen123 avatar Jun 10 '19 14:06 zehuichen123

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already.

welcome[bot] avatar Jun 10 '19 14:06 welcome[bot]

@limzykenneth is this issue open? i would to work on this issue. Can you please guide me a bit?

adrijshikhar avatar Feb 21 '20 19:02 adrijshikhar

@adrijshikhar Sorry I'm not familiar enough with p5.Sound to be working on it so I can't really answer your fully. This is a rather old issue and the first thing you can do is to try and replicate it to see if it is indeed a bug or not.

limzykenneth avatar Feb 21 '20 19:02 limzykenneth

Still a revelant issue. I can confirm

swirly avatar Oct 30 '20 19:10 swirly

@swirly Can you post a minimal example showing the issue?

limzykenneth avatar Oct 30 '20 19:10 limzykenneth

Just use openprocessing for testing https://www.openprocessing.org/sketch/995201 If you replace native html5 audio calls by p5sound, you will have CORS error on loadsound

swirly avatar Nov 02 '20 13:11 swirly

The audio source at the link you provided does not have CORS enable which means that the source website is not allowing the file to be used on other websites. The server will need to provide the relevant CORS headers for loadSound to work and I imagine not all sound site would be willing to enable that header (it will enable any other site to host their content as if it is their own).

limzykenneth avatar Nov 03 '20 10:11 limzykenneth

That's it, exactly. The problem is that if you use html5 native audio through javascript, it works. So loadsound explicitly need CORS while html5/vanillaJS can get without it.

Not really thrilling for a higher level API that should simplify developpers life.

swirly avatar Nov 12 '20 13:11 swirly