0

I know you can store images as blob data and then have that blob data put within an image tag, which will display as it would with a regular image file. Is this possible with audio as well? I want to do this because I want it so that the audio is recorded, saved as blob data, and then sent to a server where then other users can access that blob data and replay the audio simply from that blob data.

2
  • Modern browser should accept a data: url for every element. Commented Mar 23, 2015 at 5:58
  • have you tried the htm <audio> tag? what did you get? Commented Mar 23, 2015 at 5:59

1 Answer 1

1

Yes, it is also possible with Audio - in browsers that implement Blob URLs, anyway.

The browser simply (and universally) knows how to 'read' blob URLs, as it does any valid URL. Only, instead of making a request it accesses the local blob cache.

Data URLs work in the same manner and are probably easier to use when 'transferring data from the server' - as their name implies they contain all the data embedded within the URL. For downloading previously shared content, consider keeping the Audio stream a separate resource and using normal URLs / resources.

Anyway, for the details like how to actually capture the data, see Capturing Audio & Video in HTML5.

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

2 Comments

The problem I had was when given the url, it seemed only to be a temporary thing when I left my browser tab that had the audio. Once it exited, the audio no longer exists. If I were to transfer the url to the server and someone else viewed the url, would they still hear the audio?
@user3864563 Well, that is a Blob URL.. it is a local non-persisted resource (basically a tag for a local cache entry). You must send the actual data back to the web-server and then send the actual data to other clients (who create their own local Blob URLs for the underlying data). This is why a Data URL is likely easier to deal with then doing this additional processing. Blob URLs can be converted to Data URLs and Data URLs contain all data.

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.