1) I use node -speaker and pause-stream as follows:
var mp3Stream = fs.createReadStream(__dirname + '/sounds/' + filename);
mp3Stream.pipe(new Lame.Decoder()).pipe(speaker);
function pause () {
if (isPlaying) {
mp3Stream.pipe(pauseStream.pause());
isPlaying = false;
}
}
and receive the audio stream is suspended only a few seconds after a pause (). How to use audio streams to prevent such buffering?
2) I switch the tracks as follows:
function play(params) {
if (isPlaying) {
speaker.end();
speaker = new Speaker({
channels: 2,
bitDepth: 16,
sampleRate: 44100
});
}
mp3Stream = fs.createReadStream(__dirname + '/sounds/' + params.filename);
mp3Stream.pipe(new Lame.Decoder()).pipe(speaker);
isPlaying = true;
}
Everything is fine? I am afraid that I will have memory leaks.
3) Is there an easy way to search for sound buffers?
Thank!
source
share