Skip to content Skip to sidebar Skip to footer

Web Audio- Streaming File From Server To Client

I'm trying to stream audio from a server containing an audio file to a client using BinaryJS. My code was inspired by the code in this question: Playing PCM stream from Web Audio A

Solution 1:

I think the issue here is that you're accessing file.length, while file is a Stream object which I don't think have a length property. So what you're doing is basically saying

newInt16Array(undefined);

and hence the type error.

fs.createReadStream is documented here; https://nodejs.org/api/fs.html#fs_fs_createreadstream_path_options

You can use the Stream object to read data in chunks using stream.read(256), as documented here; https://nodejs.org/api/stream.html#stream_readable_read_size

Hopefully that gives you enough pointers to proceed!

Post a Comment for "Web Audio- Streaming File From Server To Client"