perthcpe23 / android-mjpeg-view

Custom View to display MJPEG
MIT License
64 stars 20 forks source link

Feature : error callback interface #14

Closed tiger79 closed 1 year ago

tiger79 commented 1 year ago

Hi, I was wondering if as an extra feature an error callback interface could be implemented in the library. So when the library catches an error, for example not being able to connect to the stream, this could be returned using an interface to the app using the library. This would make it possible, in certain cases, to at least show a message or popup to the user or log the exception to file. The library is already logging, for example here : try { bis.close(); connection.disconnect(); Log.i(tag,"disconnected with " + url); } catch (Exception e) { if(e.getMessage() != null) { Log.e(tag, e.getMessage()); } }

And this is what is shown in Logcat :

2023-04-24 09:17:15.801 18640-19460/nl.organization.myapp E/MjpegView: Failed to connect to streamingserver.organization.nl/188.72.65.150:443 2023-04-24 09:17:15.802 18640-19460/nl.organization.myapp E/MjpegView: Attempt to invoke virtual method 'void java.io.BufferedInputStream.close()' on a null object reference

I also think there is a bug here, an exception gets thrown whilst trying to close bis object

perthcpe23 commented 1 year ago

Good idea!

punyapat-s commented 1 year ago

https://github.com/perthcpe23/android-mjpeg-view/releases/tag/v1.1.2

tiger79 commented 1 year ago

Thanks both for approving this rfc and the speedy implementation ! This helps out quite a lot, now that it's possible to log errors from within our app / local log files !