src/js/widgets/segmentsWidget.js
branchpopcorn-port
changeset 835 a8af9da7c622
parent 834 573c7ca752e0
child 836 526f91f5253e
equal deleted inserted replaced
834:573c7ca752e0 835:a8af9da7c622
    24   this.selector.append(Mustache.to_html(IriSP.overlay_marker_template));
    24   this.selector.append(Mustache.to_html(IriSP.overlay_marker_template));
    25   
    25   
    26   this.positionMarker = this.selector.find(".Ldt-SegmentPositionMarker");
    26   this.positionMarker = this.selector.find(".Ldt-SegmentPositionMarker");
    27   
    27   
    28   this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.positionUpdater));
    28   this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.positionUpdater));
       
    29   var duration = this._serializer.getDuration();
       
    30   
    29   if (this.cinecast_version) {
    31   if (this.cinecast_version) {
    30       var _sourceMedia = IriSP.__jsonMetadata.medias[0],
       
    31         _mediaId = _sourceMedia.id,
       
    32         duration = IriSP.__jsonMetadata.medias[0].meta.duration;
       
    33       
       
    34       var segments_annotations = IriSP.underscore.filter(
    32       var segments_annotations = IriSP.underscore.filter(
    35           this._serializer._data.annotations,
    33           this._serializer._data.annotations,
    36           function(_a) {
    34           function(_a) {
    37               return _a.type == "cinecast:MovieExtract" && _a.media == _mediaId;
    35               return _a.type == "cinecast:MovieExtract";
    38           }
    36           }
    39       );
    37       );
    40   }
    38   }
    41   else {
    39   else {
    42 
    40 
    43     var duration = this._serializer.getDuration();
       
    44       var view_type = this._serializer.getChapitrage();
    41       var view_type = this._serializer.getChapitrage();
    45       if (typeof(view_type) === "undefined") {
    42       if (typeof(view_type) === "undefined") {
    46         view_type = this._serializer.getNonTweetIds()[0];  
    43         view_type = this._serializer.getNonTweetIds()[0];  
    47       }
    44       }
    48     
    45     
    67   var lastSegment = IriSP.underscore.max(segments_annotations, function(annotation) { return annotation.end; });
    64   var lastSegment = IriSP.underscore.max(segments_annotations, function(annotation) { return annotation.end; });
    68   
    65   
    69   for (i = 0; i < segments_annotations.length; i++) {
    66   for (i = 0; i < segments_annotations.length; i++) {
    70   
    67   
    71     var annotation = segments_annotations[i];
    68     var annotation = segments_annotations[i];
    72     var begin = (+ annotation.begin * (this.cinecast_version ? 1000 : 1));
    69     var begin = (+ annotation.begin);
    73     var end = (+ annotation.end * (this.cinecast_version ? 1000 : 1));
    70     var end = (+ annotation.end);
    74     var id = annotation.id;
    71     var id = annotation.id;
    75         
    72         
    76     var startPixel = Math.floor(_w * (begin / duration));
    73     var startPixel = Math.floor(_w * (begin / duration));
    77 
    74 
    78     var endPixel = Math.floor(_w * (end / duration));
    75     var endPixel = Math.floor(_w * (end / duration));
   190 IriSP.SegmentsWidget.prototype.searchFieldClosedHandler = function() {
   187 IriSP.SegmentsWidget.prototype.searchFieldClosedHandler = function() {
   191   this.clear();
   188   this.clear();
   192 };
   189 };
   193 
   190 
   194 IriSP.SegmentsWidget.prototype.positionUpdater = function() {  
   191 IriSP.SegmentsWidget.prototype.positionUpdater = function() {  
   195   if (this.cinecast_version) {
   192   var duration = this._serializer.getDuration() / 1000;
   196     var duration = IriSP.__jsonMetadata.medias[0].meta.duration;
       
   197   } else {
       
   198     var duration = this._serializer.getDuration() / 1000;
       
   199   }
       
   200   var time = this._Popcorn.currentTime();
   193   var time = this._Popcorn.currentTime();
   201   //var position 	= ((time / duration) * 100).toFixed(2);
   194   //var position 	= ((time / duration) * 100).toFixed(2);
   202   var position 	= ((time / duration) * 100).toFixed(2);
   195   var position 	= ((time / duration) * 100).toFixed(2);
   203 
   196 
   204   this.positionMarker.css("left", position + "%");  
   197   this.positionMarker.css("left", position + "%");