var fs = require('fs');
var lame = require('lame');
var Speaker = require('speaker');
var $stream = fs.createReadStream('sounds/test.mp3').pipe(new lame.Decoder).pipe(new Speaker);
setTimeout(function() {
$stream.close();
}, 5000);
setTimeout(function() {
console.log('It worked!');
}, 10000);
This produces the following output. (Not 'It worked!' as expected.) Is there any way to stop the playing of a audio file?
node: pcm.c:1951: snd_pcm_bytes_to_frames: Assertion `pcm' failed.
Abgebrochen (Speicherabzug geschrieben)
Seems to work with .end, so maybe you aren't supposed to use close. Otherwise perhaps there is a bug in the library.
$stream.end();