I trying to create some visualization for audio-stream. But I run into CORS trouble when I try get access to raw audio data with createMediaElementSource()
function.
Is there a way to avoid this restriction and get raw audio data from stream on other origins? Perhaps using WebSockets?
I trying to create some visualization for audio-stream. But I run into CORS trouble when I try get access to raw audio data with createMediaElementSource()
function.
Is there a way to avoid this restriction and get raw audio data from stream on other origins? Perhaps using WebSockets?
Share Improve this question edited Jun 2, 2015 at 21:46 user1693593 asked Jun 2, 2015 at 18:32 Alexey NikiforovAlexey Nikiforov 3771 gold badge6 silver badges14 bronze badges 2- 1 Use a server-side proxy script to download and server the file. Host JS and proxy on the same server. – Mikko Ohtamaa Commented Jun 2, 2015 at 18:34
- possible duplicate of Ways to circumvent the same-origin policy – Dave Commented Jun 2, 2015 at 21:49
1 Answer
Reset to default 8There are five ways to deal with the protections against cross-origin retrieval:
- CORS headers -- this is ideal, but you need the cooperation of the third-party server
- JSONP -- not appropriate for streaming content and you typically need the cooperation of the third-party server
- Iframes and inter-window munication -- probably not appropriate for streaming content and you need the cooperation of the third-party server
- Turning off browser protections -- you need to be running the browser in a custom mode, and you should not use that browser for anything else
- Server-side proxy -- paratively slow but often the only feasible option