I want to pipe data into an opusstream and play that opusstream continuously so can then do something like this. Only way I see doing that is through receiver.subscribe(...); but in my case, it's not really practical. Here is a small example of what I want to do:
let opusStream = //what do I enter here?
mixer.pipe(opusStream);
const audioPlayer = createAudioPlayer();
connection.subscribe(audioPlayer);
const resource = createAudioResource(opusStream, { inputType: StreamType.Opus });
audioPlayer.play(resource);
I get the data through a speaking event which then fires the following code:
function playStream(receiver, userId) {
const audioStream = receiver.subscribe(userId, { end: { behavior: EndBehaviorType.AfterSilence, duration: 200 } });
const input = mixer.input({ volume: 75 });
audioStream
.on("data", (chunk) => {
const buffer = encoder.decode(chunk);
input.write(buffer);
})
.on("error", (err) => {
console.log(err)
})
.on("end", () => {
mixer.removeInput(input);
});
}
And "mixer" is then the stream which I want to output, since it mixes all user receiver together into one stream.