Let's say I am storing an audio file in the database and later on I would want to use that BLOB or binary in my application.
<audio src ="${sessionScope.user.music}">
Where ${sessionScope.user.music}
returns a binary data that has been retrieve from the database.
would it be possible to load an audio file in an audio tag, using binary data instead of a uri? or path?
A bit like inline images:
<img src="data:image/gif;base64,R0lGODlhEAAOALMAAOazToeHh0tLS/7LZv/0jvb29t/
f3//Ub//ge8WSLf/rhf/3kdbW1mxsbP//mf///yH5BAAAAAAALAAAAAAQAA4AAARe8L1Ekyky67
QZ1hLnjM5UUde0ECwLJoExKcppV0aCcGCmTIHEIUEqjgaORCMxIC6e0CcguWw6aFjsVMkkIr7g7
7ZKPJjPZqIyd7sJAgVGoEGv2xsBxqNgYPj/gAwXEQA7"
width="16" height="14" alt="embedded folder icon">
Where this works for <img>
, I am far from sure that data:audio/mp3;base64, ...
(or audio/ogg
) would work. It is not in my HTML5 reference.
For the encoding, see JEditorPane with inline Image.
i was in need to inline large amounts (some MB) of binary data for threejs 3D display.
This is what i came up with:
<img src="data:image/png;base64,....">
to include that into the html5 fileI don't know if this works to provide binary music data also, but the question wasn't mentioning music data and it might be helpful for others who stranded here like me looking for general solutions to include binary data into HTML5 :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With