I’m new to node.js and hyperdev, and all’s going great except…
-
I’m generating a small file in /tmp/file.mp3 successfully, but referring to it as gives a 404. I tried app.use(express.static('tmp)); but that doesn’t help; I seem to be able to refer to the file from server.js to create it, read it, etc., but can’t find a way to access from a client html page.
-
Instead I refer to it as for which I’ve created an endpoint:
app.get("/i_stream", function (request, response) {
var stat = fs.statSync(fnameStream);
response.setHeader(‘Content-Type’, ‘audio/mpeg’);
response.setHeader(‘Content-Length’, stat.size);
var readStream = fs.createReadStream(fnameStream);
readStream.pipe(response);
});
and that works perfectly in IE 11, but in Chrome/Win and Chrome/Mac it plays through to the end, but the audio player seconds counter stops at 4 seconds and also stops emitting events after that point (the file is 8 seconds long). Also, while the mp3 files generated play fine in various players, there’s the above Chrome error, and also the audio file won’t play at all on iOS browser and Android 7 tablet Chrome browser, but it does play on Android Galaxy S7 phone Chrome browser.
I also tried jPlayer instead of native player and that too stops at 4 seconds using “/i_stream” endpoint.
I’m wondering if I run in plain node.js, w/o Hyperdev, and I could create the file in “public” and use “public” and then see the file from the client, that would help?
Sorry for the lengthy description, but I very much appreciate any help, and apologize for all newbieness!
Thanks,
Larry