Convert byte[] to audio(mp3) using javascript - javascript

I'm storing several mp3 files in MS SQL Server'08 as BLOB objects (I use filestream). There's a WCF service which can send one of this objects to html client.
Preliminarily I convert BLOB to byte[] using ToArray().
How to convert incoming byte[] array to audio(mp3) and play it?This's only javascript/html on client.
I use SoundManager2 http://www.schillmania.com/projects/soundmanager2/
to play audio.
Thanks!

Related

How to convert image to byte array using js

I am trying to convert image to byte array using only javascript and send to api. I have found this answer but it only shows to convert to base64 then send it to server side. Are there any other ways to convert to byte array using js or I can't just send byte array to api ?

How to transfer aes key from js to java server?

I am trying to transfer AES key generate in js:
var AESkey = forge.random.getBytesSync(16);
exapmle if printed condsole i have "§½­üå8bdÈP"
but printed in my java server it is "—§‡½­\u001eüå8b\u000ed�\u0012P›"
(other data are ok)
I tried to get the bytes with Buffer.from(AESkey) but instead of getting a 16 bytes buffer I get a 22/24/25.. buffer lenghts.
In which format can I transfer the key and how can I get my AESkey to that format in js?
A possible solution:
make a base64 encoded string on client side
send base64-encoded string to server
decode base64 in Java to get the byte sequence back
This way the byte sequence can be safely transported.

send arraybuffer from angularjs to c# endpoint

I have an ArrayBuffer in angularjs that I am trying to send to my backend endpoint in c#, I thought it was a regular byte array but it's not mapping appropriately
What would an ArrayBuffer map to as an object in c# if not a byte[]?.
I have a PDF file represented as that ArrayBuffer but now I would like to send it to the server, or perhaps is there a way to convert that ArrayBuffer to a File type in JavaScript and send it o the endpoint so that I can use something like an IFormFile?.
Thank you
I had a situation of same some long days back. What I did was, I converted the array buffer data to base 64 string in the js side and sent it to the backend c# code using post method,and again I decoded it to array buffer to regenerate the file on server side. By this way I achieved the mapping.
I used this code which helps to convert the array buffer to base 64 string in JS.
and this api of .net framework to convert back the base 64 string to file buffer.
I hope this would help you.

Save javascript BLOB to database through java

I am currently doing a sound recording using JavaScript and I have a BLOB URL data as an output.
Is there anywhere that I can send this data and save it in Database through java using Input Stream?
Sample of BLOB URL DATA which was generated after recoding the audio:
blob:http://127.0.0.1:8888/363f3a17-81d0-4f4d-915c-8d01d288b8bc

Understanding AudioBuffer to ArrayBuffer conversion

I have an AudioBuffer client-side that I'd like to AJAX to a express server.
This link shows how a XMLHttpRequest can send/receive binary data - ArrayBuffer.
An ArrayBuffer is different to an AudioBuffer (or so I believe) as I decoded an ArrayBuffer to make the AudioBuffer in the first place. This was done using decodeAudioData() as part of the Web Audio API.
So my question is, can I convert an AudioBuffer back to an ArrayBuffer?
If this is possible, I'd like to then send the ArrayBuffer to my express server and then forward it on to a S3 bucket as shown in this example.
In that example, the code PUTs a Buffer in a S3 bucket created via a fs.readFileSync(). I assume the difference between a Buffer and ArrayBuffer wont be an issue with S3 :S
Use the copyFromChannel method, then convert the Float32Array to an ArrayBuffer.
var myArrayBuffer = audioCtx.createBuffer(2, frameCount, audioCtx.sampleRate);
var anotherArray = new Float32Array();
myArrayBuffer.copyFromChannel(anotherArray,1,0);

Categories