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

jsmpeg.player.pause() not working properly #398

Open
YeonwooSung opened this issue Mar 31, 2022 · 3 comments
Open

jsmpeg.player.pause() not working properly #398

YeonwooSung opened this issue Mar 31, 2022 · 3 comments

Comments

@YeonwooSung
Copy link

Hi, I am currently using this library for displaying the rtsp stream that is sent by node.js server with node-rtsp-stream.
What I want to do is keep displaying the video stream on the canvas by using jsmpeg player, and pause/restart when the user press the button.
Since this library contains the pause(), stop(), and start() methods, I was trying to use those methods for implementing the functionalities.
However, for some reason pause() and stop() method never works on my code..

`var client;
var canvas;
var rtsp_player;

function init_rtsp_video_canvas() {
client = new WebSocket('ws://localhost:9999');
canvas = document.querySelector('canvas');
rtsp_player = new jsmpeg(client, {canvas: canvas, loop: true, autoplay: true});
}

function pause_rtsp_client() {
rtsp_player.pause();
}

function play_rtsp_client() {
rtsp_player.play();
}
`

Am I missing something or doing some stupid mistake?

@phoboslab
Copy link
Owner

.pause(), .stop() and .play() only work for static video files, not for streaming. I should probably mention this in the readme.

It's also debatable how theses should work. Sure .stop() should disconnect the WebSocket and when .play() is called reconnect again.

But what does .pause() do? Does it keep the WebSocket connection open and accumulate all incoming video data in a big buffer? How big is this buffer allowed to get? What happens when I call .play() again? Should it automatically "catch up" to realtime again? If not, we would probably need to have a function that does allow this - i.e. allow seeking in streaming video. This is big can of worms...

So, if you just want to en-/deable the video stream, the best solution right now would be to .destroy() the player when you want to stop it and create a new one, when you want to start again.

I'll look into supporting .stop() and .play() for WebSockets when I can find some more time!

@YeonwooSung
Copy link
Author

Ah, nice. Thanks for the reply!
Yeh, I thought maybe the play() and stop() method would not work for streaming.
And please let me know if you actually make play() and stop() working for the video stream!

@russellevans
Copy link

Thanks for this...it has been driving me nuts for days but makes real sense.

I do not know if it is an issue on my implementation but when I .destroy() the player I get this console error.

image

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