]> www.vanbest.org Git - motioneye-debian/commitdiff
- Add minor comments.
authorDermot Duffy <dermot.duffy@gmail.com>
Mon, 6 Jun 2016 19:33:01 +0000 (20:33 +0100)
committerDermot Duffy <dermot.duffy@gmail.com>
Mon, 6 Jun 2016 19:33:01 +0000 (20:33 +0100)
motioneye/handlers.py
motioneye/static/js/main.js

index 1d6d17ebbdb8ec06766b6a1ed9e609e5dbe199a0..63b67fdda03091eaf9b47baf5531e243e9e1e1ce 100644 (file)
@@ -1381,7 +1381,7 @@ class MovieHandler(BaseHandler):
             self.set_header('Content-Disposition', 'attachment; filename=' + pretty_filename + ';')
             self.set_header("Content-Length", content_length)
 
-
+            # Yield the data to the network in chunks.
             content = StaticFileHandler.get_content(full_path, start, end)
             if content:           
                 for chunk in content:
@@ -1397,8 +1397,12 @@ class MovieHandler(BaseHandler):
                 if error:
                     return self.finish_json({'error': 'Failed to download movie from %(url)s: %(msg)s.' % {
                             'url': remote.pretty_camera_url(camera_config), 'msg': error}})
-
-                self.set_status(response.code)
+               # Copy certain critical headers out of the remote response and
+               # into our response. Propogating these headers are necessary to
+               # support in-brower playback of remote movies. Also copy the 
+                # response code which might be 200 or 206 (partial content, for range
+                # requests).
+               self.set_status(response.code)
                 for header in ('Content-Type', 'Content-Range', 'Content-Length', 'Content-Disposition'):
                     if header in response.headers:
                         self.set_header(header, response.headers[header])
index 3c1fa13c3d336bfc1fffb78da310c64c09e8a310..8c45c815c64f59d07d87803e360826b3a604406b 100644 (file)
@@ -2950,6 +2950,8 @@ function runPictureDialog(entries, pos, mediaType) {
         prevArrow.css('display', 'none');
         nextArrow.css('display', 'none');
 
+        /* Construct a likely mime-type with 'video/' and the file extension, then see if the 
+           browser can play it */       
         var playable = video_container.get(0).canPlayType('video/' + entry.path.split('.').pop()) != ''
         playButton.hide();
         video_container.hide();
@@ -2966,11 +2968,11 @@ function runPictureDialog(entries, pos, mediaType) {
          playButton.on('click', function() {
             video_source.attr('src', addAuthParams('GET', basePath + mediaType + '/' + entry.cameraId + '/download' + entry.path));
             video_container.show();
-            video_container.get(0).load();
+            video_container.get(0).load();  /* Must call load() after changing <video> source */
             img.hide();
             playButton.hide();
             video_container.on('canplay', function() {
-              video_container.get(0).play();
+              video_container.get(0).play();  /* Automatically play the video once the browser is ready */
             });
           });