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

Is it possible to reconnect when stream is closed. #36

Open
saknarak opened this issue Jan 23, 2024 · 2 comments
Open

Is it possible to reconnect when stream is closed. #36

saknarak opened this issue Jan 23, 2024 · 2 comments

Comments

@saknarak
Copy link

How to reconnect/refresh when stream server is closed or restart

when image shown and then I restart my stream server
there is no error so I cannot refresh image

It's would be nice to have flag that try to reconnect to stream source.

@cybrox
Copy link
Contributor

cybrox commented Jan 24, 2024

A restartWhenClosed option would definitely be a good addition to the library!


In the meantime, you could create a timeout-timer that is reset by a frame pre-processor every time a frame is received.
If no new frame is received for a given duration, the widget is reloaded.

Something like:

class ResetTimeoutPreprocessor extends MjpegPreprocessor {
  /// The external timeout timer
  Timer timeoutTimer;

  ResetTimeoutPreprocessor(this.timer);

  @override
  List<int>? process(List<int> frame) {
    // reset timer here
    return frame;
  }

and

Mjpeg(stream: "...", preprocessor: ResetTimeoutPreprocessor(myTimer));

@cybrox
Copy link
Contributor

cybrox commented Mar 7, 2024

For anyone interested, I implemented a proof-of-concept of a frameTimeout option in Koch-AG@0d602e7.

I'll MR this as soon as we've tested it for a while and are sure it does not interfere with anything else. Unfortunately, I don't have a lot of time to work on this at the moment but the solution is functional and we're testing it in-house at the moment.

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

2 participants