9

For some small hacking project I would like to load the raw data of an MP3 into an ArrayBuffer.

<audio src="http://xyz.com/test.mp3">

I know that there are some basic functions exposed by an <audio> element but I was not able to find what I'm looking for. It is very likely that if there is such thing it is part of the Web Audio API and only works in Chrome by now.

1 Answer 1

2

You cannot access raw data of HTML5 <audio> element.

What you can do is

  • Load data via AJAX

  • Grab raw data from the result for your internal purposes

  • Pass data forward to audio element (probably need to do data-uri here)

But for this kind on manipulation I recommend using Web Audio API instead of <audio>:

http://www.html5rocks.com/en/tutorials/webaudio/intro/

Firefox support should land in few iterations.

Sign up to request clarification or add additional context in comments.

6 Comments

The problem with that is that the audio data is coming from a different origin. I thought that it might be possible to ship around that problem by using the <audio> tag. Thanks for your fast answer!
Fix your different origin to use CORS headers developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS
Unfortunately I don't have this level of access to the different origin. (Thats why I've been looking into other possible options like using the <audio> tag.)
Then you are working against Internet security model.... unless you set up a proxy server it is impossible to grab data. Otherwise you could steal data off any server with user cookie priviledges.
Any updates on this in these modern times or still not possible?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.