src/js/model.js
changeset 961 e1baacb52075
parent 959 ee11ed1b739e
child 964 d7d56ea2d0a6
equal deleted inserted replaced
956:7c1d08cf6956 961:e1baacb52075
   362 IriSP.Model.Reference.prototype.refresh = function() {
   362 IriSP.Model.Reference.prototype.refresh = function() {
   363     if (this.isList) {
   363     if (this.isList) {
   364         this.contents = new IriSP.Model.List(this.source.directory);
   364         this.contents = new IriSP.Model.List(this.source.directory);
   365         this.contents.addIds(this.id);
   365         this.contents.addIds(this.id);
   366     } else {
   366     } else {
   367         this.contents = this.source.directory.getElement(this.id);
   367         this.contents = this.source.getElement(this.id);
   368     }
   368     }
   369     
   369     
   370 }
   370 }
   371 
   371 
   372 IriSP.Model.Reference.prototype.getContents = function() {
   372 IriSP.Model.Reference.prototype.getContents = function() {
   448     this.video = '';
   448     this.video = '';
   449 }
   449 }
   450 
   450 
   451 IriSP.Model.Media.prototype = new IriSP.Model.Element();
   451 IriSP.Model.Media.prototype = new IriSP.Model.Element();
   452 
   452 
       
   453 /* Default functions to be overriden by players */
       
   454 
       
   455 IriSP.Model.Media.prototype.getCurrentTime = function() {  return new IriSP.Model.Time(0); }
       
   456 
       
   457 IriSP.Model.Media.prototype.getVolume = function() { return .5; }
       
   458 
       
   459 IriSP.Model.Media.prototype.getPaused = function() { return true; }
       
   460 
       
   461 IriSP.Model.Media.prototype.getMuted = function() { return false; }
       
   462 
       
   463 IriSP.Model.Media.prototype.setCurrentTime
       
   464     = IriSP.Model.Media.prototype.setVolume
       
   465     = IriSP.Model.Media.prototype.setMuted
       
   466     = IriSP.Model.Media.prototype.play
       
   467     = IriSP.Model.Media.prototype.pause
       
   468     = function() {}
       
   469     
   453 IriSP.Model.Media.prototype.setDuration = function(_durationMs) {
   470 IriSP.Model.Media.prototype.setDuration = function(_durationMs) {
   454     this.duration.setMilliseconds(_durationMs);
   471     this.duration.setMilliseconds(_durationMs);
   455 }
   472 }
   456 
   473 
   457 IriSP.Model.Media.prototype.getAnnotations = function() {
   474 IriSP.Model.Media.prototype.getAnnotations = function() {
   644         return _annotation.getMedia();
   661         return _annotation.getMedia();
   645     } else {
   662     } else {
   646         return undefined;
   663         return undefined;
   647     }
   664     }
   648 }
   665 }
       
   666 
       
   667 /* Default functions to be overriden by players */
       
   668 
       
   669 IriSP.Model.Mashup.prototype.getCurrentTime = function() { return new IriSP.Model.Time(0); }
       
   670 
       
   671 IriSP.Model.Mashup.prototype.getVolume = function() { return .5; }
       
   672 
       
   673 IriSP.Model.Mashup.prototype.getPaused = function() { return true; }
       
   674 
       
   675 IriSP.Model.Mashup.prototype.getMuted = function() { return false; }
       
   676 
       
   677 IriSP.Model.Mashup.prototype.setCurrentTime
       
   678     = IriSP.Model.Mashup.prototype.setVolume
       
   679     = IriSP.Model.Mashup.prototype.setMuted
       
   680     = IriSP.Model.Mashup.prototype.play
       
   681     = IriSP.Model.Mashup.prototype.pause
       
   682     = function() {}
   649 
   683 
   650 /* */
   684 /* */
   651 
   685 
   652 IriSP.Model.Source = function(_config) {
   686 IriSP.Model.Source = function(_config) {
   653     this.status = IriSP.Model._SOURCE_STATUS_EMPTY;
   687     this.status = IriSP.Model._SOURCE_STATUS_EMPTY;
   766     if (typeof _m !== "undefined") {
   800     if (typeof _m !== "undefined") {
   767         return this.currentMedia.duration;
   801         return this.currentMedia.duration;
   768     }
   802     }
   769 }
   803 }
   770 
   804 
       
   805 IriSP.Model.Source.prototype.getCurrentMedia = function(_opts) {
       
   806     if (typeof this.currentMedia === "undefined") {
       
   807         if (_opts.is_mashup) {
       
   808             var _mashups = this.getMashups();
       
   809             if (_mashups.length) {
       
   810                 this.currentMedia = _mashups[0];
       
   811             }
       
   812         } else {
       
   813             var _medias = this.getMedias();
       
   814             if (_medias.length) {
       
   815                 _media = _medias[0];
       
   816             }
       
   817         }
       
   818     }
       
   819     return this.currentMedia;
       
   820 }
       
   821 
   771 IriSP.Model.Source.prototype.merge = function(_source) {
   822 IriSP.Model.Source.prototype.merge = function(_source) {
   772     var _this = this;
   823     var _this = this;
   773     _source.forEach(function(_value, _key) {
   824     _source.forEach(function(_value, _key) {
   774         _this.getList(_key).addElements(_value);
   825         _this.getList(_key).addElements(_value);
   775     });
   826     });