Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stopping stream #88

Open
KuntilBogel opened this issue Apr 22, 2024 · 6 comments
Open

stopping stream #88

KuntilBogel opened this issue Apr 22, 2024 · 6 comments

Comments

@KuntilBogel
Copy link

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
Copy link
Owner

dank074 commented Apr 22, 2024

Wrote a snippet that does what you are looking for some time ago:
#16 (comment)

@KuntilBogel
Copy link
Author

Ah thanks!

@KuntilBogel
Copy link
Author

@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
Copy link
Collaborator

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
Copy link
Owner

dank074 commented Apr 23, 2024

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
Copy link
Collaborator

longnguyen2004 commented Apr 24, 2024

Maybe

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants