src/js/model.js
changeset 1044 d8339b45edc4
parent 1026 420608a77566
child 1068 7623f9af9272
equal deleted inserted replaced
1043:967ac73327dc 1044:d8339b45edc4
   574     this.elementType = 'playable';
   574     this.elementType = 'playable';
   575     this.currentTime = new Time();
   575     this.currentTime = new Time();
   576     this.volume = .5;
   576     this.volume = .5;
   577     this.paused = true;
   577     this.paused = true;
   578     this.muted = false;
   578     this.muted = false;
       
   579     this.timeRange = false;
   579     this.loadedMetadata = false;
   580     this.loadedMetadata = false;
   580     var _this = this;
   581     var _this = this;
   581     this.on("play", function() {
   582     this.on("play", function() {
   582         _this.paused = false;
   583         _this.paused = false;
   583     });
   584     });
   598         }).forEach(function(_a) {
   599         }).forEach(function(_a) {
   599             _a.playing = true;
   600             _a.playing = true;
   600             _a.trigger("enter");
   601             _a.trigger("enter");
   601             _this.trigger("enter-annotation",_a);
   602             _this.trigger("enter-annotation",_a);
   602         });
   603         });
       
   604         
       
   605         if (_this.getTimeRange()){
       
   606             if (_this.getTimeRange()[0] > _time) {
       
   607                 _this.pause();
       
   608                 _this.setCurrentTime(_this.getTimeRange()[0]);
       
   609             }
       
   610             if (_this.getTimeRange()[1] < _time){
       
   611                 _this.pause();
       
   612                 _this.setCurrentTime(_this.getTimeRange()[1]);
       
   613             }
       
   614         }
       
   615         
   603     });
   616     });
   604     this.on("loadedmetadata", function() {
   617     this.on("loadedmetadata", function() {
   605         _this.loadedMetadata = true;
   618         _this.loadedMetadata = true;
   606     });
   619     });
   607 };
   620 };
   622 
   635 
   623 Playable.prototype.getMuted = function() {
   636 Playable.prototype.getMuted = function() {
   624     return this.muted;
   637     return this.muted;
   625 };
   638 };
   626 
   639 
       
   640 Playable.prototype.getTimeRange = function() {
       
   641     return this.timeRange;
       
   642 }
       
   643 
   627 Playable.prototype.setCurrentTime = function(_time) {
   644 Playable.prototype.setCurrentTime = function(_time) {
   628     this.trigger("setcurrenttime",_time);
   645     this.trigger("setcurrenttime",_time);
   629 };
   646 };
   630 
   647 
   631 Playable.prototype.setVolume = function(_vol) {
   648 Playable.prototype.setVolume = function(_vol) {
   634 
   651 
   635 Playable.prototype.setMuted = function(_muted) {
   652 Playable.prototype.setMuted = function(_muted) {
   636     this.trigger("setmuted",_muted);
   653     this.trigger("setmuted",_muted);
   637 };
   654 };
   638 
   655 
       
   656 Playable.prototype.setTimeRange = function(_timeBegin, _timeEnd) {
       
   657     if ((_timeBegin < _timeEnd)&&(_timeBegin >= 0)&&(_timeEnd>0)){
       
   658         return this.trigger("settimerange", [_timeBegin, _timeEnd]);
       
   659     }
       
   660 }
       
   661 
       
   662 Playable.prototype.resetTimeRange = function() {
       
   663     return this.trigger("resettimerange");
       
   664 }
       
   665 
   639 Playable.prototype.play = function() {
   666 Playable.prototype.play = function() {
   640     this.trigger("setplay");
   667     this.trigger("setplay");
   641 };
   668 };
   642 
   669 
   643 Playable.prototype.pause = function() {
   670 Playable.prototype.pause = function() {
   646 
   673 
   647 Playable.prototype.show = function() {};
   674 Playable.prototype.show = function() {};
   648 
   675 
   649 Playable.prototype.hide = function() {};
   676 Playable.prototype.hide = function() {};
   650 
   677 
       
   678 /* */
       
   679 
       
   680 var Media = Model.Media = function(_id, _source) {
       
   681     Playable.call(this, _id, _source);
       
   682     this.elementType = 'media';
       
   683     this.duration = new Time();
       
   684     this.video = '';
       
   685     var _this = this;
       
   686 };
       
   687 
       
   688 extendPrototype(Media, Playable);
   651 /* */
   689 /* */
   652 
   690 
   653 var Media = Model.Media = function(_id, _source) {
   691 var Media = Model.Media = function(_id, _source) {
   654     Playable.call(this, _id, _source);
   692     Playable.call(this, _id, _source);
   655     this.elementType = 'media';
   693     this.elementType = 'media';