dank074 / Discord-video-stream

Experiment for making video streaming work for discord selfbots.
185 stars 35 forks source link

stopping stream #88

Open KuntilBogel opened 7 months ago

KuntilBogel commented 7 months ago

heya is there anyway to stop a stream, replace the streamed video with a new one and start streaming again thanks, I've tried using command.kill but command is always undefined

dank074 commented 7 months ago

Wrote a snippet that does what you are looking for some time ago: https://github.com/dank074/Discord-video-stream/issues/16#issuecomment-1659295075

KuntilBogel commented 7 months ago

Ah thanks!

KuntilBogel commented 7 months ago

@dank074 Heya, when I'm using the solution on the provided comment I still can't stop the video, console.log(command) is giving me undefined even though there's already a stream ongoing

longnguyen2004 commented 7 months ago

Also some words about code quality: Seeing command being a "global" variable like that makes me uncomfortable. Maybe we can return the command directly from streamLivestreamVideo instead?

dank074 commented 7 months ago

Also some words about code quality: Seeing command being a "global" variable like that makes me uncomfortable. Maybe we can return the command directly from streamLivestreamVideo instead?

Yeah we can definitely do that. I think I originally did it that way because the promise in streamLivestreamVideo doesn't resolve until the video is done streaming or errors. Need to think of a better way to do it

longnguyen2004 commented 7 months ago

Maybe

let command;
const playback = new Promise(/* do stuff */);
return { playback, command }

Or use p-cancelable, and completely hide the command from the user.