audiocogs / jsmad

Deprecated. Please use mp3.js.

Home Page:https://github.com/audiocogs/mp3.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

playback finish is not handled properly

jussi-kalliokoski opened this issue · comments

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

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

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?

@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.