TooTallNate / node-speaker

Output PCM audio data to the speakers
655 stars 147 forks source link

Stop Audio Instantly #108

Open akashbudhia opened 6 years ago

akashbudhia commented 6 years ago

I pipe a local mp3 file stream via node-lame decoder to the node-speaker instance to play a local mp3 file. What would be the correct way to instantly stop the audio from playing?

var fs = require('fs');
var lame = require('lame');
var Speaker = require('speaker');

fs.createReadStream('audio.mp3').pipe(lame.Decoder()).pipe(new Speaker());
akashbudhia commented 6 years ago

+Bump

akashbudhia commented 6 years ago

+Bump

abigyani commented 5 years ago

Did you get the solution?

Radzell commented 3 years ago

any solution

LinusU commented 3 years ago

Open for suggestions on how an API for this would look!

euguuu commented 2 years ago

Did you get the solution?

lmoesch commented 2 years ago

My suggestion would be to write a custom throughput stream which accepts the piped data and processes them in a small buffered loop which you can stop via a custom control command. (true instant stop is not possible because the audio card uses an internal buffer. But with a size of 1024 samples and 44100 samples per second this is relatively short).