FIx tag editor when no tags are created
authorclebeaupin
Wed, 28 Apr 2010 17:30:07 +0200
changeset 94 fd776c2b3062
parent 93 8e4e2f2a2fdf
child 95 411b36a1912e
child 99 9b8f2cd7a078
FIx tag editor when no tags are created
web/thdProject/apps/frontend/modules/editor/templates/_player.php
web/thdProject/web/js/segmentation/tagtool.js
--- a/web/thdProject/apps/frontend/modules/editor/templates/_player.php	Wed Apr 28 17:20:48 2010 +0200
+++ b/web/thdProject/apps/frontend/modules/editor/templates/_player.php	Wed Apr 28 17:30:07 2010 +0200
@@ -72,14 +72,13 @@
 
 
                function playerLoaded(player) {
-
                    // Charge les tags
-    				$("#segmentMarkerButtons").css("opacity",1);
-                    $("#btMarkIn").removeAttr("disabled");
-                    $.getJSON("<?php echo url_for("@segmentListJson?film_slug={$film->getSlugUrl()}");?>", "", function(data) {
-                        tagTool.segments = data;
-                        tagTool.setupHandlers($f("player"));
-                        window.setTimeout("loadSegments()", 2000);
+    				       $("#segmentMarkerButtons").css("opacity",1);
+                   $("#btMarkIn").removeAttr("disabled");
+                   $.getJSON("<?php echo url_for("@segmentListJson?film_slug={$film->getSlugUrl()}");?>", "", function(data) {
+                       tagTool.segments = data;
+                       tagTool.setupHandlers($f("player"));
+                       window.setTimeout("loadSegments()", 2000);
                     });
 
                    tagTool.player = $f("player");
--- a/web/thdProject/web/js/segmentation/tagtool.js	Wed Apr 28 17:20:48 2010 +0200
+++ b/web/thdProject/web/js/segmentation/tagtool.js	Wed Apr 28 17:30:07 2010 +0200
@@ -61,23 +61,26 @@
     setupHandlers: function(player) {
 
         cuepoints = new Array();
+        
         for (seg in this.segments) {
             cuepoint = {time: parseInt(this.segments[seg]['in']), tag: this.segments[seg]['tags'].join(', ')};
             cuepoints.push(cuepoint);
             cuepoint = {time: parseInt(this.segments[seg]['out']), tag: this.segments[seg]['tags'].join(', '), out: 'true'};
             cuepoints.push(cuepoint);
         }
-        player.onCuepoint(cuepoints, function(clip, cuepoint) {
-            if (cuepoint.out) {
-                tagTool.removeTag(cuepoint.tag);
-                if (tagTool.stopOnSegment == cuepoint.time) {
-                    this.pause();
-                    tagTool.stopOnSegment = false;
-                }
-            } else {
-                tagTool.addTag(cuepoint.tag);
-            }
-        });
-
+        
+        if (cuepoints.length > 0) {
+	        player.onCuepoint(cuepoints, function(clip, cuepoint) {
+	            if (cuepoint.out) {
+	                tagTool.removeTag(cuepoint.tag);
+	                if (tagTool.stopOnSegment == cuepoint.time) {
+	                    this.pause();
+	                    tagTool.stopOnSegment = false;
+	                }
+	            } else {
+	                tagTool.addTag(cuepoint.tag);
+	            }
+	        });
+        }
     }
 }
\ No newline at end of file