all files / scripts/ads/vast/ MediaFile.js

94.12% Statements 16/17
83.33% Branches 5/6
100% Functions 2/2
94.12% Lines 16/17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50                                      226×         226×   226× 2712× 2712×                    
'use strict';
 
var xml = require('../../utils/xml');
var vastUtil = require('./vastUtil');
 
var attributesList = [
  //Required attributes
  'delivery',
  'type',
  'width',
  'height',
  //Optional attributes
  'codec',
  'id',
  'bitrate',
  'minBitrate',
  'maxBitrate',
  'scalable',
  'maintainAspectRatio',
  'apiFramework'
];
 
function MediaFile(mediaFileJTree) {
  Iif (!(this instanceof MediaFile)) {
    return new MediaFile(mediaFileJTree);
  }
 
  //Required attributes
  this.src = xml.keyValue(mediaFileJTree);
 
  for(var x=0; x<attributesList.length; x++) {
    var attribute = attributesList[x];
    this[attribute] = mediaFileJTree.attr(attribute);
  }
}
 
MediaFile.prototype.isSupported = function(){
  if(vastUtil.isVPAID(this)) {
    return !!vastUtil.findSupportedVPAIDTech(this.type);
  }
 
  if (this.type === 'video/x-flv') {
    return vastUtil.isFlashSupported();
  }
 
  return true;
};
 
module.exports = MediaFile;