JamesKyburz/youtube-audio-stream

Pause or close before end of stream?

Closed this issue · 2 comments

Is it possible to interrupt this via your package or another way? Cannot seem to find an answer on stack overflow that works with this pipe flow.

Thanks!

I'm having the same issue. I am piping into a decoder, and I can end that, but that leaves an ffmpeg process left behind. In my use case, if users skip multiple tracks, then multiple ffmpeg processes show up in top and don't leave until node is exited.

mster commented

Hi there! Not sure if you're still interested in this issue or not.

I had success by calling the .close() function on the stream variable. When needing to end the specific song, sound, or track, I closed the stream associated with that variable.

Like their example:

var ytStream = stream(videoUrl).pipe(decoder()).pipe(speaker()); //this begins playing the sound
ytStream.close(); // ends sound and stream 

I'm not sure if this resolves the dilemma @ballparts was referring to. Hope it helps out though!