From: Calin Crisan Date: Sun, 1 Dec 2013 13:13:27 +0000 (+0200) Subject: added a checker for camera errors that get stuck on loading X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=504dd266d4db487c406becd8a89dd000491f3194;p=motioneye-debian added a checker for camera errors that get stuck on loading --- diff --git a/src/handlers.py b/src/handlers.py index b285aa2..ef4daed 100644 --- a/src/handlers.py +++ b/src/handlers.py @@ -629,6 +629,9 @@ class PictureHandler(BaseHandler): if camera_id not in config.get_camera_ids(): raise HTTPError(404, 'no such camera') + import time + time.sleep(100) + camera_config = config.get_camera(camera_id) if camera_config['@proto'] != 'v4l2': def on_response(response): diff --git a/static/js/main.js b/static/js/main.js index df7be01..c48a7ae 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -1904,6 +1904,20 @@ function refreshCameraFrames() { setTimeout(refreshCameraFrames, 100); } +function checkCameraErrors() { + /* properly triggers the onerror event on the cameras whose imgs were not successfully loaded, + * but the onerror event hasn't been triggered, for some reason (seems to happen in Chrome) */ + var cameraFrames = $('div.page-container').find('img.camera'); + + cameraFrames.each(function () { + if (this.complete === true && this.naturalWidth === 0 && !this.error) { + $(this).error(); + } + }); + + setTimeout(checkCameraErrors, 500); +} + /* startup function */ @@ -1935,5 +1949,6 @@ $(document).ready(function () { initUI(); fetchCurrentConfig(); refreshCameraFrames(); + checkCameraErrors(); });