Open saknarak opened 7 months ago
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));
For anyone interested, I implemented a proof-of-concept of a frameTimeout
option in https://github.com/Koch-AG/flutter_mjpeg/commit/0d602e73988f63eb39e3699ba9d11adca3fcfa6b.
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.
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.