src/js/widgets/createAnnotationWidget.js
branchpopcorn-port
changeset 678 45385e19022a
parent 651 c43441822b1b
child 682 10a52271579d
equal deleted inserted replaced
677:2f3ab8896fa1 678:45385e19022a
    22 };
    22 };
    23 
    23 
    24 IriSP.createAnnotationWidget.prototype.draw = function() {
    24 IriSP.createAnnotationWidget.prototype.draw = function() {
    25   var _this = this;
    25   var _this = this;
    26 
    26 
    27   if (this.cinecast_version) {    
    27   var annotationMarkup = IriSP.templToHTML(IriSP.createAnnotationWidget_template);
    28     var annotationMarkup = IriSP.templToHTML(IriSP.createAnnotationWidget_festivalCinecast_template);
       
    29   } else {
       
    30     var annotationMarkup = IriSP.templToHTML(IriSP.createAnnotationWidget_template);
       
    31   }
       
    32   
    28   
    33 	this.selector.append(annotationMarkup);
    29 	this.selector.append(annotationMarkup);
    34   
    30   
    35   if (!this.cinecast_version)
    31   if (!this.cinecast_version)
    36     this.selector.hide();
    32     this.selector.hide();
   239                       }
   235                       }
   240                    }));
   236                    }));
   241   } else {
   237   } else {
   242     this.showWaitScreen();
   238     this.showWaitScreen();
   243     
   239     
   244     this.sendLdtData(contents, function() {
   240     this.sendLdtData(contents, function(annotation) {
   245                     if (_this.cinecast_version) {
   241                     if (_this.cinecast_version) {
   246                         if (_this._Popcorn.media.paused)
   242                         if (_this._Popcorn.media.paused)
   247                           _this._Popcorn.play();
   243                           _this._Popcorn.play();
   248                     }
   244                     }
   249 
   245 
   250                     _this.showEndScreen();
   246                     _this.showEndScreen(annotation);
   251                     window.setTimeout(IriSP.wrap(_this, function() { this.showStartScreen(); }), 5000);
   247                     if (_this.cinecast_version) {
       
   248                       window.setTimeout(IriSP.wrap(_this, function() { this.showStartScreen(); }), 5000);
       
   249                     }
       
   250                     
   252                     });
   251                     });
   253   }
   252   }
   254 };
   253 };
   255 
   254 
   256 IriSP.createAnnotationWidget.prototype.handleSliderChanges = function(params) {
   255 IriSP.createAnnotationWidget.prototype.handleSliderChanges = function(params) {
   263   var apiJson = {annotations : [{}], meta: {}};
   262   var apiJson = {annotations : [{}], meta: {}};
   264   var annotation = apiJson["annotations"][0];
   263   var annotation = apiJson["annotations"][0];
   265   
   264   
   266   annotation["media"] = this._serializer.currentMedia()["id"];
   265   annotation["media"] = this._serializer.currentMedia()["id"];
   267   
   266   
   268   if (this.cinecast_version) {
   267   if (this.cinecast_version) {   
   269     if (typeof(this._currentAnnotation) !== "undefined") {
   268       annotation["begin"] = Math.round(this._Popcorn.currentTime() * 1000 - 10000);
   270       annotation["begin"] = this._currentAnnotation.begin;
   269       annotation["end"] = Math.round(this._Popcorn.currentTime() * 1000 + 10000);
   271       annotation["end"] = this._currentAnnotation.end;
   270       if (annotation["begin"] < 0)
   272     }
   271         annotation["begin"] = 0;
       
   272       
       
   273       if (annotation["end"] > this._serializer.currentMedia().meta["dc:duration"])
       
   274         annotation["end"] = this._serializer.currentMedia().meta["dc:duration"];
       
   275       
   273   } else {
   276   } else {
   274     var duration = +this._serializer.currentMedia().meta["dc:duration"];    
   277     var duration = +this._serializer.currentMedia().meta["dc:duration"];    
   275     annotation["begin"] = +((duration * (this.sliceLeft / 100)).toFixed(0));
   278     annotation["begin"] = +((duration * (this.sliceLeft / 100)).toFixed(0));
   276     annotation["end"] = +((duration * ((this.sliceWidth + this.sliceLeft) / 100)).toFixed(0));
   279     annotation["end"] = +((duration * ((this.sliceWidth + this.sliceLeft) / 100)).toFixed(0));
   277   }
   280   }