new version of the player, and a different wire pattern.
authorhamidouk
Fri, 13 Jan 2012 10:07:16 +0100
changeset 378 5f6012d0a7ac
parent 362 4fea77d5154a
child 379 4af2a8d56916
new version of the player, and a different wire pattern. also enabled the non-cinecast mode.
src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_player.html
src/ldt/ldt/static/ldt/css/imgs/wire_pattern.png
src/ldt/ldt/static/ldt/js/LdtPlayer-release.js
--- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_player.html	Thu Jan 12 16:11:21 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_player.html	Fri Jan 13 10:07:16 2012 +0100
@@ -28,6 +28,8 @@
   
   IriSP.paths["imgs"] = "{{WEB_URL}}{{LDT_MEDIA_PREFIX}}css/imgs";
   IriSP.default_templates_vars["img_dir"] = IriSP.paths.imgs;
+  IriSP.widgetsDefaults["createAnnotationWidget"].cinecast_version = false;
+  
     var config = {            
         gui:{
             width:{{ player_width }},             
@@ -75,7 +77,14 @@
                 type:'empty'
               }
              }],
-            },           
+            },
+            {type: "SliceWidget", // please note that type refers directly to the constructor of the widget.
+             mode: "radio",
+             metadata:{
+              format:'cinelab',
+              src:'{{ json_url }}',
+              type:'json'}
+            },            
             {type: "ArrowWidget",
              metadata:{
               format:'cinelab',
Binary file src/ldt/ldt/static/ldt/css/imgs/wire_pattern.png has changed
--- a/src/ldt/ldt/static/ldt/js/LdtPlayer-release.js	Thu Jan 12 16:11:21 2012 +0100
+++ b/src/ldt/ldt/static/ldt/js/LdtPlayer-release.js	Fri Jan 13 10:07:16 2012 +0100
@@ -2483,6 +2483,12 @@
   this.keywords = IriSP.widgetsDefaults["createAnnotationWidget"].keywords;
   this.cinecast_version = IriSP.widgetsDefaults["createAnnotationWidget"].cinecast_version;
   this.ids = {}; /* a dictionnary linking buttons ids to keywords */
+  
+  /* variables to save the current position of the slicer */
+  if (this.cinecast_version) {
+    this.sliceLeft = 0;
+    this.sliceWidth = 0;
+  }
 };
 
 
@@ -2614,13 +2620,22 @@
     
     // block the arrow.
     this._Popcorn.trigger("IriSP.ArrowWidget.blockArrow");
+    
     var duration = +this._serializer.currentMedia().meta["dc:duration"];
+        
     var currentChapter = this._serializer.currentChapitre(currentTime);
-    console.log(currentTime);
-    var left = (currentChapter.begin / duration) * this.selector.width();
-    var width = (currentChapter.end / duration) * this.selector.width() - left;
-    console.log([left, width]);
+    if (typeof(currentChapter) === "undefined") {
+      var left = this.selector.width() / 2;
+      var width = this.selector.width() / 10;
+    } else {
+      var left = (currentChapter.begin / duration) * this.selector.width();
+      var width = (currentChapter.end / duration) * this.selector.width() - left;
+    }
+    
+    this.sliceLeft = left;
+    this.sliceWidth = width;
     this._Popcorn.trigger("IriSP.SliceWidget.position", [left, width]);
+    this._Popcorn.listen("IriSP.SliceWidget.zoneChange", IriSP.wrap(this, this.handleSliderChanges));
     this._Popcorn.trigger("IriSP.SliceWidget.show");
   }
 };
@@ -2715,14 +2730,29 @@
   }
 };
 
+IriSP.createAnnotationWidget.prototype.handleSliderChanges = function(params) {
+  this.sliceLeft = param[0];
+  this.sliceWidth = param[1];
+};
+
 IriSP.createAnnotationWidget.prototype.sendLdtData = function(contents, callback) {
   var _this = this;
   var apiJson = {annotations : [{}], meta: {}};
   var annotation = apiJson["annotations"][0];
   
   annotation["media"] = this._serializer.currentMedia()["id"];
-  annotation["begin"] = this._currentAnnotation.begin;
-  annotation["end"] = this._currentAnnotation.end;
+  
+  if (this.cinecast_version) {
+    if (typeof(this._currentAnnotation) !== "undefined") {
+      annotation["begin"] = this._currentAnnotation.begin;
+      annotation["end"] = this._currentAnnotation.end;
+    }
+  } else {
+    var duration = +this._serializer.currentMedia().meta["dc:duration"];
+    annotation["begin"] = duration * (this.sliceLeft / 100);
+    annotation["end"] = duration * ((this.sliceWidth + this.sliceLeft) / 100);
+  }
+  
   annotation["type"] = this._serializer.getContributions();
   if (typeof(annotation["type"]) === "undefined")
     annotation["type"] = "";