Okazari/Rythm.js

CORS error on remote mp3

mpint opened this issue · 2 comments

mpint commented

Hello, I'm getting the following error when fetching audio sources from remote servers with the following code:

rythm.setMusic('https://archive.org/download/testmp3testfile/mpthreetest.mp3');

MediaElementAudioSource outputs zeroes due to CORS access restrictions for https://archive.org/download/testmp3testfile/mpthreetest.mp3

Any thoughts on how to resolve this?

Hey @MPin .
CORS errors are due to server not allowing browser to fetch the ressource without being on an authorized domain name.

You have like three solutions :

  • Add a backend proxy to your page : and configure it the way that calling myserver/proxy/archive/* will redirect the call to https://archive.org/*

  • Move the ressource to your own server (if this ressource is free to use)

  • If you are the maintainer of the archive.org website, add CORS authorization for your front-end domain name.

Unfortunatly, rythm.js is not in cause here.
Hope it helped ;)

If your audio file has the correct CORS headers (solution 3 above), you may still need to do:

rythm.player.audio.crossOrigin = "anonymous";

after you call the setMusic() function. (more info)