diff -r 967ac73327dc -r d8339b45edc4 src/js/model.js --- a/src/js/model.js Fri Sep 18 14:02:21 2015 +0200 +++ b/src/js/model.js Tue Sep 01 15:10:17 2015 +0200 @@ -576,6 +576,7 @@ this.volume = .5; this.paused = true; this.muted = false; + this.timeRange = false; this.loadedMetadata = false; var _this = this; this.on("play", function() { @@ -600,6 +601,18 @@ _a.trigger("enter"); _this.trigger("enter-annotation",_a); }); + + if (_this.getTimeRange()){ + if (_this.getTimeRange()[0] > _time) { + _this.pause(); + _this.setCurrentTime(_this.getTimeRange()[0]); + } + if (_this.getTimeRange()[1] < _time){ + _this.pause(); + _this.setCurrentTime(_this.getTimeRange()[1]); + } + } + }); this.on("loadedmetadata", function() { _this.loadedMetadata = true; @@ -624,6 +637,10 @@ return this.muted; }; +Playable.prototype.getTimeRange = function() { + return this.timeRange; +} + Playable.prototype.setCurrentTime = function(_time) { this.trigger("setcurrenttime",_time); }; @@ -636,6 +653,16 @@ this.trigger("setmuted",_muted); }; +Playable.prototype.setTimeRange = function(_timeBegin, _timeEnd) { + if ((_timeBegin < _timeEnd)&&(_timeBegin >= 0)&&(_timeEnd>0)){ + return this.trigger("settimerange", [_timeBegin, _timeEnd]); + } +} + +Playable.prototype.resetTimeRange = function() { + return this.trigger("resettimerange"); +} + Playable.prototype.play = function() { this.trigger("setplay"); }; @@ -659,6 +686,17 @@ }; extendPrototype(Media, Playable); +/* */ + +var Media = Model.Media = function(_id, _source) { + Playable.call(this, _id, _source); + this.elementType = 'media'; + this.duration = new Time(); + this.video = ''; + var _this = this; +}; + +extendPrototype(Media, Playable); /* Default functions to be overriden by players */