vast-player-react
Version:
A React Component That Plays an Inline VAST 4.0 Ad
98 lines (74 loc) • 4.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _axios = require('axios');
var _axios2 = _interopRequireDefault(_axios);
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _baseResource = require('../resources/base-resource');
var _baseResource2 = _interopRequireDefault(_baseResource);
var _styles = require('../helpers/styles');
var _duration = require('../helpers/duration');
var _tracking = require('../helpers/tracking');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Companion = function (_React$Component) {
_inherits(Companion, _React$Component);
function Companion(props) {
_classCallCheck(this, Companion);
var _this = _possibleConstructorReturn(this, (Companion.__proto__ || Object.getPrototypeOf(Companion)).call(this, props));
_this.durationMillis = (0, _duration.getVastDurationInMillis)(_this.props.duration);
_this.startTrackingArr = (0, _tracking.getTracking)('start', _this.props.tracking);
_this.completeTrackingArr = (0, _tracking.getTracking)('complete', _this.props.tracking);
return _this;
}
_createClass(Companion, [{
key: 'componentDidMount',
value: function componentDidMount() {
var _this2 = this;
this.onStartedTracking();
setTimeout(function () {
_this2.onCompletedTracking();
}, this.durationMillis);
}
}, {
key: 'onStartedTracking',
value: function onStartedTracking() {
this.startTrackingArr.forEach(function (src) {
_axios2.default.get(src);
});
}
}, {
key: 'onCompletedTracking',
value: function onCompletedTracking() {
this.completeTrackingArr.forEach(function (src) {
_axios2.default.get(src);
});
}
}, {
key: 'render',
value: function render() {
return _react2.default.createElement(
'div',
{ style: _styles.vastBaseStyle },
_react2.default.createElement(_baseResource2.default, {
baseResource: this.props.companion,
height: parseInt(this.props.companion.getAttr('height'), 10),
width: parseInt(this.props.companion.getAttr('width'), 10)
})
);
}
}]);
return Companion;
}(_react2.default.Component);
Companion.propTypes = {
companion: _react2.default.PropTypes.object.isRequired,
duration: _react2.default.PropTypes.string,
tracking: _react2.default.PropTypes.array
};
exports.default = Companion;
//# sourceMappingURL=companion.js.map