196 this._Popcorn.trigger("IriSP.ArrowWidget.blockArrow"); |
196 this._Popcorn.trigger("IriSP.ArrowWidget.blockArrow"); |
197 |
197 |
198 var duration = +this._serializer.currentMedia().meta["dc:duration"]; |
198 var duration = +this._serializer.currentMedia().meta["dc:duration"]; |
199 |
199 |
200 var currentChapter = this._serializer.currentChapitre(currentTime); |
200 var currentChapter = this._serializer.currentChapitre(currentTime); |
201 if (IriSP.null_or_undefined(currentChapter)) { |
201 |
|
202 if (IriSP.null_or_undefined(currentChapter)) { |
202 var left = this.selector.width() / 2; |
203 var left = this.selector.width() / 2; |
203 var width = this.selector.width() / 10; |
204 var width = this.selector.width() / 10; |
204 } else { |
205 } else { |
205 var left = (currentChapter.begin / duration) * this.selector.width(); |
206 var left = (currentChapter.begin / duration) * this.selector.width(); |
206 var width = (currentChapter.end / duration) * this.selector.width() - left; |
207 var width = (currentChapter.end / duration) * this.selector.width() - left; |
207 } |
208 } |
208 |
209 |
209 this.sliceLeft = left; |
210 // slider position and length is kept in percents. |
210 this.sliceWidth = width; |
211 this.sliceLeft = (left / this.selector.width()) * 100; |
|
212 this.sliceWidth = (width / this.selector.width()) * 100; |
|
213 |
211 this._Popcorn.trigger("IriSP.SliceWidget.position", [left, width]); |
214 this._Popcorn.trigger("IriSP.SliceWidget.position", [left, width]); |
212 this._Popcorn.listen("IriSP.SliceWidget.zoneChange", IriSP.wrap(this, this.handleSliderChanges)); |
215 this._Popcorn.listen("IriSP.SliceWidget.zoneChange", IriSP.wrap(this, this.handleSliderChanges)); |
213 this._Popcorn.trigger("IriSP.SliceWidget.show"); |
216 this._Popcorn.trigger("IriSP.SliceWidget.show"); |
214 |
217 |
215 if (!IriSP.null_or_undefined(currentChapter)) { |
218 if (!IriSP.null_or_undefined(currentChapter)) { |
362 annotation["media"] = this._serializer.currentMedia()["id"]; |
365 annotation["media"] = this._serializer.currentMedia()["id"]; |
363 var duration_part = Math.round(this._serializer.currentMedia().meta["dc:duration"] / 20); |
366 var duration_part = Math.round(this._serializer.currentMedia().meta["dc:duration"] / 20); |
364 |
367 |
365 if (this.cinecast_version) { |
368 if (this.cinecast_version) { |
366 annotation["begin"] = Math.round(this._Popcorn.currentTime() * 1000 - duration_part); |
369 annotation["begin"] = Math.round(this._Popcorn.currentTime() * 1000 - duration_part); |
367 annotation["end"] = Math.round(this._Popcorn.currentTime() * 1000 + duration_part); |
370 annotation["end"] = Math.round(this._Popcorn.currentTime() * 1000 + duration_part); |
368 if (annotation["begin"] < 0) |
|
369 annotation["begin"] = 0; |
|
370 |
|
371 if (annotation["end"] > this._serializer.currentMedia().meta["dc:duration"]) |
|
372 annotation["end"] = this._serializer.currentMedia().meta["dc:duration"]; |
|
373 |
|
374 } else { |
371 } else { |
375 var duration = +this._serializer.currentMedia().meta["dc:duration"]; |
372 var duration = +this._serializer.currentMedia().meta["dc:duration"]; |
376 annotation["begin"] = +((duration * (this.sliceLeft / 100)).toFixed(0)); |
373 annotation["begin"] = +((duration * (this.sliceLeft / 100)).toFixed(0)); |
377 annotation["end"] = +((duration * ((this.sliceWidth + this.sliceLeft) / 100)).toFixed(0)); |
374 annotation["end"] = +((duration * ((this.sliceWidth + this.sliceLeft) / 100)).toFixed(0)); |
378 } |
375 } |
|
376 |
|
377 // boundary checks |
|
378 if (annotation["begin"] < 0) |
|
379 annotation["begin"] = 0; |
|
380 |
|
381 if (annotation["end"] > this._serializer.currentMedia().meta["dc:duration"]) |
|
382 annotation["end"] = this._serializer.currentMedia().meta["dc:duration"]; |
|
383 |
379 |
384 |
380 annotation["type"] = this._serializer.getContributions(); |
385 annotation["type"] = this._serializer.getContributions(); |
381 if (typeof(annotation["type"]) === "undefined") |
386 if (typeof(annotation["type"]) === "undefined") |
382 annotation["type"] = ""; |
387 annotation["type"] = ""; |
383 |
388 |