audiocogs / jsmad

Deprecated. Please use mp3.js.
https://github.com/audiocogs/mp3.js
124 stars 11 forks source link

playback finish is not handled properly #4

Open jussi-kalliokoski opened 12 years ago

jussi-kalliokoski commented 12 years ago

when a file's end is reached, jsmad throws

Uncaught Header decoding failed
Mad.Frame.decodeframe.js:366
refillplayer.js:62
(anonymous function)player.js:92
AUDIOLIB.SinkClass.processaudiolib.js:2550
bufferFill

then it starts throwing

Uncaught TypeError: Cannot read property 'flags' of null
Mad.Frame.decodeframe.js:362
refillplayer.js:62
(anonymous function)player.js:92
AUDIOLIB.SinkClass.processaudiolib.js:2550
bufferFill
nddrylliog commented 12 years ago

@jussi-kalliokoski How do you plan to fix that?

jussi-kalliokoski commented 12 years ago

I'm not sure yet, I was thinking of adding another check to see if we actually have a frame and a header, but maybe jsmad should let the developer know of the stream end somehow... A callback? Trigger stop? Imho, it would be best to do both, but can I tell if it's just buffering or if the stream really ended? Does stream have information on whether it's ended?

nddrylliog commented 12 years ago

@jussi-kalliokoski imho, the underlying I/O layer should let jsmad know whether it just ran out of buffer or that it reached the end of the stream. jsmad could then let devs know through callbacks, that's a good idea yes.