Merge with upstream
authorhamidouk
Thu, 09 Feb 2012 12:09:37 +0100
changeset 547 7f0a19cf1d3d
parent 546 0e27f37afd2f (diff)
parent 545 96ca8ff7d7cc (current diff)
child 548 f051a2432970
Merge with upstream
Binary file src/ldt/ldt/static/ldt/css/imgs/user_default_icon.png has changed
Binary file src/ldt/ldt/static/ldt/css/imgs/video_sequence.png has changed
--- a/src/ldt/ldt/static/ldt/js/LdtPlayer-release.js	Thu Feb 09 11:48:48 2012 +0100
+++ b/src/ldt/ldt/static/ldt/js/LdtPlayer-release.js	Thu Feb 09 12:09:37 2012 +0100
@@ -1090,7 +1090,7 @@
 IriSP.annotation_template = "{{! template for an annotation displayed in a segmentWidget }}<div title='{{divTitle}}' id='{{id}}'	class='Ldt-iri-chapter' 	style='left: {{startPixel}}px;          width: {{pxWidth}}px;          background-color:#{{hexa_color}};' 	></div>";
 IriSP.annotationWidget_template = "{{! template for the annotation widget }}<div class='Ldt-AnnotationsWidget'>  <!-- ugly div because we want to have a double border -->  <div class='Ldt-Annotation-DoubleBorder'>      <div class='Ldt-AnnotationContent'>          <div class='Ldt-AnnotationShareIcons'>         <a target='_blank' class='Ldt-fbShare' title='share on facebook'></a>         <a target='_blank' class='Ldt-TwShare' title='share on twitter'></a>         <a target='_blank'  class='Ldt-GplusShare' title='share on google+'></a>        </div>        <div class='Ldt-SaTitle'></div>        <div class='Ldt-SaDescription'></div>        <div class='Ldt-SaKeywords'></div>    </div>  </div></div>";
 IriSP.annotation_loading_template = "{{! template shown while the annotation widget is loading }}<div id='Ldt-load-container'><div id='Ldt-loader'>&nbsp;</div> Chargement... </div>";
-IriSP.annotationsListWidget_template = "{{! template for the annotation list widget }}<div class='Ldt-AnnotationsListWidget'>  <!-- ugly div because we want to have a double border -->  <div class='Ldt-Annotation-DoubleBorder'>    <ul>    {{#annotations}}      <li>        {{! if the url is not present, it means that the annotation exists             in the current project }}        {{^url}}        <a href='#id={{id}}'>        {{/url}}        {{! otherwise link to url }}        {{#url}}        <a href='{{url}}#id={{id}}'>        {{/url}}          <div style='overflow: auto; margin-top: 5px; margin-bottom: 5px;'>            <div class='Ldt-AnnotationsList-Caption'>              <img src='http://i.imgur.com/aoUlC.jpg'></img>            </div>            <div class='Ldt-AnnotationsList-Duration'>{{begin}} - {{end}}</div>            <div class='Ldt-AnnotationsList-Title'>{{title}}</div>            <div class='Ldt-AnnotationsList-Description'>{{desc}}</div>          </div>        </a>      </li>    {{/annotations}}    </ul>  </div></div>";
+IriSP.annotationsListWidget_template = "{{! template for the annotation list widget }}<div class='Ldt-AnnotationsListWidget'>  <!-- ugly div because we want to have a double border -->  <div class='Ldt-Annotation-DoubleBorder'>    <ul>    {{#annotations}}      <li>        {{! if the url is not present, it means that the annotation exists             in the current project }}        {{^url}}        <a href='#id={{id}}'>        {{/url}}        {{! otherwise link to url }}        {{#url}}        <a href='{{url}}#id={{id}}'>        {{/url}}          <div style='overflow: auto; margin-top: 5px; margin-bottom: 5px;'>            <div class='Ldt-AnnotationsList-Caption'>              <img src='{{img_dir}}/video_sequence.png'></img>            </div>            <div class='Ldt-AnnotationsList-Duration'>{{begin}} - {{end}}</div>            <div class='Ldt-AnnotationsList-Title'>{{title}}</div>            <div class='Ldt-AnnotationsList-Description'>{{desc}}</div>          </div>        </a>      </li>    {{/annotations}}    </ul>  </div></div>";
 IriSP.arrowWidget_template = "<div class='Ldt-arrowWidget'></div>";
 IriSP.createAnnotationWidget_template = "{{! template for the annotation creation widget }}<div class='Ldt-createAnnotationWidget'>  <!-- ugly div because we want to have a double border -->  <div class='Ldt-createAnnotation-DoubleBorder'>    <div class='Ldt-createAnnotation-startScreen'>      <div style='margin-bottom: 7px; overflow: auto;'>        <div class='Ldt-createAnnotation-Title'></div>        <div class='Ldt-createAnnotation-TimeFrame'></div>        {{^cinecast_version}}          <div class='Ldt-createAnnotation-Minimize' title='Cancel'></div>        {{/cinecast_version}}      </div>            <div class='Ldt-createAnnotation-Container'>        <textarea class='Ldt-createAnnotation-Description'></textarea>        <div class='Ldt-createAnnotation-profileArrow'>                  </div>        <div class='Ldt-createAnnotation-userAvatar'>        {{^user_avatar}}          <img src='https://si0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png'></img>        {{/user_avatar}}        {{#user_avatar}}          <img src='{{ user_avatar }}'></img>        {{/user_avatar}}        </div>      </div>      <div class='Ldt-createAnnotation-submitButton'>        <div style='position: absolute; bottom: 5px; right: 5px;'>Submit</div>      </div>      <div class='Ldt-createAnnotation-keywords'>        Add keywords :             </div>      {{#polemic_mode}}      <div class='Ldt-createAnnotation-polemics'>        Add polemic keywords           </div>      {{/polemic_mode}}    </div>    <div class='Ldt-createAnnotation-waitScreen' style='display: none; text-align: center'>      <img src='{{img_dir}}/spinner.gif'></img>      Please wait while your request is being processed...    </div>    <div class='Ldt-createAnnotation-errorScreen' style='display: none; text-align: center'>      <div class='Ldt-createAnnotation-Minimize' title='Hide'></div>      An error happened while contacting the server. Your annotation has not been saved.    </div>        <div class='Ldt-createAnnotation-endScreen' style='display: none'>      <div class='Ldt-createAnnotation-Minimize' title='Hide'></div>      Thank you, your annotation has been saved.<br>      Would you like to share it on social networks ?      <div style='margin-top: 12px; text-align: center;'>          <a target='_blank' class='Ldt-createAnnotation-endScreen-TweetLink'><img src='{{img_dir}}/tweet_button.png' style='margin-right: 20px;'></img></a>          <a target='_blank' class='Ldt-createAnnotation-endScreen-FbLink'><img src='{{img_dir}}/facebook_button.png' style='margin-right: 20px;'></img></a>          <a target='_blank' class='Ldt-createAnnotation-endScreen-GplusLink'><img src='{{img_dir}}/gplus_button.png' style='margin-right: 20px;'></img></a>                          </div>    </div>  </div></div>";
 IriSP.createAnnotationWidget_festivalCinecast_template = "{{! template for the annotation creation widget specific for the cinecast festival}}<div class='Ldt-createAnnotationWidget'>  <!-- ugly div because we want to have a double border -->  <div class='Ldt-createAnnotation-DoubleBorder'>    <div style='margin-bottom: 7px; overflow: auto;'>      <div class='Ldt-createAnnotation-Title'></div>      <div class='Ldt-createAnnotation-TimeFrame'></div>    </div>        <div class='Ldt-createAnnotation-Container'>      <textarea class='Ldt-createAnnotation-Description'></textarea>      <div class='Ldt-createAnnotation-profileArrow'>        <img src='{{img_dir}}/annotate_arrow.png'></img>      </div>      <div class='Ldt-createAnnotation-userAvatar'>                <img src='https://si0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png'></img>      </div>    </div>        <div class='Ldt-createAnnotation-keywords'>      Add keywords :           </div>              <div class='Ldt-createAnnotation-submitButton'>      <div style='position: absolute; bottom: 10pt; right: 11pt;'>Submit</div>    </div>        <div class='Ldt-createAnnotation-endScreen' style='display: none'>      Thank you, your annotation has been saved.<br>      Would you like to share it on social networks ?      <div style='margin-top: 12px; text-align: center;'>          <a target='_blank' class='Ldt-createAnnotation-endScreen-TweetLink'><img src='{{img_dir}}/tweet_button.png' style='margin-right: 20px;'></img></a>          <a target='_blank' class='Ldt-createAnnotation-endScreen-FbLink'><img src='{{img_dir}}/facebook_button.png' style='margin-right: 20px;'></img></a>          <a target='_blank' class='Ldt-createAnnotation-endScreen-GplusLink'><img src='{{img_dir}}/gplus_button.png' style='margin-right: 20px;'></img></a>                          </div>    </div>  </div></div>";
@@ -1731,17 +1731,22 @@
   "imgs": "/mdp/src/css/imgs"
 };
 
-IriSP.user = {
-  "name" : "loic",
-  "avatar" : "http://a1.twimg.com/profile_images/39270812/loicempuria_normal.jpg"
-};
-
 IriSP.defaults.default_templates_vars = function() { 
   return {
   "img_dir" : IriSP.paths.imgs 
   };
 }
 
+/*
+Override this if you want to change the info the player receives about the user.
+It's typically overrided in server-side templates with user-specific data.
+*/
+IriSP.defaults.user = function() {
+  return {
+      "name" : "Anonymous user",
+      "avatar" : IriSP.paths.imgs + "/user_default_icon.png"
+    }  
+};
 /* the widget classes and definitions */
 
 /**
@@ -2056,7 +2061,9 @@
 
 /** configure modules. @see configureWidgets */
 IriSP.configureModules = function (popcornInstance, modulesList) {
- 
+  if (IriSP.null_or_undefined(modulesList))
+    return;
+  
   var serialFactory = new IriSP.SerializerFactory(IriSP.__dataloader);
   var ret_modules = [];
   var index;
@@ -2145,6 +2152,11 @@
   IriSP.paths = IriSP.underscore.defaults(IriSP.paths, IriSP.defaults.paths);
   IriSP.default_templates_vars = IriSP.underscore.defaults(IriSP.default_templates_vars, 
                                        IriSP.defaults.default_templates_vars());
+
+  if (IriSP.null_or_undefined(IriSP.user))
+    IriSP.user = {};
+  
+  IriSP.user = IriSP.underscore.defaults(IriSP.user, IriSP.defaults.user());
 };
 
 /** single point of entry for the metadataplayer */
@@ -2165,31 +2177,62 @@
 
 /** jwplayer player wrapper */
 IriSP.PopcornReplacement.dailymotion = function(container, options) {
+    console.log("Calling");
     /* appel du parent pour initialiser les structures communes à tous les players */
-    IriSP.PopcornReplacement.player.call(this, container, options);
-
+    IriSP.PopcornReplacement.player.call(this, container, options);   
+    
     var _this = this;
 
     /* Définition des fonctions de l'API -  */
 
     this.playerFns = {
         play : function() {
-            return _this.player.playVideo();
+            if (_this.player) {
+                return _this.player.playVideo();
+            } else {
+                console.log("Play on undefined player");
+                return false;
+            }
         },
         pause : function() {
-            return _this.player.pauseVideo();
+            if (_this.player) {
+                return _this.player.pauseVideo();
+            } else {
+                console.log("Pause on undefined player");
+                return false;
+            }
         },
         getPosition : function() {
-            return _this.player.getCurrentTime();
+            if (_this.player) {
+                return _this.player.getCurrentTime();
+            } else {
+                console.log("getPosition on undefined player");
+                return 0;
+            }
         },
         seek : function(pos) {
-            return _this.player.seekTo(pos);
+            if (_this.player) {
+                return _this.player.seekTo(pos);
+            } else {
+                console.log("seek on undefined player");
+                return false;
+            }
         },
         getMute : function() {
-            return _this.player.isMuted();
+            if (_this.player) {
+                return _this.player.isMuted();
+            } else {
+                console.log("getMute on undefined player");
+                return false;
+            }
         },
         setMute : function(p) {
-            return p ? _this.player.mute() : _this.player.unMute();
+            if (_this.player) {
+                return p ? _this.player.mute() : _this.player.unMute();
+            } else {
+                console.log("setMute on undefined player");
+                return false;
+            }
         }
     }
 
@@ -2198,7 +2241,8 @@
     window.onDailymotionVideoProgress = IriSP.wrap(this, this.progressHandler);
 
     var params = {
-        allowScriptAccess : "always"
+        "allowScriptAccess" : "always",
+        "wmode": "opaque"
     };
     var atts = {
         id : this.container
@@ -2215,7 +2259,9 @@
     
     this.player.addEventListener("onStateChange", "onDailymotionStateChange");
     this.player.addEventListener("onVideoProgress", "onDailymotionVideoProgress");
-    this.player.loadVideoByUrl(this._options.video);
+    this.player.cueVideoByUrl(this._options.video);
+    
+    this.callbacks.onReady();
 };
 
 IriSP.PopcornReplacement.dailymotion.prototype.progressHandler = function(progressInfo) {
@@ -2237,16 +2283,19 @@
             break;
 
         case 3:
-            this.callbacks.onSeek();
+            this.callbacks.onSeek({
+                position: this.player.getCurrentTime()
+            });
             break;
 
+        /*
         case 5:
             this.callbacks.onReady();
             break;
+        */
     }
     
-};
-/* To wrap a player the develop should create a new class derived from 
+};/* To wrap a player the develop should create a new class derived from 
    the IriSP.PopcornReplacement.player and defining the correct functions */
 
 /** jwplayer player wrapper */
@@ -4668,9 +4717,16 @@
   var duration = +this._serializer.currentMedia().meta["dc:duration"];
   var time_step = Math.round(duration / num_columns); /* the time interval between two columns */
   var begin = +annotation.begin;
-  
-  var index = Math.floor(begin / time_step);
-  this._results[index]++;
+  var end = +annotation.end;
+  
+  /* increment all the values between the beginning and the end of the annotation */
+  var index_begin = Math.floor(begin / time_step);
+  var index_end = Math.floor(end / time_step);
+  
+  for (var i = index_begin; i < Math.min(index_end, this._results.length); i++) {
+    this._results[i]++;
+  }
+  
   this.selector.find(".Ldt-sparkLine").sparkline(this._results, {lineColor: "#7492b4", fillColor: "#aeaeb8",
                                                            spotColor: "#b70056",
                                                            width: this.width, height: this.height});