src/js/model.js
branchplayers-as-widgets
changeset 957 4da0a5740b6c
parent 940 9698ad710824
child 959 ee11ed1b739e
equal deleted inserted replaced
956:7c1d08cf6956 957:4da0a5740b6c
   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 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() {
   766     if (typeof _m !== "undefined") {
   783     if (typeof _m !== "undefined") {
   767         return this.currentMedia.duration;
   784         return this.currentMedia.duration;
   768     }
   785     }
   769 }
   786 }
   770 
   787 
       
   788 IriSP.Model.Source.prototype.getCurrentMedia = function(_opts) {
       
   789     if (typeof _opts === "undefined") {
       
   790         var _opts = {};
       
   791     }
       
   792     if (typeof this.currentMedia === "undefined" || _opts.override) {
       
   793         if (_opts.mashup) {
       
   794             var _mashups = this.getMashups();
       
   795             if (_mashups.length) {
       
   796                 this.currentMedia = _mashups[0];
       
   797             }
       
   798         } else {
       
   799             var _medias = this.getMedias();
       
   800             if (_medias.length) {
       
   801                 _media = _medias[0];
       
   802             }
       
   803         }
       
   804     }
       
   805     return this.currentMedia;
       
   806 }
       
   807 
   771 IriSP.Model.Source.prototype.merge = function(_source) {
   808 IriSP.Model.Source.prototype.merge = function(_source) {
   772     var _this = this;
   809     var _this = this;
   773     _source.forEach(function(_value, _key) {
   810     _source.forEach(function(_value, _key) {
   774         _this.getList(_key).addElements(_value);
   811         _this.getList(_key).addElements(_value);
   775     });
   812     });