I am trying to serve a mp3 file using nodejs. The browser I am using is Google Chrome. Serving text worked but when I changed the content-heading to indicate that I want to serve mp3, it display a play button that does not play.
Here is the beginning of the information that curl -v
gives me:
* About to connect() to localhost port 2222 (#0)
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 2222 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost:2222
> Accept: */*
>
< HTTP/1.1 200 OK
< X-Powered-By: Express
< Content-Type: audio/mpeg
< Content-Length: 14180
< ETag: "336505275"
< Date: Mon, 02 Dec 2013 10:20:03 GMT
< Connection: keep-alive
<
��8��R�$s�PFP��0m(X�
���
�ep�8���Bg*&dXȯ��"�2.���c��7�f����G�
Does anyone have any idea what I am missing to make the audio I am serving play in Google Chrome?
Here is the relevant part of the server code:
express = require('express');
var app = express();
app.get('/', function (request, response) {
var exec = require('child_process').exec,
child;
child = exec('espeak -v mb-fr1 -q --pho -a 15 -p 50 -s 130 "donc ceci démontre que ça fonctionne bien" | mbrola /usr/share/mbrola/fr1/fr1 - - | lame -r -m m -b 24 -s 16 - - ',function (error, stdout, stderr) {
response.setHeader('Content-Type', 'audio/mpeg');
//response.setHeader('Transfer-Encoding', 'chunked');
response.send(stdout);
});
});
module.exports = app;