DOM Exception 12 when trying to stream MP3 through websocket

微信扫一扫,分享到朋友圈

DOM Exception 12 when trying to stream MP3 through websocket

I am currently working on a small project where I want to split an mp3 into frames, send them to a client (browser) through a websocket and then play them back using WebAudio (webkitAudioContext). My server is running nodejs and to transfer the data as binary, I use binaryJS. The browser I am testing with is Chrome 25.0.1354.0 dev, running on Ubuntu 12.04.

I have gotten as far as successfully splitting the mp3 into frames, or, at least, based on my tests, it seems to work. If I write the frames back into a file, mplayer has no problem playing back the file and also parses the header correctly. Each frame is stored in a nodejs Buffer of the correct size and the last byte of the buffer is always the first byte before the next sync word.

As an initial test, I am only sending the first MP3 frame. The client receives the frame successfully (stored in an ArrayBuffer), and the buffer contains the correct data. However, when I call decode, I get the following message:

Uncaught Error: SyntaxError: DOM Exception 12

My function, where I call decodeAudio, looks like this:

streamDone = ->
    bArray = new Uint8Array(arr[0].byteLength)
    console.log "Stream is done, bytes", bArray.length
    context.decodeAudioData bArray, playAudio, err

The initial frame that I am trying to deocde, can be found here
.

I have been banging my head in the wall for a couple of days now trying to solve this. Has anyone managed to solve this and sucessfully decoded mp3 frames, and see what I do wrong? I have found two related question on StackOverflow, but the answers did not help me solve my problem. However, according to the accepted answer here
, my frame should qualify as a valid mp3 chunk and, thus, be decoded.

Thanks in advance for any help!

Problem courtesy of: Kristian Evensen

微信扫一扫,分享到朋友圈

DOM Exception 12 when trying to stream MP3 through websocket

Different value in the stored procedure and the return variable

上一篇

日辉信息:让每个城市都有自己的“滴滴”

下一篇

你也可能喜欢

DOM Exception 12 when trying to stream MP3 through websocket

长按储存图像,分享给朋友