Node.js stop playing audio


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() {
}, 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)
Problem courtesy of: MeinAccount


Seems to work with .end, so maybe you aren't supposed to use close. Otherwise perhaps there is a bug in the library.

Solution courtesy of: loganfsmyth


There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.