How to stop a stream after .pipe()?

502 views Asked by At
const speaker = new Speaker({
          channels: 2,
          bitDepth: 16,
          sampleRate: 44100,
          device: null,
        });

stream.pipe(speaker);

I need it for break playing sound. Stream is instance of Readable.

1

There are 1 answers

3
Deep Kakkar On

stream.pipeline which claims to handle “forwarding errors and properly cleaning up and provide a callback when the pipeline is complete.”

Syntax

stream.pipeline(...streams, callback)
  • …streams: These are two or more streams which are to be piped together.
  • callback: This function is called when the pipeline is fully done and it shows an ‘error’ if the pipeline is not accomplished.

Here is a link to documentation.