简体   繁体   English

如何在.pipe() 之后停止 stream?

[英]How to stop a stream after .pipe()?

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. Stream 是可读的实例。

stream.pipeline which claims to handle “forwarding errors and properly cleaning up and provide a callback when the pipeline is complete.” stream.pipeline声称可以处理“转发错误并正确清理并在管道完成时提供回调”。

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.回调:当管道完全完成时调用此 function,如果管道未完成,则显示“错误”。

Here is a link to documentation.这是文档的链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM