web/LdtPlayer-release.js
changeset 12 dbcb0dc6a844
parent 10 c0bfbc7be078
child 15 6d9cd6f47d95
equal deleted inserted replaced
11:cdfe29ce64da 12:dbcb0dc6a844
  8668       });
  8668       });
  8669     }
  8669     }
  8670 };
  8670 };
  8671 
  8671 
  8672 
  8672 
  8673 IriSP.annotation_template = "{{! template for an annotation displayed in a segmentWidget }}<div title='{{divTitle}}' id='{{id}}'	class='Ldt-iri-chapter' 	style='left: {{startPourcent}}%;          width: {{endPourcent}}%;          background:#{{hexa_color}};' 	></div>";
  8673 IriSP.annotation_template = "{{! template for an annotation displayed in a segmentWidget }}<div title='{{divTitle}}' id='{{id}}'	class='Ldt-iri-chapter' 	style='left: {{startPourcent}}%;          width: {{endPourcent}}%;          background-color:#{{hexa_color}};' 	></div>";
  8674 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 class='Ldt-fbShare' href=''><img src='{{img_dir}}/facebook.png' alt='share on facebook'></img></a>         <a class='Ldt-TwShare' href=''><img src='{{img_dir}}/twitter.png' alt='share on twitter'></img></a>         <a class='Ldt-GplusShare' href=''><img src='{{img_dir}}/google.png' alt='share on google+'></img></a>      </div>		  <div class='Ldt-SaTitle'></div>	  	<div class='Ldt-SaDescription'></div>    </div>  </div></div>";
  8674 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 class='Ldt-fbShare' href=''><img src='{{img_dir}}/facebook.png' alt='share on facebook'></img></a>         <a class='Ldt-TwShare' href=''><img src='{{img_dir}}/twitter.png' alt='share on twitter'></img></a>         <a class='Ldt-GplusShare' href=''><img src='{{img_dir}}/google.png' alt='share on google+'></img></a>      </div>		  <div class='Ldt-SaTitle'></div>	  	<div class='Ldt-SaDescription'></div>    </div>  </div></div>";
  8675 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>";
  8675 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>";
  8676 IriSP.arrowWidget_template = "<div class='Ldt-arrowWidget'></div>";
  8676 IriSP.arrowWidget_template = "<div class='Ldt-arrowWidget'></div>";
  8677 IriSP.overlay_marker_template = "{{! the template for the small white bars which is z-indexed over our segment widget }}<div class='positionMarker'></div>";
  8677 IriSP.overlay_marker_template = "{{! the template for the small white bars which is z-indexed over our segment widget }}<div class='positionMarker'></div>";
  8678 IriSP.player_template = "{{! template for the radio player }}<div class='Ldt-controler demo'>	<div class='Ldt-LeftPlayerControls'>    <div class='Ldt-button Ldt-CtrlPlay'></div>		<div class='Ldt-button Ldt-CtrlAnnotate'></div>    <div class='Ldt-button Ldt-CtrlSearch'></div>	</div>		<div class='Ldt-RightPlayerControls'>    <div class='Ldt-Time'>      <div class='Ldt-ElapsedTime'></div>      <div class='Ldt-TimeSeparator'>/</div>      <div class='Ldt-TotalTime'></div>    </div>		<div class='Ldt-button Ldt-CtrlSound'></div>	</div></div>";
  8678 IriSP.player_template = "{{! template for the radio player }}<div class='Ldt-controler demo'>	<div class='Ldt-LeftPlayerControls'>    <div class='Ldt-button Ldt-CtrlPlay'></div>		<div class='Ldt-button Ldt-CtrlAnnotate'></div>    <div class='Ldt-button Ldt-CtrlSearch'></div>	</div>		<div class='Ldt-RightPlayerControls'>    <div class='Ldt-Time'>      <div class='Ldt-ElapsedTime'></div>      <div class='Ldt-TimeSeparator'>/</div>      <div class='Ldt-TotalTime'></div>    </div>		<div class='Ldt-button Ldt-CtrlSound'></div>	</div></div>";
  8979 	 while (dec>15){
  8979 	 while (dec>15){
  8980 		  tmp = dec-(Math.floor(dec/16))*16;
  8980 		  tmp = dec-(Math.floor(dec/16))*16;
  8981 		  hex = hexa.charAt(tmp)+hex;
  8981 		  hex = hexa.charAt(tmp)+hex;
  8982 		  dec = Math.floor(dec/16);
  8982 		  dec = Math.floor(dec/16);
  8983 	 }
  8983 	 }
  8984 	 hex = hexa.charAt(dec)+hex;
  8984 	 hex = hexa.charAt(dec)+hex;	 
  8985 	 if (hex == "FFCC00"){ hex="";/* by default color of Ldt annotation */ }
       
  8986 	 return(hex);
  8985 	 return(hex);
  8987 };
  8986 };
  8988 
  8987 
  8989 /* shortcut to have global variables in templates */
  8988 /* shortcut to have global variables in templates */
  8990 IriSP.templToHTML = function(template, values) {
  8989 IriSP.templToHTML = function(template, values) {
 10491 
 10490 
 10492       endPourcent -= onePxPercent;
 10491       endPourcent -= onePxPercent;
 10493     }
 10492     }
 10494     
 10493     
 10495     var divTitle = annotation.content.title.substr(0,55);
 10494     var divTitle = annotation.content.title.substr(0,55);
 10496     var color = annotation.content.color
 10495 
 10497 
 10496     if (typeof(annotation.content.color) !== "undefined")
 10498 
 10497       var color = annotation.content.color;
       
 10498     else
       
 10499       var color = annotation.color;
       
 10500     
       
 10501     var hexa_color = IriSP.DEC_HEXA_COLOR(color);
       
 10502     console.log(hexa_color);
       
 10503     if (hexa_color === "FFCC00")
       
 10504       hexa_color = "333";
       
 10505     
 10499     var annotationTemplate = Mustache.to_html(IriSP.annotation_template,
 10506     var annotationTemplate = Mustache.to_html(IriSP.annotation_template,
 10500         {"divTitle" : divTitle, "id" : id, "startPourcent" : startPourcent,
 10507         {"divTitle" : divTitle, "id" : id, "startPourcent" : startPourcent,
 10501         "endPourcent" : endPourcent, "hexa_color" : IriSP.DEC_HEXA_COLOR(color),
 10508         "endPourcent" : endPourcent, "hexa_color" : hexa_color,
 10502         "seekPlace" : Math.round(begin/1000)});
 10509         "seekPlace" : Math.round(begin/1000)});
 10503 
 10510 
 10504 
 10511 
 10505     this.selector.append(annotationTemplate);
 10512     this.selector.append(annotationTemplate);
 10506 
 10513 
 10536   }
 10543   }
 10537 };
 10544 };
 10538 
 10545 
 10539 /* restores the view after a search */
 10546 /* restores the view after a search */
 10540 IriSP.SegmentsWidget.prototype.clear = function() {
 10547 IriSP.SegmentsWidget.prototype.clear = function() {
 10541   this.selector.children(".Ldt-iri-chapter").css('border','none').animate({opacity:0.3}, 100);
 10548   //this.selector.children(".Ldt-iri-chapter").css('border','none').animate({opacity:0.3}, 100);
 10542 };
 10549 };
 10543 
 10550 
 10544 IriSP.SegmentsWidget.prototype.clickHandler = function(annotation) {
 10551 IriSP.SegmentsWidget.prototype.clickHandler = function(annotation) {
 10545   this._Popcorn.trigger("IriSP.SegmentsWidget.click", annotation.id);
 10552   this._Popcorn.trigger("IriSP.SegmentsWidget.click", annotation.id);
 10546   var begin = (+ annotation.begin) / 1000;
 10553   var begin = (+ annotation.begin) / 1000;
 10635   this._Popcorn.listen("IriSP.PlayerWidget.MouseOut", IriSP.wrap(this, this.mouseOutHandler));
 10642   this._Popcorn.listen("IriSP.PlayerWidget.MouseOut", IriSP.wrap(this, this.mouseOutHandler));
 10636 };
 10643 };
 10637 
 10644 
 10638 /* update the slider and the position marker as time passes */
 10645 /* update the slider and the position marker as time passes */
 10639 IriSP.SliderWidget.prototype.sliderUpdater = function() {
 10646 IriSP.SliderWidget.prototype.sliderUpdater = function() {
 10640   if(this.draggingOngoing)
 10647   if(this.draggingOngoing || this._disableUpdates)
 10641     return;
 10648     return;
 10642 
 10649   
 10643   var time = this._Popcorn.currentTime();
 10650   var time = this._Popcorn.currentTime();
 10644 
 10651 
 10645   var duration = this._serializer.currentMedia().meta["dc:duration"] / 1000;
 10652   var duration = this._serializer.currentMedia().meta["dc:duration"] / 1000;
 10646   var percent = ((time / duration) * 100).toFixed(2);
 10653   var percent = ((time / duration) * 100).toFixed(2);
 10647   
 10654   
 10727 //  this.selector.addClass("Ldt-SliderMinimized");
 10734 //  this.selector.addClass("Ldt-SliderMinimized");
 10728 
 10735 
 10729 };
 10736 };
 10730 
 10737 
 10731 // called when the user starts dragging the position indicator
 10738 // called when the user starts dragging the position indicator
 10732 IriSP.SliderWidget.prototype.positionMarkerDraggingStartedHandler = function(event, ui) {
 10739 IriSP.SliderWidget.prototype.positionMarkerDraggingStartedHandler = function(event, ui) {  
 10733   this.draggingOngoing = true;
 10740   this.draggingOngoing = true;
 10734 };
 10741 };
 10735 
 10742 
 10736 IriSP.SliderWidget.prototype.positionMarkerDraggedHandler = function(event, ui) {
 10743 IriSP.SliderWidget.prototype.positionMarkerDraggedHandler = function(event, ui) {
       
 10744   console.log(ui.offset.left);
       
 10745   this._disableUpdate = true; // disable slider position updates while dragging is ongoing.
       
 10746   window.setTimeout(IriSP.wrap(this, function() { this._disableUpdate = false; }), 500);
       
 10747   
 10737   var width = this.sliderBackground.width();
 10748   var width = this.sliderBackground.width();
 10738   var duration = this._serializer.currentMedia().meta["dc:duration"] / 1000;
 10749   var duration = this._serializer.currentMedia().meta["dc:duration"] / 1000;
 10739   var newTime = ((ui.offset.left / width) * duration).toFixed(2);
 10750   var newTime = ((ui.offset.left / width) * duration).toFixed(2);
 10740 
 10751 
 10741   this._Popcorn.currentTime(newTime);
 10752   this._Popcorn.currentTime(newTime);