admin管理员组

文章数量:1401632

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
Add a ment  | 

1 Answer 1

Reset to default 8

There are five ways to deal with the protections against cross-origin retrieval:

  1. CORS headers -- this is ideal, but you need the cooperation of the third-party server
  2. JSONP -- not appropriate for streaming content and you typically need the cooperation of the third-party server
  3. Iframes and inter-window munication -- probably not appropriate for streaming content and you need the cooperation of the third-party server
  4. 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
  5. Server-side proxy -- paratively slow but often the only feasible option

本文标签: javascriptHow can I avoid CORS restriction for web audio apiStack Overflow