1 | var ReactPlayer =
|
2 | (function(modules) {
|
3 |
|
4 | var installedModules = {};
|
5 |
|
6 |
|
7 | function __webpack_require__(moduleId) {
|
8 |
|
9 |
|
10 | if(installedModules[moduleId]) {
|
11 | return installedModules[moduleId].exports;
|
12 | }
|
13 |
|
14 | var module = installedModules[moduleId] = {
|
15 | i: moduleId,
|
16 | l: false,
|
17 | exports: {}
|
18 | };
|
19 |
|
20 |
|
21 | modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
22 |
|
23 |
|
24 | module.l = true;
|
25 |
|
26 |
|
27 | return module.exports;
|
28 | }
|
29 |
|
30 |
|
31 |
|
32 | __webpack_require__.m = modules;
|
33 |
|
34 |
|
35 | __webpack_require__.c = installedModules;
|
36 |
|
37 |
|
38 | __webpack_require__.d = function(exports, name, getter) {
|
39 | if(!__webpack_require__.o(exports, name)) {
|
40 | Object.defineProperty(exports, name, {
|
41 | configurable: false,
|
42 | enumerable: true,
|
43 | get: getter
|
44 | /******/ });
|
45 | /******/ }
|
46 | /******/ };
|
47 | /******/
|
48 | /******/ // getDefaultExport function for compatibility with non-harmony modules
|
49 | /******/ __webpack_require__.n = function(module) {
|
50 | var getter = module && module.__esModule ?
|
51 | function getDefault() { return module['default']; } :
|
52 | function getModuleExports() { return module; };
|
53 | __webpack_require__.d(getter, 'a', getter);
|
54 | return getter;
|
55 | };
|
56 |
|
57 |
|
58 | __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
59 |
|
60 |
|
61 | __webpack_require__.p = "";
|
62 |
|
63 |
|
64 | return __webpack_require__(__webpack_require__.s = 31);
|
65 | })
|
66 |
|
67 | ([
|
68 |
|
69 | (function(module, exports) {
|
70 |
|
71 | module.exports = React;
|
72 |
|
73 | }),
|
74 |
|
75 | (function(module, exports, __webpack_require__) {
|
76 |
|
77 | "use strict";
|
78 |
|
79 |
|
80 | Object.defineProperty(exports, "__esModule", {
|
81 | value: true
|
82 | });
|
83 |
|
84 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
85 |
|
86 | var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
87 |
|
88 | exports.parseStartTime = parseStartTime;
|
89 | exports.parseEndTime = parseEndTime;
|
90 | exports.randomString = randomString;
|
91 | exports.queryString = queryString;
|
92 | exports.getSDK = getSDK;
|
93 | exports.getConfig = getConfig;
|
94 | exports.omit = omit;
|
95 | exports.callPlayer = callPlayer;
|
96 | exports.isObject = isObject;
|
97 | exports.isEqual = isEqual;
|
98 | exports.isMediaStream = isMediaStream;
|
99 |
|
100 | var _loadScript = __webpack_require__(32);
|
101 |
|
102 | var _loadScript2 = _interopRequireDefault(_loadScript);
|
103 |
|
104 | var _deepmerge = __webpack_require__(33);
|
105 |
|
106 | var _deepmerge2 = _interopRequireDefault(_deepmerge);
|
107 |
|
108 | var _props = __webpack_require__(4);
|
109 |
|
110 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
111 |
|
112 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
113 |
|
114 | var MATCH_START_QUERY = /[?&#](?:start|t)=([0-9hms]+)/;
|
115 | var MATCH_END_QUERY = /[?&#]end=([0-9hms]+)/;
|
116 | var MATCH_START_STAMP = /(\d+)(h|m|s)/g;
|
117 | var MATCH_NUMERIC = /^\d+$/;
|
118 |
|
119 |
|
120 |
|
121 | function parseTimeParam(url, pattern) {
|
122 | var match = url.match(pattern);
|
123 | if (match) {
|
124 | var stamp = match[1];
|
125 | if (stamp.match(MATCH_START_STAMP)) {
|
126 | return parseTimeString(stamp);
|
127 | }
|
128 | if (MATCH_NUMERIC.test(stamp)) {
|
129 | return parseInt(stamp);
|
130 | }
|
131 | }
|
132 | return undefined;
|
133 | }
|
134 |
|
135 | function parseTimeString(stamp) {
|
136 | var seconds = 0;
|
137 | var array = MATCH_START_STAMP.exec(stamp);
|
138 | while (array !== null) {
|
139 | var _array = array,
|
140 | _array2 = _slicedToArray(_array, 3),
|
141 | count = _array2[1],
|
142 | period = _array2[2];
|
143 |
|
144 | if (period === 'h') seconds += parseInt(count, 10) * 60 * 60;
|
145 | if (period === 'm') seconds += parseInt(count, 10) * 60;
|
146 | if (period === 's') seconds += parseInt(count, 10);
|
147 | array = MATCH_START_STAMP.exec(stamp);
|
148 | }
|
149 | return seconds;
|
150 | }
|
151 |
|
152 | function parseStartTime(url) {
|
153 | return parseTimeParam(url, MATCH_START_QUERY);
|
154 | }
|
155 |
|
156 | function parseEndTime(url) {
|
157 | return parseTimeParam(url, MATCH_END_QUERY);
|
158 | }
|
159 |
|
160 |
|
161 | function randomString() {
|
162 | return Math.random().toString(36).substr(2, 5);
|
163 | }
|
164 |
|
165 | function queryString(object) {
|
166 | return Object.keys(object).map(function (key) {
|
167 | return key + '=' + object[key];
|
168 | }).join('&');
|
169 | }
|
170 |
|
171 |
|
172 |
|
173 | var resolves = {};
|
174 | function getSDK(url, sdkGlobal) {
|
175 | var sdkReady = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
176 | var isLoaded = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function () {
|
177 | return true;
|
178 | };
|
179 | var fetchScript = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _loadScript2['default'];
|
180 |
|
181 | if (window[sdkGlobal] && isLoaded(window[sdkGlobal])) {
|
182 | return Promise.resolve(window[sdkGlobal]);
|
183 | }
|
184 | return new Promise(function (resolve, reject) {
|
185 |
|
186 |
|
187 | if (resolves[url]) {
|
188 | resolves[url].push(resolve);
|
189 | return;
|
190 | }
|
191 | resolves[url] = [resolve];
|
192 | var onLoaded = function onLoaded(sdk) {
|
193 |
|
194 | resolves[url].forEach(function (resolve) {
|
195 | return resolve(sdk);
|
196 | });
|
197 | };
|
198 | if (sdkReady) {
|
199 | var previousOnReady = window[sdkReady];
|
200 | window[sdkReady] = function () {
|
201 | if (previousOnReady) previousOnReady();
|
202 | onLoaded(window[sdkGlobal]);
|
203 | };
|
204 | }
|
205 | fetchScript(url, function (err) {
|
206 | if (err) reject(err);
|
207 | if (!sdkReady) {
|
208 | onLoaded(window[sdkGlobal]);
|
209 | }
|
210 | });
|
211 | });
|
212 | }
|
213 |
|
214 | function getConfig(props, defaultProps, showWarning) {
|
215 | var config = (0, _deepmerge2['default'])(defaultProps.config, props.config);
|
216 | var _iteratorNormalCompletion = true;
|
217 | var _didIteratorError = false;
|
218 | var _iteratorError = undefined;
|
219 |
|
220 | try {
|
221 | for (var _iterator = _props.DEPRECATED_CONFIG_PROPS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
222 | var p = _step.value;
|
223 |
|
224 | if (props[p]) {
|
225 | var key = p.replace(/Config$/, '');
|
226 | config = (0, _deepmerge2['default'])(config, _defineProperty({}, key, props[p]));
|
227 | if (showWarning) {
|
228 | var link = 'https://github.com/CookPete/react-player#config-prop';
|
229 | var message = 'ReactPlayer: %c' + p + ' %cis deprecated, please use the config prop instead \u2013 ' + link;
|
230 | console.warn(message, 'font-weight: bold', '');
|
231 | }
|
232 | }
|
233 | }
|
234 | } catch (err) {
|
235 | _didIteratorError = true;
|
236 | _iteratorError = err;
|
237 | } finally {
|
238 | try {
|
239 | if (!_iteratorNormalCompletion && _iterator['return']) {
|
240 | _iterator['return']();
|
241 | }
|
242 | } finally {
|
243 | if (_didIteratorError) {
|
244 | throw _iteratorError;
|
245 | }
|
246 | }
|
247 | }
|
248 |
|
249 | return config;
|
250 | }
|
251 |
|
252 | function omit(object) {
|
253 | var _ref;
|
254 |
|
255 | for (var _len = arguments.length, arrays = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
256 | arrays[_key - 1] = arguments[_key];
|
257 | }
|
258 |
|
259 | var omitKeys = (_ref = []).concat.apply(_ref, arrays);
|
260 | var output = {};
|
261 | var keys = Object.keys(object);
|
262 | var _iteratorNormalCompletion2 = true;
|
263 | var _didIteratorError2 = false;
|
264 | var _iteratorError2 = undefined;
|
265 |
|
266 | try {
|
267 | for (var _iterator2 = keys[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
268 | var key = _step2.value;
|
269 |
|
270 | if (omitKeys.indexOf(key) === -1) {
|
271 | output[key] = object[key];
|
272 | }
|
273 | }
|
274 | } catch (err) {
|
275 | _didIteratorError2 = true;
|
276 | _iteratorError2 = err;
|
277 | } finally {
|
278 | try {
|
279 | if (!_iteratorNormalCompletion2 && _iterator2['return']) {
|
280 | _iterator2['return']();
|
281 | }
|
282 | } finally {
|
283 | if (_didIteratorError2) {
|
284 | throw _iteratorError2;
|
285 | }
|
286 | }
|
287 | }
|
288 |
|
289 | return output;
|
290 | }
|
291 |
|
292 | function callPlayer(method) {
|
293 | var _player;
|
294 |
|
295 |
|
296 |
|
297 | if (!this.player || !this.player[method]) {
|
298 | var message = 'ReactPlayer: ' + this.constructor.displayName + ' player could not call %c' + method + '%c \u2013 ';
|
299 | if (!this.player) {
|
300 | message += 'The player was not available';
|
301 | } else if (!this.player[method]) {
|
302 | message += 'The method was not available';
|
303 | }
|
304 | console.warn(message, 'font-weight: bold', '');
|
305 | return null;
|
306 | }
|
307 |
|
308 | for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
309 | args[_key2 - 1] = arguments[_key2];
|
310 | }
|
311 |
|
312 | return (_player = this.player)[method].apply(_player, args);
|
313 | }
|
314 |
|
315 | function isObject(val) {
|
316 | return val !== null && (typeof val === 'undefined' ? 'undefined' : _typeof(val)) === 'object';
|
317 | }
|
318 |
|
319 |
|
320 |
|
321 | function isEqual(a, b) {
|
322 | if (typeof a === 'function' && typeof b === 'function') {
|
323 | return true;
|
324 | }
|
325 | if (a instanceof Array && b instanceof Array) {
|
326 | if (a.length !== b.length) {
|
327 | return false;
|
328 | }
|
329 | for (var i = 0; i !== a.length; i++) {
|
330 | if (!isEqual(a[i], b[i])) {
|
331 | return false;
|
332 | }
|
333 | }
|
334 | return true;
|
335 | }
|
336 | if (isObject(a) && isObject(b)) {
|
337 | if (Object.keys(a).length !== Object.keys(b).length) {
|
338 | return false;
|
339 | }
|
340 | var _iteratorNormalCompletion3 = true;
|
341 | var _didIteratorError3 = false;
|
342 | var _iteratorError3 = undefined;
|
343 |
|
344 | try {
|
345 | for (var _iterator3 = Object.keys(a)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
346 | var key = _step3.value;
|
347 |
|
348 | if (!isEqual(a[key], b[key])) {
|
349 | return false;
|
350 | }
|
351 | }
|
352 | } catch (err) {
|
353 | _didIteratorError3 = true;
|
354 | _iteratorError3 = err;
|
355 | } finally {
|
356 | try {
|
357 | if (!_iteratorNormalCompletion3 && _iterator3['return']) {
|
358 | _iterator3['return']();
|
359 | }
|
360 | } finally {
|
361 | if (_didIteratorError3) {
|
362 | throw _iteratorError3;
|
363 | }
|
364 | }
|
365 | }
|
366 |
|
367 | return true;
|
368 | }
|
369 | return a === b;
|
370 | }
|
371 |
|
372 | function isMediaStream(url) {
|
373 | return typeof window !== 'undefined' && typeof window.MediaStream !== 'undefined' && url instanceof window.MediaStream;
|
374 | }
|
375 |
|
376 | }),
|
377 |
|
378 | (function(module, exports, __webpack_require__) {
|
379 |
|
380 | "use strict";
|
381 |
|
382 |
|
383 | Object.defineProperty(exports, "__esModule", {
|
384 | value: true
|
385 | });
|
386 |
|
387 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
388 |
|
389 | 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; }; }();
|
390 |
|
391 | exports['default'] = createSinglePlayer;
|
392 |
|
393 | var _react = __webpack_require__(0);
|
394 |
|
395 | var _react2 = _interopRequireDefault(_react);
|
396 |
|
397 | var _props2 = __webpack_require__(4);
|
398 |
|
399 | var _utils = __webpack_require__(1);
|
400 |
|
401 | var _Player = __webpack_require__(6);
|
402 |
|
403 | var _Player2 = _interopRequireDefault(_Player);
|
404 |
|
405 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
406 |
|
407 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
408 |
|
409 | 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; }
|
410 |
|
411 | 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; }
|
412 |
|
413 | var SUPPORTED_PROPS = Object.keys(_props2.propTypes);
|
414 |
|
415 | function createSinglePlayer(activePlayer) {
|
416 | var _class, _temp2;
|
417 |
|
418 | return _temp2 = _class = function (_Component) {
|
419 | _inherits(SinglePlayer, _Component);
|
420 |
|
421 | function SinglePlayer() {
|
422 | var _ref;
|
423 |
|
424 | var _temp, _this, _ret;
|
425 |
|
426 | _classCallCheck(this, SinglePlayer);
|
427 |
|
428 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
429 | args[_key] = arguments[_key];
|
430 | }
|
431 |
|
432 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = SinglePlayer.__proto__ || Object.getPrototypeOf(SinglePlayer)).call.apply(_ref, [this].concat(args))), _this), _this.config = (0, _utils.getConfig)(_this.props, _props2.defaultProps, true), _this.getDuration = function () {
|
433 | if (!_this.player) return null;
|
434 | return _this.player.getDuration();
|
435 | }, _this.getCurrentTime = function () {
|
436 | if (!_this.player) return null;
|
437 | return _this.player.getCurrentTime();
|
438 | }, _this.getSecondsLoaded = function () {
|
439 | if (!_this.player) return null;
|
440 | return _this.player.getSecondsLoaded();
|
441 | }, _this.getInternalPlayer = function () {
|
442 | var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'player';
|
443 |
|
444 | if (!_this.player) return null;
|
445 | return _this.player.getInternalPlayer(key);
|
446 | }, _this.seekTo = function (fraction, type) {
|
447 | if (!_this.player) return null;
|
448 | _this.player.seekTo(fraction, type);
|
449 | }, _this.ref = function (player) {
|
450 | _this.player = player;
|
451 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
452 | }
|
453 |
|
454 | _createClass(SinglePlayer, [{
|
455 | key: 'shouldComponentUpdate',
|
456 | value: function shouldComponentUpdate(nextProps) {
|
457 | return !(0, _utils.isEqual)(this.props, nextProps);
|
458 | }
|
459 | }, {
|
460 | key: 'componentWillUpdate',
|
461 | value: function componentWillUpdate(nextProps) {
|
462 | this.config = (0, _utils.getConfig)(nextProps, _props2.defaultProps);
|
463 | }
|
464 | }, {
|
465 | key: 'render',
|
466 | value: function render() {
|
467 | var _config$file = this.config.file,
|
468 | forceVideo = _config$file.forceVideo,
|
469 | forceAudio = _config$file.forceAudio,
|
470 | forceHLS = _config$file.forceHLS,
|
471 | forceDASH = _config$file.forceDASH;
|
472 |
|
473 | var skipCanPlay = forceVideo || forceAudio || forceHLS || forceDASH;
|
474 | if (!activePlayer.canPlay(this.props.url) && !skipCanPlay) {
|
475 | return null;
|
476 | }
|
477 | var _props = this.props,
|
478 | style = _props.style,
|
479 | width = _props.width,
|
480 | height = _props.height,
|
481 | Wrapper = _props.wrapper;
|
482 |
|
483 | var otherProps = (0, _utils.omit)(this.props, SUPPORTED_PROPS, _props2.DEPRECATED_CONFIG_PROPS);
|
484 | return _react2['default'].createElement(
|
485 | Wrapper,
|
486 | _extends({ style: _extends({}, style, { width: width, height: height }) }, otherProps),
|
487 | _react2['default'].createElement(_Player2['default'], _extends({}, this.props, {
|
488 | ref: this.ref,
|
489 | activePlayer: activePlayer,
|
490 | config: this.config
|
491 | }))
|
492 | );
|
493 | }
|
494 | }]);
|
495 |
|
496 | return SinglePlayer;
|
497 | }(_react.Component), _class.displayName = activePlayer.displayName + 'Player', _class.propTypes = _props2.propTypes, _class.defaultProps = _props2.defaultProps, _class.canPlay = activePlayer.canPlay, _temp2;
|
498 | }
|
499 |
|
500 | }),
|
501 |
|
502 | (function(module, exports, __webpack_require__) {
|
503 |
|
504 | "use strict";
|
505 |
|
506 |
|
507 | Object.defineProperty(exports, "__esModule", {
|
508 | value: true
|
509 | });
|
510 | exports.parserUtils = undefined;
|
511 |
|
512 | var _util = __webpack_require__(12);
|
513 |
|
514 |
|
515 |
|
516 |
|
517 |
|
518 |
|
519 |
|
520 |
|
521 |
|
522 |
|
523 |
|
524 | function childByName(node, name) {
|
525 | var childNodes = node.childNodes;
|
526 |
|
527 | for (var childKey in childNodes) {
|
528 | var child = childNodes[childKey];
|
529 |
|
530 | if (child.nodeName === name) {
|
531 | return child;
|
532 | }
|
533 | }
|
534 | }
|
535 |
|
536 |
|
537 |
|
538 |
|
539 |
|
540 |
|
541 |
|
542 | function childrenByName(node, name) {
|
543 | var children = [];
|
544 | var childNodes = node.childNodes;
|
545 |
|
546 | for (var childKey in childNodes) {
|
547 | var child = childNodes[childKey];
|
548 |
|
549 | if (child.nodeName === name) {
|
550 | children.push(child);
|
551 | }
|
552 | }
|
553 | return children;
|
554 | }
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 | function resolveVastAdTagURI(vastAdTagUrl, originalUrl) {
|
563 | if (!originalUrl) {
|
564 | return vastAdTagUrl;
|
565 | }
|
566 |
|
567 | if (vastAdTagUrl.indexOf('//') === 0) {
|
568 | var _location = location,
|
569 | protocol = _location.protocol;
|
570 |
|
571 | return '' + protocol + vastAdTagUrl;
|
572 | }
|
573 |
|
574 | if (vastAdTagUrl.indexOf('://') === -1) {
|
575 |
|
576 | var baseURL = originalUrl.slice(0, originalUrl.lastIndexOf('/'));
|
577 | return baseURL + '/' + vastAdTagUrl;
|
578 | }
|
579 |
|
580 | return vastAdTagUrl;
|
581 | }
|
582 |
|
583 |
|
584 |
|
585 |
|
586 |
|
587 |
|
588 | function parseBoolean(booleanString) {
|
589 | return ['true', 'TRUE', '1'].indexOf(booleanString) !== -1;
|
590 | }
|
591 |
|
592 |
|
593 |
|
594 |
|
595 |
|
596 |
|
597 | function parseNodeText(node) {
|
598 | return node && (node.textContent || node.text || '').trim();
|
599 | }
|
600 |
|
601 |
|
602 |
|
603 |
|
604 |
|
605 |
|
606 |
|
607 | function copyNodeAttribute(attributeName, nodeSource, nodeDestination) {
|
608 | var attributeValue = nodeSource.getAttribute(attributeName);
|
609 | if (attributeValue) {
|
610 | nodeDestination.setAttribute(attributeName, attributeValue);
|
611 | }
|
612 | }
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 |
|
619 | function parseDuration(durationString) {
|
620 | if (durationString === null || typeof durationString === 'undefined') {
|
621 | return -1;
|
622 | }
|
623 |
|
624 | if (_util.util.isNumeric(durationString)) {
|
625 | return parseInt(durationString);
|
626 | }
|
627 |
|
628 | var durationComponents = durationString.split(':');
|
629 | if (durationComponents.length !== 3) {
|
630 | return -1;
|
631 | }
|
632 |
|
633 | var secondsAndMS = durationComponents[2].split('.');
|
634 | var seconds = parseInt(secondsAndMS[0]);
|
635 | if (secondsAndMS.length === 2) {
|
636 | seconds += parseFloat('0.' + secondsAndMS[1]);
|
637 | }
|
638 |
|
639 | var minutes = parseInt(durationComponents[1] * 60);
|
640 | var hours = parseInt(durationComponents[0] * 60 * 60);
|
641 |
|
642 | if (isNaN(hours) || isNaN(minutes) || isNaN(seconds) || minutes > 60 * 60 || seconds > 60) {
|
643 | return -1;
|
644 | }
|
645 | return hours + minutes + seconds;
|
646 | }
|
647 |
|
648 |
|
649 |
|
650 |
|
651 |
|
652 |
|
653 |
|
654 | function splitVAST(ads) {
|
655 | var splittedVAST = [];
|
656 | var lastAdPod = null;
|
657 |
|
658 | ads.forEach(function (ad, i) {
|
659 | if (ad.sequence) {
|
660 | ad.sequence = parseInt(ad.sequence, 10);
|
661 | }
|
662 |
|
663 | if (ad.sequence > 1) {
|
664 | var lastAd = ads[i - 1];
|
665 |
|
666 | if (lastAd && lastAd.sequence === ad.sequence - 1) {
|
667 | lastAdPod && lastAdPod.push(ad);
|
668 | return;
|
669 | }
|
670 |
|
671 |
|
672 | delete ad.sequence;
|
673 | }
|
674 |
|
675 | lastAdPod = [ad];
|
676 | splittedVAST.push(lastAdPod);
|
677 | });
|
678 |
|
679 | return splittedVAST;
|
680 | }
|
681 |
|
682 |
|
683 |
|
684 |
|
685 |
|
686 |
|
687 |
|
688 | function mergeWrapperAdData(unwrappedAd, wrapper) {
|
689 | unwrappedAd.errorURLTemplates = wrapper.errorURLTemplates.concat(unwrappedAd.errorURLTemplates);
|
690 | unwrappedAd.impressionURLTemplates = wrapper.impressionURLTemplates.concat(unwrappedAd.impressionURLTemplates);
|
691 | unwrappedAd.extensions = wrapper.extensions.concat(unwrappedAd.extensions);
|
692 |
|
693 | unwrappedAd.creatives.forEach(function (creative) {
|
694 | if (wrapper.trackingEvents && wrapper.trackingEvents[creative.type]) {
|
695 | for (var eventName in wrapper.trackingEvents[creative.type]) {
|
696 | var urls = wrapper.trackingEvents[creative.type][eventName];
|
697 | if (!Array.isArray(creative.trackingEvents[eventName])) {
|
698 | creative.trackingEvents[eventName] = [];
|
699 | }
|
700 | creative.trackingEvents[eventName] = creative.trackingEvents[eventName].concat(urls);
|
701 | }
|
702 | }
|
703 | });
|
704 |
|
705 | if (wrapper.videoClickTrackingURLTemplates && wrapper.videoClickTrackingURLTemplates.length) {
|
706 | unwrappedAd.creatives.forEach(function (creative) {
|
707 | if (creative.type === 'linear') {
|
708 | creative.videoClickTrackingURLTemplates = creative.videoClickTrackingURLTemplates.concat(wrapper.videoClickTrackingURLTemplates);
|
709 | }
|
710 | });
|
711 | }
|
712 |
|
713 | if (wrapper.videoCustomClickURLTemplates && wrapper.videoCustomClickURLTemplates.length) {
|
714 | unwrappedAd.creatives.forEach(function (creative) {
|
715 | if (creative.type === 'linear') {
|
716 | creative.videoCustomClickURLTemplates = creative.videoCustomClickURLTemplates.concat(wrapper.videoCustomClickURLTemplates);
|
717 | }
|
718 | });
|
719 | }
|
720 |
|
721 |
|
722 | if (wrapper.videoClickThroughURLTemplate) {
|
723 | unwrappedAd.creatives.forEach(function (creative) {
|
724 | if (creative.type === 'linear' && (creative.videoClickThroughURLTemplate === null || typeof creative.videoClickThroughURLTemplate === 'undefined')) {
|
725 | creative.videoClickThroughURLTemplate = wrapper.videoClickThroughURLTemplate;
|
726 | }
|
727 | });
|
728 | }
|
729 | }
|
730 |
|
731 | var parserUtils = exports.parserUtils = {
|
732 | childByName: childByName,
|
733 | childrenByName: childrenByName,
|
734 | resolveVastAdTagURI: resolveVastAdTagURI,
|
735 | parseBoolean: parseBoolean,
|
736 | parseNodeText: parseNodeText,
|
737 | copyNodeAttribute: copyNodeAttribute,
|
738 | parseDuration: parseDuration,
|
739 | splitVAST: splitVAST,
|
740 | mergeWrapperAdData: mergeWrapperAdData
|
741 | };
|
742 |
|
743 | }),
|
744 |
|
745 | (function(module, exports, __webpack_require__) {
|
746 |
|
747 | "use strict";
|
748 |
|
749 |
|
750 | Object.defineProperty(exports, "__esModule", {
|
751 | value: true
|
752 | });
|
753 | exports.DEPRECATED_CONFIG_PROPS = exports.defaultProps = exports.propTypes = undefined;
|
754 |
|
755 | var _propTypes = __webpack_require__(34);
|
756 |
|
757 | var _propTypes2 = _interopRequireDefault(_propTypes);
|
758 |
|
759 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
760 |
|
761 | var string = _propTypes2['default'].string,
|
762 | bool = _propTypes2['default'].bool,
|
763 | number = _propTypes2['default'].number,
|
764 | array = _propTypes2['default'].array,
|
765 | oneOfType = _propTypes2['default'].oneOfType,
|
766 | shape = _propTypes2['default'].shape,
|
767 | object = _propTypes2['default'].object,
|
768 | func = _propTypes2['default'].func;
|
769 | var propTypes = exports.propTypes = {
|
770 | url: oneOfType([string, array, object]),
|
771 | playing: bool,
|
772 | loop: bool,
|
773 | controls: bool,
|
774 | volume: number,
|
775 | muted: bool,
|
776 | playbackRate: number,
|
777 | width: oneOfType([string, number]),
|
778 | height: oneOfType([string, number]),
|
779 | style: object,
|
780 | progressInterval: number,
|
781 | playsinline: bool,
|
782 | pip: bool,
|
783 | light: oneOfType([bool, string]),
|
784 | wrapper: oneOfType([string, func, shape({ render: func.isRequired })]),
|
785 | config: shape({
|
786 | soundcloud: shape({
|
787 | options: object,
|
788 | preload: bool
|
789 | }),
|
790 | youtube: shape({
|
791 | playerVars: object,
|
792 | embedOptions: object,
|
793 | preload: bool
|
794 | }),
|
795 | facebook: shape({
|
796 | appId: string
|
797 | }),
|
798 | dailymotion: shape({
|
799 | params: object,
|
800 | preload: bool
|
801 | }),
|
802 | vimeo: shape({
|
803 | playerOptions: object,
|
804 | preload: bool
|
805 | }),
|
806 | file: shape({
|
807 | attributes: object,
|
808 | tracks: array,
|
809 | forceVideo: bool,
|
810 | forceAudio: bool,
|
811 | forceHLS: bool,
|
812 | forceDASH: bool,
|
813 | hlsOptions: object,
|
814 | hlsVersion: string,
|
815 | dashVersion: string
|
816 | }),
|
817 | wistia: shape({
|
818 | options: object
|
819 | }),
|
820 | mixcloud: shape({
|
821 | options: object
|
822 | }),
|
823 | twitch: shape({
|
824 | options: object
|
825 | })
|
826 | }),
|
827 | onAdSkippable: func,
|
828 | onReady: func,
|
829 | onStart: func,
|
830 | onPlay: func,
|
831 | onPause: func,
|
832 | onBuffer: func,
|
833 | onBufferEnd: func,
|
834 | onEnded: func,
|
835 | onError: func,
|
836 | onDuration: func,
|
837 | onSeek: func,
|
838 | onProgress: func,
|
839 | onVolumeChange: func,
|
840 | onEnablePIP: func,
|
841 | onDisablePIP: func
|
842 | };
|
843 |
|
844 | var defaultProps = exports.defaultProps = {
|
845 | playing: false,
|
846 | loop: false,
|
847 | controls: false,
|
848 | volume: null,
|
849 | muted: false,
|
850 | playbackRate: 1,
|
851 | width: '640px',
|
852 | height: '360px',
|
853 | style: {},
|
854 | progressInterval: 1000,
|
855 | playsinline: false,
|
856 | pip: false,
|
857 | light: false,
|
858 | wrapper: 'div',
|
859 | config: {
|
860 | soundcloud: {
|
861 | options: {
|
862 | visual: true,
|
863 | buying: false,
|
864 | liking: false,
|
865 | download: false,
|
866 | sharing: false,
|
867 | show_comments: false,
|
868 | show_playcount: false
|
869 | }
|
870 | },
|
871 | youtube: {
|
872 | playerVars: {
|
873 | playsinline: 1,
|
874 | showinfo: 0,
|
875 | rel: 0,
|
876 | iv_load_policy: 3,
|
877 | modestbranding: 1
|
878 | },
|
879 | embedOptions: {},
|
880 | preload: false
|
881 | },
|
882 | facebook: {
|
883 | appId: '1309697205772819'
|
884 | },
|
885 | dailymotion: {
|
886 | params: {
|
887 | api: 1,
|
888 | 'endscreen-enable': false
|
889 | },
|
890 | preload: false
|
891 | },
|
892 | vimeo: {
|
893 | playerOptions: {
|
894 | autopause: false,
|
895 | byline: false,
|
896 | portrait: false,
|
897 | title: false
|
898 | },
|
899 | preload: false
|
900 | },
|
901 | file: {
|
902 | attributes: {},
|
903 | tracks: [],
|
904 | forceVideo: false,
|
905 | forceAudio: false,
|
906 | forceHLS: false,
|
907 | forceDASH: false,
|
908 | hlsOptions: {},
|
909 | hlsVersion: '0.10.1',
|
910 | dashVersion: '2.9.2'
|
911 | },
|
912 | wistia: {
|
913 | options: {}
|
914 | },
|
915 | mixcloud: {
|
916 | options: {
|
917 | hide_cover: 1
|
918 | }
|
919 | },
|
920 | twitch: {
|
921 | options: {}
|
922 | }
|
923 | },
|
924 | onAdSkippable: function onAdSkippable() {},
|
925 | onReady: function onReady() {},
|
926 | onStart: function onStart() {},
|
927 | onPlay: function onPlay() {},
|
928 | onPause: function onPause() {},
|
929 | onBuffer: function onBuffer() {},
|
930 | onBufferEnd: function onBufferEnd() {},
|
931 | onEnded: function onEnded() {},
|
932 | onError: function onError() {},
|
933 | onDuration: function onDuration() {},
|
934 | onSeek: function onSeek() {},
|
935 | onVolumeChange: function onVolumeChange() {},
|
936 | onProgress: function onProgress() {},
|
937 | onEnablePIP: function onEnablePIP() {},
|
938 | onDisablePIP: function onDisablePIP() {}
|
939 | };
|
940 |
|
941 | var DEPRECATED_CONFIG_PROPS = exports.DEPRECATED_CONFIG_PROPS = ['soundcloudConfig', 'youtubeConfig', 'facebookConfig', 'dailymotionConfig', 'vimeoConfig', 'fileConfig', 'wistiaConfig'];
|
942 |
|
943 | }),
|
944 |
|
945 | (function(module, exports, __webpack_require__) {
|
946 |
|
947 | "use strict";
|
948 |
|
949 |
|
950 | Object.defineProperty(exports, "__esModule", {
|
951 | value: true
|
952 | });
|
953 | exports.YouTube = undefined;
|
954 |
|
955 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
956 |
|
957 | 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; }; }();
|
958 |
|
959 | var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
960 |
|
961 | var _react = __webpack_require__(0);
|
962 |
|
963 | var _react2 = _interopRequireDefault(_react);
|
964 |
|
965 | var _utils = __webpack_require__(1);
|
966 |
|
967 | var _singlePlayer = __webpack_require__(2);
|
968 |
|
969 | var _singlePlayer2 = _interopRequireDefault(_singlePlayer);
|
970 |
|
971 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
972 |
|
973 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
974 |
|
975 | 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; }
|
976 |
|
977 | 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; }
|
978 |
|
979 | var SDK_URL = 'https://www.youtube.com/iframe_api';
|
980 | var SDK_GLOBAL = 'YT';
|
981 | var SDK_GLOBAL_READY = 'onYouTubeIframeAPIReady';
|
982 | var MATCH_URL = /(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})|youtube\.com\/playlist\?list=/;
|
983 | var MATCH_PLAYLIST = /list=([a-zA-Z0-9_-]+)/;
|
984 |
|
985 | function parsePlaylist(url) {
|
986 | if (MATCH_PLAYLIST.test(url)) {
|
987 | var _url$match = url.match(MATCH_PLAYLIST),
|
988 | _url$match2 = _slicedToArray(_url$match, 2),
|
989 | playlistId = _url$match2[1];
|
990 |
|
991 | return {
|
992 | listType: 'playlist',
|
993 | list: playlistId
|
994 | };
|
995 | }
|
996 | return {};
|
997 | }
|
998 |
|
999 | var YouTube = exports.YouTube = function (_Component) {
|
1000 | _inherits(YouTube, _Component);
|
1001 |
|
1002 | function YouTube() {
|
1003 | var _ref;
|
1004 |
|
1005 | var _temp, _this, _ret;
|
1006 |
|
1007 | _classCallCheck(this, YouTube);
|
1008 |
|
1009 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
1010 | args[_key] = arguments[_key];
|
1011 | }
|
1012 |
|
1013 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = YouTube.__proto__ || Object.getPrototypeOf(YouTube)).call.apply(_ref, [this].concat(args))), _this), _this.callPlayer = _utils.callPlayer, _this.onStateChange = function (_ref2) {
|
1014 | var data = _ref2.data;
|
1015 | var _this$props = _this.props,
|
1016 | onPlay = _this$props.onPlay,
|
1017 | onPause = _this$props.onPause,
|
1018 | onBuffer = _this$props.onBuffer,
|
1019 | onBufferEnd = _this$props.onBufferEnd,
|
1020 | onEnded = _this$props.onEnded,
|
1021 | onReady = _this$props.onReady,
|
1022 | loop = _this$props.loop;
|
1023 | var _window$SDK_GLOBAL$Pl = window[SDK_GLOBAL].PlayerState,
|
1024 | PLAYING = _window$SDK_GLOBAL$Pl.PLAYING,
|
1025 | PAUSED = _window$SDK_GLOBAL$Pl.PAUSED,
|
1026 | BUFFERING = _window$SDK_GLOBAL$Pl.BUFFERING,
|
1027 | ENDED = _window$SDK_GLOBAL$Pl.ENDED,
|
1028 | CUED = _window$SDK_GLOBAL$Pl.CUED;
|
1029 |
|
1030 | if (data === PLAYING) {
|
1031 | onPlay();
|
1032 | onBufferEnd();
|
1033 | }
|
1034 | if (data === PAUSED) onPause();
|
1035 | if (data === BUFFERING) onBuffer();
|
1036 | if (data === ENDED) {
|
1037 | var isPlaylist = !!_this.callPlayer('getPlaylist');
|
1038 | if (loop && !isPlaylist) {
|
1039 | _this.play();
|
1040 | }
|
1041 | onEnded();
|
1042 | }
|
1043 | if (data === CUED) onReady();
|
1044 | }, _this.mute = function () {
|
1045 | _this.callPlayer('mute');
|
1046 | }, _this.unmute = function () {
|
1047 | _this.callPlayer('unMute');
|
1048 | }, _this.ref = function (container) {
|
1049 | _this.container = container;
|
1050 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
1051 | }
|
1052 |
|
1053 | _createClass(YouTube, [{
|
1054 | key: 'load',
|
1055 | value: function load(url, isReady) {
|
1056 | var _this2 = this;
|
1057 |
|
1058 | var _props = this.props,
|
1059 | playing = _props.playing,
|
1060 | muted = _props.muted,
|
1061 | playsinline = _props.playsinline,
|
1062 | controls = _props.controls,
|
1063 | loop = _props.loop,
|
1064 | config = _props.config,
|
1065 | _onError = _props.onError;
|
1066 | var _config$youtube = config.youtube,
|
1067 | playerVars = _config$youtube.playerVars,
|
1068 | embedOptions = _config$youtube.embedOptions;
|
1069 |
|
1070 | var id = url && url.match(MATCH_URL)[1];
|
1071 | if (isReady) {
|
1072 | if (MATCH_PLAYLIST.test(url)) {
|
1073 | this.player.loadPlaylist(parsePlaylist(url));
|
1074 | return;
|
1075 | }
|
1076 | this.player.cueVideoById({
|
1077 | videoId: id,
|
1078 | startSeconds: (0, _utils.parseStartTime)(url) || playerVars.start,
|
1079 | endSeconds: (0, _utils.parseEndTime)(url) || playerVars.end
|
1080 | });
|
1081 | return;
|
1082 | }
|
1083 | (0, _utils.getSDK)(SDK_URL, SDK_GLOBAL, SDK_GLOBAL_READY, function (YT) {
|
1084 | return YT.loaded;
|
1085 | }).then(function (YT) {
|
1086 | if (!_this2.container) return;
|
1087 | _this2.player = new YT.Player(_this2.container, _extends({
|
1088 | width: '100%',
|
1089 | height: '100%',
|
1090 | videoId: id,
|
1091 | playerVars: _extends({
|
1092 | autoplay: playing ? 1 : 0,
|
1093 | mute: muted ? 1 : 0,
|
1094 | controls: controls ? 1 : 0,
|
1095 | start: (0, _utils.parseStartTime)(url),
|
1096 | end: (0, _utils.parseEndTime)(url),
|
1097 | origin: window.location.origin,
|
1098 | playsinline: playsinline
|
1099 | }, parsePlaylist(url), playerVars),
|
1100 | events: {
|
1101 | onReady: _this2.props.onReady,
|
1102 | onStateChange: _this2.onStateChange,
|
1103 | onError: function onError(event) {
|
1104 | return _onError(event.data);
|
1105 | }
|
1106 | }
|
1107 | }, embedOptions));
|
1108 | if (loop) {
|
1109 | _this2.player.setLoop(true);
|
1110 | }
|
1111 | }, _onError);
|
1112 | }
|
1113 | }, {
|
1114 | key: 'play',
|
1115 | value: function play() {
|
1116 | this.callPlayer('playVideo');
|
1117 | }
|
1118 | }, {
|
1119 | key: 'pause',
|
1120 | value: function pause() {
|
1121 | this.callPlayer('pauseVideo');
|
1122 | }
|
1123 | }, {
|
1124 | key: 'stop',
|
1125 | value: function stop() {
|
1126 | if (!document.body.contains(this.callPlayer('getIframe'))) return;
|
1127 | this.callPlayer('stopVideo');
|
1128 | }
|
1129 | }, {
|
1130 | key: 'seekTo',
|
1131 | value: function seekTo(amount) {
|
1132 | this.callPlayer('seekTo', amount);
|
1133 | if (!this.props.playing) {
|
1134 | this.pause();
|
1135 | }
|
1136 | }
|
1137 | }, {
|
1138 | key: 'setVolume',
|
1139 | value: function setVolume(fraction) {
|
1140 | this.callPlayer('setVolume', fraction * 100);
|
1141 | }
|
1142 | }, {
|
1143 | key: 'setPlaybackRate',
|
1144 | value: function setPlaybackRate(rate) {
|
1145 | this.callPlayer('setPlaybackRate', rate);
|
1146 | }
|
1147 | }, {
|
1148 | key: 'setLoop',
|
1149 | value: function setLoop(loop) {
|
1150 | this.callPlayer('setLoop', loop);
|
1151 | }
|
1152 | }, {
|
1153 | key: 'getDuration',
|
1154 | value: function getDuration() {
|
1155 | return this.callPlayer('getDuration');
|
1156 | }
|
1157 | }, {
|
1158 | key: 'getCurrentTime',
|
1159 | value: function getCurrentTime() {
|
1160 | return this.callPlayer('getCurrentTime');
|
1161 | }
|
1162 | }, {
|
1163 | key: 'getSecondsLoaded',
|
1164 | value: function getSecondsLoaded() {
|
1165 | return this.callPlayer('getVideoLoadedFraction') * this.getDuration();
|
1166 | }
|
1167 | }, {
|
1168 | key: 'render',
|
1169 | value: function render() {
|
1170 | var style = _extends({
|
1171 | width: '100%',
|
1172 | height: '100%'
|
1173 | }, this.props.style);
|
1174 | return _react2['default'].createElement(
|
1175 | 'div',
|
1176 | { style: style },
|
1177 | _react2['default'].createElement('div', { ref: this.ref })
|
1178 | );
|
1179 | }
|
1180 | }]);
|
1181 |
|
1182 | return YouTube;
|
1183 | }(_react.Component);
|
1184 |
|
1185 | YouTube.displayName = 'YouTube';
|
1186 |
|
1187 | YouTube.canPlay = function (url) {
|
1188 | return MATCH_URL.test(url);
|
1189 | };
|
1190 |
|
1191 | exports['default'] = (0, _singlePlayer2['default'])(YouTube);
|
1192 |
|
1193 | }),
|
1194 |
|
1195 | (function(module, exports, __webpack_require__) {
|
1196 |
|
1197 | "use strict";
|
1198 |
|
1199 |
|
1200 | Object.defineProperty(exports, "__esModule", {
|
1201 | value: true
|
1202 | });
|
1203 |
|
1204 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
1205 |
|
1206 | 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; }; }();
|
1207 |
|
1208 | var _react = __webpack_require__(0);
|
1209 |
|
1210 | var _react2 = _interopRequireDefault(_react);
|
1211 |
|
1212 | var _props2 = __webpack_require__(4);
|
1213 |
|
1214 | var _utils = __webpack_require__(1);
|
1215 |
|
1216 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
1217 |
|
1218 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
1219 |
|
1220 | 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; }
|
1221 |
|
1222 | 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; }
|
1223 |
|
1224 | var SEEK_ON_PLAY_EXPIRY = 5000;
|
1225 |
|
1226 | var Player = function (_Component) {
|
1227 | _inherits(Player, _Component);
|
1228 |
|
1229 | function Player() {
|
1230 | var _ref;
|
1231 |
|
1232 | var _temp, _this, _ret;
|
1233 |
|
1234 | _classCallCheck(this, Player);
|
1235 |
|
1236 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
1237 | args[_key] = arguments[_key];
|
1238 | }
|
1239 |
|
1240 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Player.__proto__ || Object.getPrototypeOf(Player)).call.apply(_ref, [this].concat(args))), _this), _this.mounted = false, _this.isReady = false, _this.isPlaying = false, _this.isLoading = true, _this.loadOnReady = null, _this.startOnPlay = true, _this.seekOnPlay = null, _this.onDurationCalled = false, _this.getInternalPlayer = function (key) {
|
1241 | if (!_this.player) return null;
|
1242 | return _this.player[key];
|
1243 | }, _this.progress = function () {
|
1244 | if (_this.props.url && _this.player && _this.isReady) {
|
1245 | var playedSeconds = _this.getCurrentTime() || 0;
|
1246 | var loadedSeconds = _this.getSecondsLoaded();
|
1247 | var duration = _this.getDuration();
|
1248 | if (duration) {
|
1249 | var progress = {
|
1250 | playedSeconds: playedSeconds,
|
1251 | played: playedSeconds / duration
|
1252 | };
|
1253 | if (loadedSeconds !== null) {
|
1254 | progress.loadedSeconds = loadedSeconds;
|
1255 | progress.loaded = loadedSeconds / duration;
|
1256 | }
|
1257 |
|
1258 | if (progress.played !== _this.prevPlayed || progress.loaded !== _this.prevLoaded) {
|
1259 | _this.props.onProgress(progress);
|
1260 | }
|
1261 | _this.prevPlayed = progress.played;
|
1262 | _this.prevLoaded = progress.loaded;
|
1263 | }
|
1264 | }
|
1265 | _this.progressTimeout = setTimeout(_this.progress, _this.props.progressFrequency || _this.props.progressInterval);
|
1266 | }, _this.onReady = function () {
|
1267 | if (!_this.mounted) return;
|
1268 | _this.isReady = true;
|
1269 | _this.isLoading = false;
|
1270 | var _this$props = _this.props,
|
1271 | onReady = _this$props.onReady,
|
1272 | playing = _this$props.playing,
|
1273 | volume = _this$props.volume,
|
1274 | muted = _this$props.muted;
|
1275 |
|
1276 | onReady();
|
1277 | if (!muted && volume !== null) {
|
1278 | _this.player.setVolume(volume);
|
1279 | }
|
1280 | if (_this.loadOnReady) {
|
1281 | _this.player.load(_this.loadOnReady, true);
|
1282 | _this.loadOnReady = null;
|
1283 | } else if (playing) {
|
1284 | _this.player.play();
|
1285 | }
|
1286 | _this.onDurationCheck();
|
1287 | }, _this.onPlay = function () {
|
1288 | _this.isPlaying = true;
|
1289 | _this.isLoading = false;
|
1290 | var _this$props2 = _this.props,
|
1291 | onStart = _this$props2.onStart,
|
1292 | onPlay = _this$props2.onPlay,
|
1293 | playbackRate = _this$props2.playbackRate;
|
1294 |
|
1295 | if (_this.startOnPlay) {
|
1296 | if (_this.player.setPlaybackRate) {
|
1297 | _this.player.setPlaybackRate(playbackRate);
|
1298 | }
|
1299 | onStart();
|
1300 | _this.startOnPlay = false;
|
1301 | }
|
1302 | onPlay();
|
1303 | if (_this.seekOnPlay) {
|
1304 | _this.seekTo(_this.seekOnPlay);
|
1305 | _this.seekOnPlay = null;
|
1306 | }
|
1307 | _this.onDurationCheck();
|
1308 | }, _this.onPause = function (e) {
|
1309 | _this.isPlaying = false;
|
1310 | if (!_this.isLoading) {
|
1311 | _this.props.onPause(e);
|
1312 | }
|
1313 | }, _this.onEnded = function () {
|
1314 | var _this$props3 = _this.props,
|
1315 | activePlayer = _this$props3.activePlayer,
|
1316 | loop = _this$props3.loop,
|
1317 | onEnded = _this$props3.onEnded;
|
1318 |
|
1319 | if (activePlayer.loopOnEnded && loop) {
|
1320 | _this.seekTo(0);
|
1321 | }
|
1322 | if (!loop) {
|
1323 | _this.isPlaying = false;
|
1324 | onEnded();
|
1325 | }
|
1326 | }, _this.onError = function (e) {
|
1327 | _this.isLoading = false;
|
1328 | _this.props.onError(e);
|
1329 | }, _this.onDurationCheck = function () {
|
1330 | clearTimeout(_this.durationCheckTimeout);
|
1331 | var duration = _this.getDuration();
|
1332 | if (duration) {
|
1333 | if (!_this.onDurationCalled) {
|
1334 | _this.props.onDuration(duration);
|
1335 | _this.onDurationCalled = true;
|
1336 | }
|
1337 | } else {
|
1338 | _this.durationCheckTimeout = setTimeout(_this.onDurationCheck, 100);
|
1339 | }
|
1340 | }, _this.onLoaded = function () {
|
1341 |
|
1342 |
|
1343 | _this.isLoading = false;
|
1344 | }, _this.ref = function (player) {
|
1345 | if (player) {
|
1346 | _this.player = player;
|
1347 | }
|
1348 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
1349 | }
|
1350 |
|
1351 |
|
1352 |
|
1353 | _createClass(Player, [{
|
1354 | key: 'componentDidMount',
|
1355 | value: function componentDidMount() {
|
1356 | this.mounted = true;
|
1357 | this.player.load(this.props.url);
|
1358 | this.progress();
|
1359 | }
|
1360 | }, {
|
1361 | key: 'componentWillUnmount',
|
1362 | value: function componentWillUnmount() {
|
1363 | clearTimeout(this.progressTimeout);
|
1364 | clearTimeout(this.durationCheckTimeout);
|
1365 | if (this.isReady) {
|
1366 | this.player.stop();
|
1367 | }
|
1368 | if (this.player.disablePIP) {
|
1369 | this.player.disablePIP();
|
1370 | }
|
1371 | this.mounted = false;
|
1372 | }
|
1373 | }, {
|
1374 | key: 'componentWillReceiveProps',
|
1375 | value: function componentWillReceiveProps(nextProps) {
|
1376 | var _this2 = this;
|
1377 |
|
1378 |
|
1379 | var _props = this.props,
|
1380 | url = _props.url,
|
1381 | playing = _props.playing,
|
1382 | volume = _props.volume,
|
1383 | muted = _props.muted,
|
1384 | playbackRate = _props.playbackRate,
|
1385 | pip = _props.pip,
|
1386 | loop = _props.loop;
|
1387 |
|
1388 | if (!(0, _utils.isEqual)(url, nextProps.url)) {
|
1389 | if (this.isLoading) {
|
1390 | console.warn('ReactPlayer: the attempt to load ' + nextProps.url + ' is being deferred until the player has loaded');
|
1391 | this.loadOnReady = nextProps.url;
|
1392 | return;
|
1393 | }
|
1394 | this.isLoading = true;
|
1395 | this.startOnPlay = true;
|
1396 | this.onDurationCalled = false;
|
1397 | this.player.load(nextProps.url, this.isReady);
|
1398 | }
|
1399 | if (!playing && nextProps.playing && !this.isPlaying) {
|
1400 | this.player.play();
|
1401 | }
|
1402 | if (playing && !nextProps.playing && this.isPlaying) {
|
1403 | this.player.pause();
|
1404 | }
|
1405 | if (!pip && nextProps.pip && this.player.enablePIP) {
|
1406 | this.player.enablePIP();
|
1407 | } else if (pip && !nextProps.pip && this.player.disablePIP) {
|
1408 | this.player.disablePIP();
|
1409 | }
|
1410 | if (volume !== nextProps.volume && nextProps.volume !== null) {
|
1411 | this.player.setVolume(nextProps.volume);
|
1412 | }
|
1413 | if (muted !== nextProps.muted) {
|
1414 | if (nextProps.muted) {
|
1415 | this.player.mute();
|
1416 | } else {
|
1417 | this.player.unmute();
|
1418 | if (nextProps.volume !== null) {
|
1419 |
|
1420 | setTimeout(function () {
|
1421 | return _this2.player.setVolume(nextProps.volume);
|
1422 | });
|
1423 | }
|
1424 | }
|
1425 | }
|
1426 | if (playbackRate !== nextProps.playbackRate && this.player.setPlaybackRate) {
|
1427 | this.player.setPlaybackRate(nextProps.playbackRate);
|
1428 | }
|
1429 | if (loop !== nextProps.loop && this.player.setLoop) {
|
1430 | this.player.setLoop(nextProps.loop);
|
1431 | }
|
1432 | }
|
1433 | }, {
|
1434 | key: 'getDuration',
|
1435 | value: function getDuration() {
|
1436 | if (!this.isReady) return null;
|
1437 | return this.player.getDuration();
|
1438 | }
|
1439 | }, {
|
1440 | key: 'getCurrentTime',
|
1441 | value: function getCurrentTime() {
|
1442 | if (!this.isReady) return null;
|
1443 | return this.player.getCurrentTime();
|
1444 | }
|
1445 | }, {
|
1446 | key: 'getSecondsLoaded',
|
1447 | value: function getSecondsLoaded() {
|
1448 | if (!this.isReady) return null;
|
1449 | return this.player.getSecondsLoaded();
|
1450 | }
|
1451 | }, {
|
1452 | key: 'seekTo',
|
1453 | value: function seekTo(amount, type) {
|
1454 | var _this3 = this;
|
1455 |
|
1456 |
|
1457 | if (!this.isReady && amount !== 0) {
|
1458 | this.seekOnPlay = amount;
|
1459 | setTimeout(function () {
|
1460 | _this3.seekOnPlay = null;
|
1461 | }, SEEK_ON_PLAY_EXPIRY);
|
1462 | return;
|
1463 | }
|
1464 | var isFraction = !type ? amount > 0 && amount < 1 : type === 'fraction';
|
1465 | if (isFraction) {
|
1466 |
|
1467 | var duration = this.player.getDuration();
|
1468 | if (!duration) {
|
1469 | console.warn('ReactPlayer: could not seek using fraction – duration not yet available');
|
1470 | return;
|
1471 | }
|
1472 | this.player.seekTo(duration * amount);
|
1473 | return;
|
1474 | }
|
1475 | this.player.seekTo(amount);
|
1476 | }
|
1477 | }, {
|
1478 | key: 'render',
|
1479 | value: function render() {
|
1480 | var Player = this.props.activePlayer;
|
1481 | if (!Player) {
|
1482 | return null;
|
1483 | }
|
1484 | return _react2['default'].createElement(Player, _extends({}, this.props, {
|
1485 | ref: this.ref,
|
1486 | onReady: this.onReady,
|
1487 | onPlay: this.onPlay,
|
1488 | onPause: this.onPause,
|
1489 | onEnded: this.onEnded,
|
1490 | onLoaded: this.onLoaded,
|
1491 | onError: this.onError
|
1492 | }));
|
1493 | }
|
1494 | }]);
|
1495 |
|
1496 | return Player;
|
1497 | }(_react.Component);
|
1498 |
|
1499 | Player.displayName = 'Player';
|
1500 | Player.propTypes = _props2.propTypes;
|
1501 | Player.defaultProps = _props2.defaultProps;
|
1502 | exports['default'] = Player;
|
1503 |
|
1504 | }),
|
1505 |
|
1506 | (function(module, exports, __webpack_require__) {
|
1507 |
|
1508 | "use strict";
|
1509 |
|
1510 |
|
1511 | Object.defineProperty(exports, "__esModule", {
|
1512 | value: true
|
1513 | });
|
1514 | exports.SoundCloud = undefined;
|
1515 |
|
1516 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
1517 |
|
1518 | 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; }; }();
|
1519 |
|
1520 | var _react = __webpack_require__(0);
|
1521 |
|
1522 | var _react2 = _interopRequireDefault(_react);
|
1523 |
|
1524 | var _utils = __webpack_require__(1);
|
1525 |
|
1526 | var _singlePlayer = __webpack_require__(2);
|
1527 |
|
1528 | var _singlePlayer2 = _interopRequireDefault(_singlePlayer);
|
1529 |
|
1530 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
1531 |
|
1532 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
1533 |
|
1534 | 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; }
|
1535 |
|
1536 | 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; }
|
1537 |
|
1538 | var SDK_URL = 'https://w.soundcloud.com/player/api.js';
|
1539 | var SDK_GLOBAL = 'SC';
|
1540 | var MATCH_URL = /(soundcloud\.com|snd\.sc)\/.+$/;
|
1541 |
|
1542 | var SoundCloud = exports.SoundCloud = function (_Component) {
|
1543 | _inherits(SoundCloud, _Component);
|
1544 |
|
1545 | function SoundCloud() {
|
1546 | var _ref;
|
1547 |
|
1548 | var _temp, _this, _ret;
|
1549 |
|
1550 | _classCallCheck(this, SoundCloud);
|
1551 |
|
1552 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
1553 | args[_key] = arguments[_key];
|
1554 | }
|
1555 |
|
1556 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = SoundCloud.__proto__ || Object.getPrototypeOf(SoundCloud)).call.apply(_ref, [this].concat(args))), _this), _this.callPlayer = _utils.callPlayer, _this.duration = null, _this.currentTime = null, _this.fractionLoaded = null, _this.mute = function () {
|
1557 | _this.setVolume(0);
|
1558 | }, _this.unmute = function () {
|
1559 | if (_this.props.volume !== null) {
|
1560 | _this.setVolume(_this.props.volume);
|
1561 | }
|
1562 | }, _this.ref = function (iframe) {
|
1563 | _this.iframe = iframe;
|
1564 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
1565 | }
|
1566 |
|
1567 | _createClass(SoundCloud, [{
|
1568 | key: 'load',
|
1569 | value: function load(url, isReady) {
|
1570 | var _this2 = this;
|
1571 |
|
1572 | (0, _utils.getSDK)(SDK_URL, SDK_GLOBAL).then(function (SC) {
|
1573 | if (!_this2.iframe) return;
|
1574 | var _SC$Widget$Events = SC.Widget.Events,
|
1575 | PLAY = _SC$Widget$Events.PLAY,
|
1576 | PLAY_PROGRESS = _SC$Widget$Events.PLAY_PROGRESS,
|
1577 | PAUSE = _SC$Widget$Events.PAUSE,
|
1578 | FINISH = _SC$Widget$Events.FINISH,
|
1579 | ERROR = _SC$Widget$Events.ERROR;
|
1580 |
|
1581 | if (!isReady) {
|
1582 | _this2.player = SC.Widget(_this2.iframe);
|
1583 | _this2.player.bind(PLAY, _this2.props.onPlay);
|
1584 | _this2.player.bind(PAUSE, _this2.props.onPause);
|
1585 | _this2.player.bind(PLAY_PROGRESS, function (e) {
|
1586 | _this2.currentTime = e.currentPosition / 1000;
|
1587 | _this2.fractionLoaded = e.loadedProgress;
|
1588 | });
|
1589 | _this2.player.bind(FINISH, function () {
|
1590 | return _this2.props.onEnded();
|
1591 | });
|
1592 | _this2.player.bind(ERROR, function (e) {
|
1593 | return _this2.props.onError(e);
|
1594 | });
|
1595 | }
|
1596 | _this2.player.load(url, _extends({}, _this2.props.config.soundcloud.options, {
|
1597 | callback: function callback() {
|
1598 | _this2.player.getDuration(function (duration) {
|
1599 | _this2.duration = duration / 1000;
|
1600 | _this2.props.onReady();
|
1601 | });
|
1602 | }
|
1603 | }));
|
1604 | });
|
1605 | }
|
1606 | }, {
|
1607 | key: 'play',
|
1608 | value: function play() {
|
1609 | this.callPlayer('play');
|
1610 | }
|
1611 | }, {
|
1612 | key: 'pause',
|
1613 | value: function pause() {
|
1614 | this.callPlayer('pause');
|
1615 | }
|
1616 | }, {
|
1617 | key: 'stop',
|
1618 | value: function stop() {
|
1619 |
|
1620 | }
|
1621 | }, {
|
1622 | key: 'seekTo',
|
1623 | value: function seekTo(seconds) {
|
1624 | this.callPlayer('seekTo', seconds * 1000);
|
1625 | }
|
1626 | }, {
|
1627 | key: 'setVolume',
|
1628 | value: function setVolume(fraction) {
|
1629 | this.callPlayer('setVolume', fraction * 100);
|
1630 | }
|
1631 | }, {
|
1632 | key: 'getDuration',
|
1633 | value: function getDuration() {
|
1634 | return this.duration;
|
1635 | }
|
1636 | }, {
|
1637 | key: 'getCurrentTime',
|
1638 | value: function getCurrentTime() {
|
1639 | return this.currentTime;
|
1640 | }
|
1641 | }, {
|
1642 | key: 'getSecondsLoaded',
|
1643 | value: function getSecondsLoaded() {
|
1644 | return this.fractionLoaded * this.duration;
|
1645 | }
|
1646 | }, {
|
1647 | key: 'render',
|
1648 | value: function render() {
|
1649 | var style = _extends({
|
1650 | width: '100%',
|
1651 | height: '100%'
|
1652 | }, this.props.style);
|
1653 | return _react2['default'].createElement('iframe', {
|
1654 | ref: this.ref,
|
1655 | src: 'https://w.soundcloud.com/player/?url=' + encodeURIComponent(this.props.url),
|
1656 | style: style,
|
1657 | frameBorder: 0,
|
1658 | allow: 'autoplay'
|
1659 | });
|
1660 | }
|
1661 | }]);
|
1662 |
|
1663 | return SoundCloud;
|
1664 | }(_react.Component);
|
1665 |
|
1666 | SoundCloud.displayName = 'SoundCloud';
|
1667 |
|
1668 | SoundCloud.canPlay = function (url) {
|
1669 | return MATCH_URL.test(url);
|
1670 | };
|
1671 |
|
1672 | SoundCloud.loopOnEnded = true;
|
1673 | exports['default'] = (0, _singlePlayer2['default'])(SoundCloud);
|
1674 |
|
1675 | }),
|
1676 |
|
1677 | (function(module, exports, __webpack_require__) {
|
1678 |
|
1679 | "use strict";
|
1680 |
|
1681 |
|
1682 | Object.defineProperty(exports, "__esModule", {
|
1683 | value: true
|
1684 | });
|
1685 | exports.Vimeo = undefined;
|
1686 |
|
1687 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
1688 |
|
1689 | 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; }; }();
|
1690 |
|
1691 | var _react = __webpack_require__(0);
|
1692 |
|
1693 | var _react2 = _interopRequireDefault(_react);
|
1694 |
|
1695 | var _utils = __webpack_require__(1);
|
1696 |
|
1697 | var _singlePlayer = __webpack_require__(2);
|
1698 |
|
1699 | var _singlePlayer2 = _interopRequireDefault(_singlePlayer);
|
1700 |
|
1701 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
1702 |
|
1703 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
1704 |
|
1705 | 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; }
|
1706 |
|
1707 | 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; }
|
1708 |
|
1709 | var SDK_URL = 'https://player.vimeo.com/api/player.js';
|
1710 | var SDK_GLOBAL = 'Vimeo';
|
1711 | var MATCH_URL = /vimeo\.com\/.+/;
|
1712 | var MATCH_FILE_URL = /vimeo\.com\/external\/.+\.mp4/;
|
1713 |
|
1714 | var Vimeo = exports.Vimeo = function (_Component) {
|
1715 | _inherits(Vimeo, _Component);
|
1716 |
|
1717 | function Vimeo() {
|
1718 | var _ref;
|
1719 |
|
1720 | var _temp, _this, _ret;
|
1721 |
|
1722 | _classCallCheck(this, Vimeo);
|
1723 |
|
1724 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
1725 | args[_key] = arguments[_key];
|
1726 | }
|
1727 |
|
1728 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Vimeo.__proto__ || Object.getPrototypeOf(Vimeo)).call.apply(_ref, [this].concat(args))), _this), _this.callPlayer = _utils.callPlayer, _this.duration = null, _this.currentTime = null, _this.secondsLoaded = null, _this.mute = function () {
|
1729 | _this.setVolume(0);
|
1730 | }, _this.unmute = function () {
|
1731 | if (_this.props.volume !== null) {
|
1732 | _this.setVolume(_this.props.volume);
|
1733 | }
|
1734 | }, _this.ref = function (container) {
|
1735 | _this.container = container;
|
1736 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
1737 | }
|
1738 |
|
1739 | _createClass(Vimeo, [{
|
1740 | key: 'load',
|
1741 | value: function load(url) {
|
1742 | var _this2 = this;
|
1743 |
|
1744 | this.duration = null;
|
1745 | (0, _utils.getSDK)(SDK_URL, SDK_GLOBAL).then(function (Vimeo) {
|
1746 | if (!_this2.container) return;
|
1747 | _this2.player = new Vimeo.Player(_this2.container, _extends({}, _this2.props.config.vimeo.playerOptions, {
|
1748 | url: url,
|
1749 | autoplay: _this2.props.playing,
|
1750 | muted: _this2.props.muted,
|
1751 | loop: _this2.props.loop,
|
1752 | playsinline: _this2.props.playsinline
|
1753 | }));
|
1754 | _this2.player.ready().then(function () {
|
1755 | var iframe = _this2.container.querySelector('iframe');
|
1756 | iframe.style.width = '100%';
|
1757 | iframe.style.height = '100%';
|
1758 | })['catch'](_this2.props.onError);
|
1759 | _this2.player.on('loaded', function () {
|
1760 | _this2.props.onReady();
|
1761 | _this2.refreshDuration();
|
1762 | });
|
1763 | _this2.player.on('play', function () {
|
1764 | _this2.props.onPlay();
|
1765 | _this2.refreshDuration();
|
1766 | });
|
1767 | _this2.player.on('pause', _this2.props.onPause);
|
1768 | _this2.player.on('seeked', function (e) {
|
1769 | return _this2.props.onSeek(e.seconds);
|
1770 | });
|
1771 | _this2.player.on('ended', _this2.props.onEnded);
|
1772 | _this2.player.on('error', _this2.props.onError);
|
1773 | _this2.player.on('timeupdate', function (_ref2) {
|
1774 | var seconds = _ref2.seconds;
|
1775 |
|
1776 | _this2.currentTime = seconds;
|
1777 | });
|
1778 | _this2.player.on('progress', function (_ref3) {
|
1779 | var seconds = _ref3.seconds;
|
1780 |
|
1781 | _this2.secondsLoaded = seconds;
|
1782 | });
|
1783 | }, this.props.onError);
|
1784 | }
|
1785 | }, {
|
1786 | key: 'refreshDuration',
|
1787 | value: function refreshDuration() {
|
1788 | var _this3 = this;
|
1789 |
|
1790 | this.player.getDuration().then(function (duration) {
|
1791 | _this3.duration = duration;
|
1792 | });
|
1793 | }
|
1794 | }, {
|
1795 | key: 'play',
|
1796 | value: function play() {
|
1797 | this.callPlayer('play');
|
1798 | }
|
1799 | }, {
|
1800 | key: 'pause',
|
1801 | value: function pause() {
|
1802 | this.callPlayer('pause');
|
1803 | }
|
1804 | }, {
|
1805 | key: 'stop',
|
1806 | value: function stop() {
|
1807 | this.callPlayer('unload');
|
1808 | }
|
1809 | }, {
|
1810 | key: 'seekTo',
|
1811 | value: function seekTo(seconds) {
|
1812 | this.callPlayer('setCurrentTime', seconds);
|
1813 | }
|
1814 | }, {
|
1815 | key: 'setVolume',
|
1816 | value: function setVolume(fraction) {
|
1817 | this.callPlayer('setVolume', fraction);
|
1818 | }
|
1819 | }, {
|
1820 | key: 'setLoop',
|
1821 | value: function setLoop(loop) {
|
1822 | this.callPlayer('setLoop', loop);
|
1823 | }
|
1824 | }, {
|
1825 | key: 'getDuration',
|
1826 | value: function getDuration() {
|
1827 | return this.duration;
|
1828 | }
|
1829 | }, {
|
1830 | key: 'getCurrentTime',
|
1831 | value: function getCurrentTime() {
|
1832 | return this.currentTime;
|
1833 | }
|
1834 | }, {
|
1835 | key: 'getSecondsLoaded',
|
1836 | value: function getSecondsLoaded() {
|
1837 | return this.secondsLoaded;
|
1838 | }
|
1839 | }, {
|
1840 | key: 'render',
|
1841 | value: function render() {
|
1842 | var style = _extends({
|
1843 | width: '100%',
|
1844 | height: '100%',
|
1845 | overflow: 'hidden',
|
1846 | backgroundColor: 'black'
|
1847 | }, this.props.style);
|
1848 | return _react2['default'].createElement('div', {
|
1849 | key: this.props.url,
|
1850 | ref: this.ref,
|
1851 | style: style
|
1852 | });
|
1853 | }
|
1854 | }]);
|
1855 |
|
1856 | return Vimeo;
|
1857 | }(_react.Component);
|
1858 |
|
1859 | Vimeo.displayName = 'Vimeo';
|
1860 |
|
1861 | Vimeo.canPlay = function (url) {
|
1862 | if (MATCH_FILE_URL.test(url)) {
|
1863 | return false;
|
1864 | }
|
1865 | return MATCH_URL.test(url);
|
1866 | };
|
1867 |
|
1868 | exports['default'] = (0, _singlePlayer2['default'])(Vimeo);
|
1869 |
|
1870 | }),
|
1871 |
|
1872 | (function(module, exports, __webpack_require__) {
|
1873 |
|
1874 | "use strict";
|
1875 |
|
1876 |
|
1877 | Object.defineProperty(exports, "__esModule", {
|
1878 | value: true
|
1879 | });
|
1880 | exports.DailyMotion = undefined;
|
1881 |
|
1882 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
1883 |
|
1884 | var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
1885 |
|
1886 | 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; }; }();
|
1887 |
|
1888 | var _react = __webpack_require__(0);
|
1889 |
|
1890 | var _react2 = _interopRequireDefault(_react);
|
1891 |
|
1892 | var _utils = __webpack_require__(1);
|
1893 |
|
1894 | var _singlePlayer = __webpack_require__(2);
|
1895 |
|
1896 | var _singlePlayer2 = _interopRequireDefault(_singlePlayer);
|
1897 |
|
1898 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
1899 |
|
1900 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
1901 |
|
1902 | 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; }
|
1903 |
|
1904 | 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; }
|
1905 |
|
1906 | var SDK_URL = 'https://api.dmcdn.net/all.js';
|
1907 | var SDK_GLOBAL = 'DM';
|
1908 | var SDK_GLOBAL_READY = 'dmAsyncInit';
|
1909 | var MATCH_URL = /^(?:(?:https?):)?(?:\/\/)?(?:www\.)?(?:(?:dailymotion\.com(?:\/embed)?\/video)|dai\.ly)\/([a-zA-Z0-9]+)(?:_[\w_-]+)?$/;
|
1910 |
|
1911 | var DailyMotion = exports.DailyMotion = function (_Component) {
|
1912 | _inherits(DailyMotion, _Component);
|
1913 |
|
1914 | function DailyMotion() {
|
1915 | var _ref;
|
1916 |
|
1917 | var _temp, _this, _ret;
|
1918 |
|
1919 | _classCallCheck(this, DailyMotion);
|
1920 |
|
1921 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
1922 | args[_key] = arguments[_key];
|
1923 | }
|
1924 |
|
1925 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = DailyMotion.__proto__ || Object.getPrototypeOf(DailyMotion)).call.apply(_ref, [this].concat(args))), _this), _this.callPlayer = _utils.callPlayer, _this.onDurationChange = function () {
|
1926 | var duration = _this.getDuration();
|
1927 | _this.props.onDuration(duration);
|
1928 | }, _this.mute = function () {
|
1929 | _this.callPlayer('setMuted', true);
|
1930 | }, _this.unmute = function () {
|
1931 | _this.callPlayer('setMuted', false);
|
1932 | }, _this.ref = function (container) {
|
1933 | _this.container = container;
|
1934 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
1935 | }
|
1936 |
|
1937 | _createClass(DailyMotion, [{
|
1938 | key: 'load',
|
1939 | value: function load(url) {
|
1940 | var _this2 = this;
|
1941 |
|
1942 | var _props = this.props,
|
1943 | controls = _props.controls,
|
1944 | config = _props.config,
|
1945 | onError = _props.onError,
|
1946 | playing = _props.playing;
|
1947 |
|
1948 | var _url$match = url.match(MATCH_URL),
|
1949 | _url$match2 = _slicedToArray(_url$match, 2),
|
1950 | id = _url$match2[1];
|
1951 |
|
1952 | if (this.player) {
|
1953 | this.player.load(id, {
|
1954 | start: (0, _utils.parseStartTime)(url),
|
1955 | autoplay: playing
|
1956 | });
|
1957 | return;
|
1958 | }
|
1959 | (0, _utils.getSDK)(SDK_URL, SDK_GLOBAL, SDK_GLOBAL_READY, function (DM) {
|
1960 | return DM.player;
|
1961 | }).then(function (DM) {
|
1962 | if (!_this2.container) return;
|
1963 | var Player = DM.player;
|
1964 | _this2.player = new Player(_this2.container, {
|
1965 | width: '100%',
|
1966 | height: '100%',
|
1967 | video: id,
|
1968 | params: _extends({
|
1969 | controls: controls,
|
1970 | autoplay: _this2.props.playing,
|
1971 | mute: _this2.props.muted,
|
1972 | start: (0, _utils.parseStartTime)(url),
|
1973 | origin: window.location.origin
|
1974 | }, config.dailymotion.params),
|
1975 | events: {
|
1976 | apiready: _this2.props.onReady,
|
1977 | seeked: function seeked() {
|
1978 | return _this2.props.onSeek(_this2.player.currentTime);
|
1979 | },
|
1980 | video_end: _this2.props.onEnded,
|
1981 | durationchange: _this2.onDurationChange,
|
1982 | pause: _this2.props.onPause,
|
1983 | playing: _this2.props.onPlay,
|
1984 | waiting: _this2.props.onBuffer,
|
1985 | error: function error(event) {
|
1986 | return onError(event);
|
1987 | }
|
1988 | }
|
1989 | });
|
1990 | }, onError);
|
1991 | }
|
1992 | }, {
|
1993 | key: 'play',
|
1994 | value: function play() {
|
1995 | this.callPlayer('play');
|
1996 | }
|
1997 | }, {
|
1998 | key: 'pause',
|
1999 | value: function pause() {
|
2000 | this.callPlayer('pause');
|
2001 | }
|
2002 | }, {
|
2003 | key: 'stop',
|
2004 | value: function stop() {
|
2005 |
|
2006 | }
|
2007 | }, {
|
2008 | key: 'seekTo',
|
2009 | value: function seekTo(seconds) {
|
2010 | this.callPlayer('seek', seconds);
|
2011 | }
|
2012 | }, {
|
2013 | key: 'setVolume',
|
2014 | value: function setVolume(fraction) {
|
2015 | this.callPlayer('setVolume', fraction);
|
2016 | }
|
2017 | }, {
|
2018 | key: 'getDuration',
|
2019 | value: function getDuration() {
|
2020 | return this.player.duration || null;
|
2021 | }
|
2022 | }, {
|
2023 | key: 'getCurrentTime',
|
2024 | value: function getCurrentTime() {
|
2025 | return this.player.currentTime;
|
2026 | }
|
2027 | }, {
|
2028 | key: 'getSecondsLoaded',
|
2029 | value: function getSecondsLoaded() {
|
2030 | return this.player.bufferedTime;
|
2031 | }
|
2032 | }, {
|
2033 | key: 'render',
|
2034 | value: function render() {
|
2035 | var style = _extends({
|
2036 | width: '100%',
|
2037 | height: '100%',
|
2038 | backgroundColor: 'black'
|
2039 | }, this.props.style);
|
2040 | return _react2['default'].createElement(
|
2041 | 'div',
|
2042 | { style: style },
|
2043 | _react2['default'].createElement('div', { ref: this.ref })
|
2044 | );
|
2045 | }
|
2046 | }]);
|
2047 |
|
2048 | return DailyMotion;
|
2049 | }(_react.Component);
|
2050 |
|
2051 | DailyMotion.displayName = 'DailyMotion';
|
2052 |
|
2053 | DailyMotion.canPlay = function (url) {
|
2054 | return MATCH_URL.test(url);
|
2055 | };
|
2056 |
|
2057 | DailyMotion.loopOnEnded = true;
|
2058 | exports['default'] = (0, _singlePlayer2['default'])(DailyMotion);
|
2059 |
|
2060 | }),
|
2061 |
|
2062 | (function(module, exports, __webpack_require__) {
|
2063 |
|
2064 | "use strict";
|
2065 |
|
2066 |
|
2067 | Object.defineProperty(exports, "__esModule", {
|
2068 | value: true
|
2069 | });
|
2070 | exports.FilePlayer = undefined;
|
2071 |
|
2072 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
2073 |
|
2074 | 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; }; }();
|
2075 |
|
2076 | var _react = __webpack_require__(0);
|
2077 |
|
2078 | var _react2 = _interopRequireDefault(_react);
|
2079 |
|
2080 | var _utils = __webpack_require__(1);
|
2081 |
|
2082 | var _singlePlayer = __webpack_require__(2);
|
2083 |
|
2084 | var _singlePlayer2 = _interopRequireDefault(_singlePlayer);
|
2085 |
|
2086 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
2087 |
|
2088 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2089 |
|
2090 | 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; }
|
2091 |
|
2092 | 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; }
|
2093 |
|
2094 | var IOS = typeof navigator !== 'undefined' && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
2095 | var AUDIO_EXTENSIONS = /\.(m4a|mp4a|mpga|mp2|mp2a|mp3|m2a|m3a|wav|weba|aac|oga|spx)($|\?)/i;
|
2096 | var VIDEO_EXTENSIONS = /\.(mp4|og[gv]|webm|mov|m4v)($|\?)/i;
|
2097 | var HLS_EXTENSIONS = /\.(m3u8)($|\?)/i;
|
2098 | var HLS_SDK_URL = 'https://cdnjs.cloudflare.com/ajax/libs/hls.js/VERSION/hls.min.js';
|
2099 | var HLS_GLOBAL = 'Hls';
|
2100 | var DASH_EXTENSIONS = /\.(mpd)($|\?)/i;
|
2101 | var DASH_SDK_URL = 'https://cdnjs.cloudflare.com/ajax/libs/dashjs/VERSION/dash.all.min.js';
|
2102 | var DASH_GLOBAL = 'dashjs';
|
2103 | var MATCH_DROPBOX_URL = /www\.dropbox\.com\/.+/;
|
2104 |
|
2105 | function canPlay(url) {
|
2106 | if (url instanceof Array) {
|
2107 | var _iteratorNormalCompletion = true;
|
2108 | var _didIteratorError = false;
|
2109 | var _iteratorError = undefined;
|
2110 |
|
2111 | try {
|
2112 | for (var _iterator = url[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
2113 | var item = _step.value;
|
2114 |
|
2115 | if (typeof item === 'string' && canPlay(item)) {
|
2116 | return true;
|
2117 | }
|
2118 | if (canPlay(item.src)) {
|
2119 | return true;
|
2120 | }
|
2121 | }
|
2122 | } catch (err) {
|
2123 | _didIteratorError = true;
|
2124 | _iteratorError = err;
|
2125 | } finally {
|
2126 | try {
|
2127 | if (!_iteratorNormalCompletion && _iterator['return']) {
|
2128 | _iterator['return']();
|
2129 | }
|
2130 | } finally {
|
2131 | if (_didIteratorError) {
|
2132 | throw _iteratorError;
|
2133 | }
|
2134 | }
|
2135 | }
|
2136 |
|
2137 | return false;
|
2138 | }
|
2139 | if ((0, _utils.isMediaStream)(url)) {
|
2140 | return true;
|
2141 | }
|
2142 | return AUDIO_EXTENSIONS.test(url) || VIDEO_EXTENSIONS.test(url) || HLS_EXTENSIONS.test(url) || DASH_EXTENSIONS.test(url);
|
2143 | }
|
2144 |
|
2145 | function canEnablePIP(url) {
|
2146 | return canPlay(url) && !!document.pictureInPictureEnabled && !AUDIO_EXTENSIONS.test(url);
|
2147 | }
|
2148 |
|
2149 | var FilePlayer = exports.FilePlayer = function (_Component) {
|
2150 | _inherits(FilePlayer, _Component);
|
2151 |
|
2152 | function FilePlayer() {
|
2153 | var _ref;
|
2154 |
|
2155 | var _temp, _this, _ret;
|
2156 |
|
2157 | _classCallCheck(this, FilePlayer);
|
2158 |
|
2159 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
2160 | args[_key] = arguments[_key];
|
2161 | }
|
2162 |
|
2163 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = FilePlayer.__proto__ || Object.getPrototypeOf(FilePlayer)).call.apply(_ref, [this].concat(args))), _this), _this.onDisablePIP = function (e) {
|
2164 | var _this$props = _this.props,
|
2165 | onDisablePIP = _this$props.onDisablePIP,
|
2166 | playing = _this$props.playing;
|
2167 |
|
2168 | onDisablePIP(e);
|
2169 | if (playing) {
|
2170 | _this.play();
|
2171 | }
|
2172 | }, _this.onSeek = function (e) {
|
2173 | _this.props.onSeek(e.target.currentTime);
|
2174 | }, _this.mute = function () {
|
2175 | _this.player.muted = true;
|
2176 | }, _this.unmute = function () {
|
2177 | _this.player.muted = false;
|
2178 | }, _this.renderSourceElement = function (source, index) {
|
2179 | if (typeof source === 'string') {
|
2180 | return _react2['default'].createElement('source', { key: index, src: source });
|
2181 | }
|
2182 | return _react2['default'].createElement('source', _extends({ key: index }, source));
|
2183 | }, _this.renderTrack = function (track, index) {
|
2184 | return _react2['default'].createElement('track', _extends({ key: index }, track));
|
2185 | }, _this.ref = function (player) {
|
2186 | _this.player = player;
|
2187 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
2188 | }
|
2189 |
|
2190 | _createClass(FilePlayer, [{
|
2191 | key: 'componentDidMount',
|
2192 | value: function componentDidMount() {
|
2193 | this.addListeners();
|
2194 | if (IOS) {
|
2195 | this.player.load();
|
2196 | }
|
2197 | }
|
2198 | }, {
|
2199 | key: 'componentWillReceiveProps',
|
2200 | value: function componentWillReceiveProps(nextProps) {
|
2201 | if (this.shouldUseAudio(this.props) !== this.shouldUseAudio(nextProps)) {
|
2202 | this.removeListeners();
|
2203 | }
|
2204 | }
|
2205 | }, {
|
2206 | key: 'componentDidUpdate',
|
2207 | value: function componentDidUpdate(prevProps) {
|
2208 | if (this.shouldUseAudio(this.props) !== this.shouldUseAudio(prevProps)) {
|
2209 | this.addListeners();
|
2210 | }
|
2211 | }
|
2212 | }, {
|
2213 | key: 'componentWillUnmount',
|
2214 | value: function componentWillUnmount() {
|
2215 | this.removeListeners();
|
2216 | }
|
2217 | }, {
|
2218 | key: 'addListeners',
|
2219 | value: function addListeners() {
|
2220 | var _props = this.props,
|
2221 | onReady = _props.onReady,
|
2222 | onPlay = _props.onPlay,
|
2223 | onBuffer = _props.onBuffer,
|
2224 | onBufferEnd = _props.onBufferEnd,
|
2225 | onPause = _props.onPause,
|
2226 | onEnded = _props.onEnded,
|
2227 | onError = _props.onError,
|
2228 | playsinline = _props.playsinline,
|
2229 | onEnablePIP = _props.onEnablePIP,
|
2230 | onVolumeChange = _props.onVolumeChange,
|
2231 | videoElementId = _props.videoElementId;
|
2232 |
|
2233 | this.player.addEventListener('canplay', onReady);
|
2234 | this.player.addEventListener('play', onPlay);
|
2235 | this.player.addEventListener('waiting', onBuffer);
|
2236 | this.player.addEventListener('playing', onBufferEnd);
|
2237 | this.player.addEventListener('pause', onPause);
|
2238 | this.player.addEventListener('seeked', this.onSeek);
|
2239 | this.player.addEventListener('ended', onEnded);
|
2240 | this.player.addEventListener('error', onError);
|
2241 | this.player.addEventListener('volumeChange', onVolumeChange);
|
2242 | this.player.setAttribute('id', videoElementId);
|
2243 | this.player.addEventListener('enterpictureinpicture', onEnablePIP);
|
2244 | this.player.addEventListener('leavepictureinpicture', this.onDisablePIP);
|
2245 | if (playsinline) {
|
2246 | this.player.setAttribute('playsinline', '');
|
2247 | this.player.setAttribute('webkit-playsinline', '');
|
2248 | this.player.setAttribute('x5-playsinline', '');
|
2249 | }
|
2250 | }
|
2251 | }, {
|
2252 | key: 'removeListeners',
|
2253 | value: function removeListeners() {
|
2254 | var _props2 = this.props,
|
2255 | onReady = _props2.onReady,
|
2256 | onPlay = _props2.onPlay,
|
2257 | onBuffer = _props2.onBuffer,
|
2258 | onBufferEnd = _props2.onBufferEnd,
|
2259 | onPause = _props2.onPause,
|
2260 | onEnded = _props2.onEnded,
|
2261 | onError = _props2.onError,
|
2262 | onEnablePIP = _props2.onEnablePIP,
|
2263 | onVolumeChange = _props2.onVolumeChange;
|
2264 |
|
2265 | this.player.removeEventListener('canplay', onReady);
|
2266 | this.player.removeEventListener('play', onPlay);
|
2267 | this.player.removeEventListener('waiting', onBuffer);
|
2268 | this.player.removeEventListener('playing', onBufferEnd);
|
2269 | this.player.removeEventListener('pause', onPause);
|
2270 | this.player.removeEventListener('seeked', this.onSeek);
|
2271 | this.player.removeEventListener('ended', onEnded);
|
2272 | this.player.removeEventListener('error', onError);
|
2273 | this.player.removeEventListener('volumeChange', onVolumeChange);
|
2274 | this.player.removeEventListener('enterpictureinpicture', onEnablePIP);
|
2275 | this.player.removeEventListener('leavepictureinpicture', this.onDisablePIP);
|
2276 | }
|
2277 | }, {
|
2278 | key: 'shouldUseAudio',
|
2279 | value: function shouldUseAudio(props) {
|
2280 | if (props.config.file.forceVideo) {
|
2281 | return false;
|
2282 | }
|
2283 | if (props.config.file.attributes.poster) {
|
2284 | return false;
|
2285 | }
|
2286 | return AUDIO_EXTENSIONS.test(props.url) || props.config.file.forceAudio;
|
2287 | }
|
2288 | }, {
|
2289 | key: 'shouldUseHLS',
|
2290 | value: function shouldUseHLS(url) {
|
2291 | return HLS_EXTENSIONS.test(url) && !IOS || this.props.config.file.forceHLS;
|
2292 | }
|
2293 | }, {
|
2294 | key: 'shouldUseDASH',
|
2295 | value: function shouldUseDASH(url) {
|
2296 | return DASH_EXTENSIONS.test(url) || this.props.config.file.forceDASH;
|
2297 | }
|
2298 | }, {
|
2299 | key: 'load',
|
2300 | value: function load(url) {
|
2301 | var _this2 = this;
|
2302 |
|
2303 | var _props$config$file = this.props.config.file,
|
2304 | hlsVersion = _props$config$file.hlsVersion,
|
2305 | dashVersion = _props$config$file.dashVersion;
|
2306 |
|
2307 | if (this.shouldUseHLS(url)) {
|
2308 | (0, _utils.getSDK)(HLS_SDK_URL.replace('VERSION', hlsVersion), HLS_GLOBAL).then(function (Hls) {
|
2309 | _this2.hls = new Hls(_this2.props.config.file.hlsOptions);
|
2310 | _this2.hls.on(Hls.Events.ERROR, function (e, data) {
|
2311 | _this2.props.onError(e, data, _this2.hls, Hls);
|
2312 | });
|
2313 | _this2.hls.loadSource(url);
|
2314 | _this2.hls.attachMedia(_this2.player);
|
2315 | });
|
2316 | }
|
2317 | if (this.shouldUseDASH(url)) {
|
2318 | (0, _utils.getSDK)(DASH_SDK_URL.replace('VERSION', dashVersion), DASH_GLOBAL).then(function (dashjs) {
|
2319 | _this2.dash = dashjs.MediaPlayer().create();
|
2320 | _this2.dash.initialize(_this2.player, url, _this2.props.playing);
|
2321 | _this2.dash.getDebug().setLogToBrowserConsole(false);
|
2322 | });
|
2323 | }
|
2324 |
|
2325 | if (url instanceof Array) {
|
2326 |
|
2327 |
|
2328 |
|
2329 |
|
2330 | this.player.load();
|
2331 | } else if ((0, _utils.isMediaStream)(url)) {
|
2332 | try {
|
2333 | this.player.srcObject = url;
|
2334 | } catch (e) {
|
2335 | this.player.src = window.URL.createObjectURL(url);
|
2336 | }
|
2337 | }
|
2338 | }
|
2339 | }, {
|
2340 | key: 'play',
|
2341 | value: function play() {
|
2342 | var promise = this.player.play();
|
2343 | if (promise) {
|
2344 | promise['catch'](this.props.onError);
|
2345 | }
|
2346 | }
|
2347 | }, {
|
2348 | key: 'pause',
|
2349 | value: function pause() {
|
2350 | this.player.pause();
|
2351 | }
|
2352 | }, {
|
2353 | key: 'stop',
|
2354 | value: function stop() {
|
2355 | this.player.removeAttribute('src');
|
2356 | if (this.hls) {
|
2357 | this.hls.destroy();
|
2358 | }
|
2359 | if (this.dash) {
|
2360 | this.dash.reset();
|
2361 | }
|
2362 | }
|
2363 | }, {
|
2364 | key: 'seekTo',
|
2365 | value: function seekTo(seconds) {
|
2366 | this.player.currentTime = seconds;
|
2367 | }
|
2368 | }, {
|
2369 | key: 'setVolume',
|
2370 | value: function setVolume(fraction) {
|
2371 | this.player.volume = fraction;
|
2372 | }
|
2373 | }, {
|
2374 | key: 'enablePIP',
|
2375 | value: function enablePIP() {
|
2376 | if (this.player.requestPictureInPicture && document.pictureInPictureElement !== this.player) {
|
2377 | this.player.requestPictureInPicture();
|
2378 | }
|
2379 | }
|
2380 | }, {
|
2381 | key: 'disablePIP',
|
2382 | value: function disablePIP() {
|
2383 | if (document.exitPictureInPicture && document.pictureInPictureElement === this.player) {
|
2384 | document.exitPictureInPicture();
|
2385 | }
|
2386 | }
|
2387 | }, {
|
2388 | key: 'setPlaybackRate',
|
2389 | value: function setPlaybackRate(rate) {
|
2390 | this.player.playbackRate = rate;
|
2391 | }
|
2392 | }, {
|
2393 | key: 'getDuration',
|
2394 | value: function getDuration() {
|
2395 | if (!this.player) return null;
|
2396 | var _player = this.player,
|
2397 | duration = _player.duration,
|
2398 | seekable = _player.seekable;
|
2399 |
|
2400 |
|
2401 |
|
2402 | if (duration === Infinity && seekable.length > 0) {
|
2403 | return seekable.end(seekable.length - 1);
|
2404 | }
|
2405 | return duration;
|
2406 | }
|
2407 | }, {
|
2408 | key: 'getCurrentTime',
|
2409 | value: function getCurrentTime() {
|
2410 | if (!this.player) return null;
|
2411 | return this.player.currentTime;
|
2412 | }
|
2413 | }, {
|
2414 | key: 'getSecondsLoaded',
|
2415 | value: function getSecondsLoaded() {
|
2416 | if (!this.player) return null;
|
2417 | var buffered = this.player.buffered;
|
2418 |
|
2419 | if (buffered.length === 0) {
|
2420 | return 0;
|
2421 | }
|
2422 | var end = buffered.end(buffered.length - 1);
|
2423 | var duration = this.getDuration();
|
2424 | if (end > duration) {
|
2425 | return duration;
|
2426 | }
|
2427 | return end;
|
2428 | }
|
2429 | }, {
|
2430 | key: 'getSource',
|
2431 | value: function getSource(url) {
|
2432 | var useHLS = this.shouldUseHLS(url);
|
2433 | var useDASH = this.shouldUseDASH(url);
|
2434 | if (url instanceof Array || (0, _utils.isMediaStream)(url) || useHLS || useDASH) {
|
2435 | return undefined;
|
2436 | }
|
2437 | if (MATCH_DROPBOX_URL.test(url)) {
|
2438 | return url.replace('www.dropbox.com', 'dl.dropboxusercontent.com');
|
2439 | }
|
2440 | return url;
|
2441 | }
|
2442 | }, {
|
2443 | key: 'render',
|
2444 | value: function render() {
|
2445 | var _props3 = this.props,
|
2446 | url = _props3.url,
|
2447 | playing = _props3.playing,
|
2448 | loop = _props3.loop,
|
2449 | controls = _props3.controls,
|
2450 | muted = _props3.muted,
|
2451 | config = _props3.config,
|
2452 | width = _props3.width,
|
2453 | height = _props3.height;
|
2454 |
|
2455 | var useAudio = this.shouldUseAudio(this.props);
|
2456 | var Element = useAudio ? 'audio' : 'video';
|
2457 | var style = {
|
2458 | width: width === 'auto' ? width : '100%',
|
2459 | height: height === 'auto' ? height : '100%'
|
2460 | };
|
2461 | return _react2['default'].createElement(
|
2462 | Element,
|
2463 | _extends({
|
2464 | ref: this.ref,
|
2465 | src: this.getSource(url),
|
2466 | style: style,
|
2467 | preload: 'auto',
|
2468 | autoPlay: playing || undefined,
|
2469 | controls: controls,
|
2470 | muted: muted,
|
2471 | loop: loop
|
2472 | }, config.file.attributes),
|
2473 | url instanceof Array && url.map(this.renderSourceElement),
|
2474 | config.file.tracks.map(this.renderTrack)
|
2475 | );
|
2476 | }
|
2477 | }]);
|
2478 |
|
2479 | return FilePlayer;
|
2480 | }(_react.Component);
|
2481 |
|
2482 | FilePlayer.displayName = 'FilePlayer';
|
2483 | FilePlayer.canPlay = canPlay;
|
2484 | FilePlayer.canEnablePIP = canEnablePIP;
|
2485 | exports['default'] = (0, _singlePlayer2['default'])(FilePlayer);
|
2486 |
|
2487 | }),
|
2488 |
|
2489 | (function(module, exports, __webpack_require__) {
|
2490 |
|
2491 | "use strict";
|
2492 |
|
2493 |
|
2494 | Object.defineProperty(exports, "__esModule", {
|
2495 | value: true
|
2496 | });
|
2497 |
|
2498 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2499 |
|
2500 | var Creative = exports.Creative = function Creative() {
|
2501 | var creativeAttributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
2502 |
|
2503 | _classCallCheck(this, Creative);
|
2504 |
|
2505 | this.id = creativeAttributes.id || null;
|
2506 | this.adId = creativeAttributes.adId || null;
|
2507 | this.sequence = creativeAttributes.sequence || null;
|
2508 | this.apiFramework = creativeAttributes.apiFramework || null;
|
2509 | this.trackingEvents = {};
|
2510 | };
|
2511 |
|
2512 | }),
|
2513 |
|
2514 | (function(module, exports, __webpack_require__) {
|
2515 |
|
2516 | "use strict";
|
2517 |
|
2518 |
|
2519 | Object.defineProperty(exports, "__esModule", {
|
2520 | value: true
|
2521 | });
|
2522 | function track(URLTemplates, variables, options) {
|
2523 | var URLs = resolveURLTemplates(URLTemplates, variables, options);
|
2524 |
|
2525 | URLs.forEach(function (URL) {
|
2526 | if (typeof window !== 'undefined' && window !== null) {
|
2527 | var i = new Image();
|
2528 | i.src = URL;
|
2529 | }
|
2530 | });
|
2531 | }
|
2532 |
|
2533 |
|
2534 |
|
2535 |
|
2536 |
|
2537 |
|
2538 |
|
2539 |
|
2540 | function resolveURLTemplates(URLTemplates) {
|
2541 | var variables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
2542 | var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
2543 |
|
2544 | var URLs = [];
|
2545 |
|
2546 |
|
2547 | if (variables['ASSETURI']) {
|
2548 | variables['ASSETURI'] = encodeURIComponentRFC3986(variables['ASSETURI']);
|
2549 | }
|
2550 | if (variables['CONTENTPLAYHEAD']) {
|
2551 | variables['CONTENTPLAYHEAD'] = encodeURIComponentRFC3986(variables['CONTENTPLAYHEAD']);
|
2552 | }
|
2553 |
|
2554 |
|
2555 | if (variables['ERRORCODE'] && !options.isCustomCode && !/^[0-9]{3}$/.test(variables['ERRORCODE'])) {
|
2556 | variables['ERRORCODE'] = 900;
|
2557 | }
|
2558 |
|
2559 |
|
2560 | variables['CACHEBUSTING'] = leftpad(Math.round(Math.random() * 1.0e8).toString());
|
2561 | variables['TIMESTAMP'] = encodeURIComponentRFC3986(new Date().toISOString());
|
2562 |
|
2563 |
|
2564 | variables['RANDOM'] = variables['random'] = variables['CACHEBUSTING'];
|
2565 |
|
2566 | for (var URLTemplateKey in URLTemplates) {
|
2567 | var resolveURL = URLTemplates[URLTemplateKey];
|
2568 |
|
2569 | if (typeof resolveURL !== 'string') {
|
2570 | continue;
|
2571 | }
|
2572 |
|
2573 | for (var key in variables) {
|
2574 | var value = variables[key];
|
2575 | var macro1 = '[' + key + ']';
|
2576 | var macro2 = '%%' + key + '%%';
|
2577 | resolveURL = resolveURL.replace(macro1, value);
|
2578 | resolveURL = resolveURL.replace(macro2, value);
|
2579 | }
|
2580 | URLs.push(resolveURL);
|
2581 | }
|
2582 |
|
2583 | return URLs;
|
2584 | }
|
2585 |
|
2586 |
|
2587 | function encodeURIComponentRFC3986(str) {
|
2588 | return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
|
2589 | return '%' + c.charCodeAt(0).toString(16);
|
2590 | });
|
2591 | }
|
2592 |
|
2593 | function leftpad(str) {
|
2594 | if (str.length < 8) {
|
2595 | return range(0, 8 - str.length, false).map(function () {
|
2596 | return '0';
|
2597 | }).join('') + str;
|
2598 | }
|
2599 | return str;
|
2600 | }
|
2601 |
|
2602 | function range(left, right, inclusive) {
|
2603 | var result = [];
|
2604 | var ascending = left < right;
|
2605 | var end = !inclusive ? right : ascending ? right + 1 : right - 1;
|
2606 |
|
2607 | for (var i = left; ascending ? i < end : i > end; ascending ? i++ : i--) {
|
2608 | result.push(i);
|
2609 | }
|
2610 | return result;
|
2611 | }
|
2612 |
|
2613 | function isNumeric(n) {
|
2614 | return !isNaN(parseFloat(n)) && isFinite(n);
|
2615 | }
|
2616 |
|
2617 | function flatten(arr) {
|
2618 | return arr.reduce(function (flat, toFlatten) {
|
2619 | return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
|
2620 | }, []);
|
2621 | }
|
2622 |
|
2623 | var util = exports.util = {
|
2624 | track: track,
|
2625 | resolveURLTemplates: resolveURLTemplates,
|
2626 | encodeURIComponentRFC3986: encodeURIComponentRFC3986,
|
2627 | leftpad: leftpad,
|
2628 | range: range,
|
2629 | isNumeric: isNumeric,
|
2630 | flatten: flatten
|
2631 | };
|
2632 |
|
2633 | }),
|
2634 |
|
2635 | (function(module, exports, __webpack_require__) {
|
2636 |
|
2637 | "use strict";
|
2638 |
|
2639 |
|
2640 | Object.defineProperty(exports, "__esModule", {
|
2641 | value: true
|
2642 | });
|
2643 | exports.Facebook = undefined;
|
2644 |
|
2645 | 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; }; }();
|
2646 |
|
2647 | var _react = __webpack_require__(0);
|
2648 |
|
2649 | var _react2 = _interopRequireDefault(_react);
|
2650 |
|
2651 | var _utils = __webpack_require__(1);
|
2652 |
|
2653 | var _singlePlayer = __webpack_require__(2);
|
2654 |
|
2655 | var _singlePlayer2 = _interopRequireDefault(_singlePlayer);
|
2656 |
|
2657 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
2658 |
|
2659 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2660 |
|
2661 | 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; }
|
2662 |
|
2663 | 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; }
|
2664 |
|
2665 | var SDK_URL = '//connect.facebook.net/en_US/sdk.js';
|
2666 | var SDK_GLOBAL = 'FB';
|
2667 | var SDK_GLOBAL_READY = 'fbAsyncInit';
|
2668 | var MATCH_URL = /facebook\.com\/([^/?].+\/)?video(s|\.php)[/?].*$/;
|
2669 | var PLAYER_ID_PREFIX = 'facebook-player-';
|
2670 |
|
2671 | var Facebook = exports.Facebook = function (_Component) {
|
2672 | _inherits(Facebook, _Component);
|
2673 |
|
2674 | function Facebook() {
|
2675 | var _ref;
|
2676 |
|
2677 | var _temp, _this, _ret;
|
2678 |
|
2679 | _classCallCheck(this, Facebook);
|
2680 |
|
2681 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
2682 | args[_key] = arguments[_key];
|
2683 | }
|
2684 |
|
2685 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Facebook.__proto__ || Object.getPrototypeOf(Facebook)).call.apply(_ref, [this].concat(args))), _this), _this.callPlayer = _utils.callPlayer, _this.playerID = PLAYER_ID_PREFIX + (0, _utils.randomString)(), _this.mute = function () {
|
2686 | _this.callPlayer('mute');
|
2687 | }, _this.unmute = function () {
|
2688 | _this.callPlayer('unmute');
|
2689 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
2690 | }
|
2691 |
|
2692 | _createClass(Facebook, [{
|
2693 | key: 'load',
|
2694 | value: function load(url, isReady) {
|
2695 | var _this2 = this;
|
2696 |
|
2697 | if (isReady) {
|
2698 | (0, _utils.getSDK)(SDK_URL, SDK_GLOBAL, SDK_GLOBAL_READY).then(function (FB) {
|
2699 | return FB.XFBML.parse();
|
2700 | });
|
2701 | return;
|
2702 | }
|
2703 | (0, _utils.getSDK)(SDK_URL, SDK_GLOBAL, SDK_GLOBAL_READY).then(function (FB) {
|
2704 | FB.init({
|
2705 | appId: _this2.props.config.facebook.appId,
|
2706 | xfbml: true,
|
2707 | version: 'v2.5'
|
2708 | });
|
2709 | FB.Event.subscribe('xfbml.render', function (msg) {
|
2710 |
|
2711 |
|
2712 | _this2.props.onLoaded();
|
2713 | });
|
2714 | FB.Event.subscribe('xfbml.ready', function (msg) {
|
2715 | if (msg.type === 'video' && msg.id === _this2.playerID) {
|
2716 | _this2.player = msg.instance;
|
2717 | _this2.player.subscribe('startedPlaying', _this2.props.onPlay);
|
2718 | _this2.player.subscribe('paused', _this2.props.onPause);
|
2719 | _this2.player.subscribe('finishedPlaying', _this2.props.onEnded);
|
2720 | _this2.player.subscribe('startedBuffering', _this2.props.onBuffer);
|
2721 | _this2.player.subscribe('finishedBuffering', _this2.props.onBufferEnd);
|
2722 | _this2.player.subscribe('error', _this2.props.onError);
|
2723 | if (!_this2.props.muted) {
|
2724 |
|
2725 | _this2.callPlayer('unmute');
|
2726 | }
|
2727 | _this2.props.onReady();
|
2728 |
|
2729 |
|
2730 |
|
2731 | document.getElementById(_this2.playerID).querySelector('iframe').style.visibility = 'visible';
|
2732 | }
|
2733 | });
|
2734 | });
|
2735 | }
|
2736 | }, {
|
2737 | key: 'play',
|
2738 | value: function play() {
|
2739 | this.callPlayer('play');
|
2740 | }
|
2741 | }, {
|
2742 | key: 'pause',
|
2743 | value: function pause() {
|
2744 | this.callPlayer('pause');
|
2745 | }
|
2746 | }, {
|
2747 | key: 'stop',
|
2748 | value: function stop() {
|
2749 |
|
2750 | }
|
2751 | }, {
|
2752 | key: 'seekTo',
|
2753 | value: function seekTo(seconds) {
|
2754 | this.callPlayer('seek', seconds);
|
2755 | }
|
2756 | }, {
|
2757 | key: 'setVolume',
|
2758 | value: function setVolume(fraction) {
|
2759 | this.callPlayer('setVolume', fraction);
|
2760 | }
|
2761 | }, {
|
2762 | key: 'getDuration',
|
2763 | value: function getDuration() {
|
2764 | return this.callPlayer('getDuration');
|
2765 | }
|
2766 | }, {
|
2767 | key: 'getCurrentTime',
|
2768 | value: function getCurrentTime() {
|
2769 | return this.callPlayer('getCurrentPosition');
|
2770 | }
|
2771 | }, {
|
2772 | key: 'getSecondsLoaded',
|
2773 | value: function getSecondsLoaded() {
|
2774 | return null;
|
2775 | }
|
2776 | }, {
|
2777 | key: 'render',
|
2778 | value: function render() {
|
2779 | var style = {
|
2780 | width: '100%',
|
2781 | height: '100%',
|
2782 | backgroundColor: 'black'
|
2783 | };
|
2784 | return _react2['default'].createElement('div', {
|
2785 | style: style,
|
2786 | id: this.playerID,
|
2787 | className: 'fb-video',
|
2788 | 'data-href': this.props.url,
|
2789 | 'data-autoplay': this.props.playing ? 'true' : 'false',
|
2790 | 'data-allowfullscreen': 'true',
|
2791 | 'data-controls': this.props.controls ? 'true' : 'false'
|
2792 | });
|
2793 | }
|
2794 | }]);
|
2795 |
|
2796 | return Facebook;
|
2797 | }(_react.Component);
|
2798 |
|
2799 | Facebook.displayName = 'Facebook';
|
2800 |
|
2801 | Facebook.canPlay = function (url) {
|
2802 | return MATCH_URL.test(url);
|
2803 | };
|
2804 |
|
2805 | Facebook.loopOnEnded = true;
|
2806 | exports['default'] = (0, _singlePlayer2['default'])(Facebook);
|
2807 |
|
2808 | }),
|
2809 |
|
2810 | (function(module, exports, __webpack_require__) {
|
2811 |
|
2812 | "use strict";
|
2813 |
|
2814 |
|
2815 | Object.defineProperty(exports, "__esModule", {
|
2816 | value: true
|
2817 | });
|
2818 | exports.Streamable = undefined;
|
2819 |
|
2820 | 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; }; }();
|
2821 |
|
2822 | var _react = __webpack_require__(0);
|
2823 |
|
2824 | var _react2 = _interopRequireDefault(_react);
|
2825 |
|
2826 | var _utils = __webpack_require__(1);
|
2827 |
|
2828 | var _singlePlayer = __webpack_require__(2);
|
2829 |
|
2830 | var _singlePlayer2 = _interopRequireDefault(_singlePlayer);
|
2831 |
|
2832 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
2833 |
|
2834 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2835 |
|
2836 | 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; }
|
2837 |
|
2838 | 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; }
|
2839 |
|
2840 | var SDK_URL = '//cdn.embed.ly/player-0.1.0.min.js';
|
2841 | var SDK_GLOBAL = 'playerjs';
|
2842 | var MATCH_URL = /streamable\.com\/([a-z0-9]+)$/;
|
2843 |
|
2844 | var Streamable = exports.Streamable = function (_Component) {
|
2845 | _inherits(Streamable, _Component);
|
2846 |
|
2847 | function Streamable() {
|
2848 | var _ref;
|
2849 |
|
2850 | var _temp, _this, _ret;
|
2851 |
|
2852 | _classCallCheck(this, Streamable);
|
2853 |
|
2854 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
2855 | args[_key] = arguments[_key];
|
2856 | }
|
2857 |
|
2858 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Streamable.__proto__ || Object.getPrototypeOf(Streamable)).call.apply(_ref, [this].concat(args))), _this), _this.callPlayer = _utils.callPlayer, _this.duration = null, _this.currentTime = null, _this.secondsLoaded = null, _this.mute = function () {
|
2859 | _this.callPlayer('mute');
|
2860 | }, _this.unmute = function () {
|
2861 | _this.callPlayer('unmute');
|
2862 | }, _this.ref = function (iframe) {
|
2863 | _this.iframe = iframe;
|
2864 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
2865 | }
|
2866 |
|
2867 | _createClass(Streamable, [{
|
2868 | key: 'load',
|
2869 | value: function load(url) {
|
2870 | var _this2 = this;
|
2871 |
|
2872 | (0, _utils.getSDK)(SDK_URL, SDK_GLOBAL).then(function (playerjs) {
|
2873 | if (!_this2.iframe) return;
|
2874 | _this2.player = new playerjs.Player(_this2.iframe);
|
2875 | _this2.player.setLoop(_this2.props.loop);
|
2876 | _this2.player.on('ready', _this2.props.onReady);
|
2877 | _this2.player.on('play', _this2.props.onPlay);
|
2878 | _this2.player.on('pause', _this2.props.onPause);
|
2879 | _this2.player.on('seeked', _this2.props.onSeek);
|
2880 | _this2.player.on('ended', _this2.props.onEnded);
|
2881 | _this2.player.on('error', _this2.props.onError);
|
2882 | _this2.player.on('timeupdate', function (_ref2) {
|
2883 | var duration = _ref2.duration,
|
2884 | seconds = _ref2.seconds;
|
2885 |
|
2886 | _this2.duration = duration;
|
2887 | _this2.currentTime = seconds;
|
2888 | });
|
2889 | _this2.player.on('buffered', function (_ref3) {
|
2890 | var percent = _ref3.percent;
|
2891 |
|
2892 | if (_this2.duration) {
|
2893 | _this2.secondsLoaded = _this2.duration * percent;
|
2894 | }
|
2895 | });
|
2896 | if (_this2.props.muted) {
|
2897 | _this2.player.mute();
|
2898 | }
|
2899 | }, this.props.onError);
|
2900 | }
|
2901 | }, {
|
2902 | key: 'play',
|
2903 | value: function play() {
|
2904 | this.callPlayer('play');
|
2905 | }
|
2906 | }, {
|
2907 | key: 'pause',
|
2908 | value: function pause() {
|
2909 | this.callPlayer('pause');
|
2910 | }
|
2911 | }, {
|
2912 | key: 'stop',
|
2913 | value: function stop() {
|
2914 |
|
2915 | }
|
2916 | }, {
|
2917 | key: 'seekTo',
|
2918 | value: function seekTo(seconds) {
|
2919 | this.callPlayer('setCurrentTime', seconds);
|
2920 | }
|
2921 | }, {
|
2922 | key: 'setVolume',
|
2923 | value: function setVolume(fraction) {
|
2924 | this.callPlayer('setVolume', fraction * 100);
|
2925 | }
|
2926 | }, {
|
2927 | key: 'setLoop',
|
2928 | value: function setLoop(loop) {
|
2929 | this.callPlayer('setLoop', loop);
|
2930 | }
|
2931 | }, {
|
2932 | key: 'getDuration',
|
2933 | value: function getDuration() {
|
2934 | return this.duration;
|
2935 | }
|
2936 | }, {
|
2937 | key: 'getCurrentTime',
|
2938 | value: function getCurrentTime() {
|
2939 | return this.currentTime;
|
2940 | }
|
2941 | }, {
|
2942 | key: 'getSecondsLoaded',
|
2943 | value: function getSecondsLoaded() {
|
2944 | return this.secondsLoaded;
|
2945 | }
|
2946 | }, {
|
2947 | key: 'render',
|
2948 | value: function render() {
|
2949 | var id = this.props.url.match(MATCH_URL)[1];
|
2950 | var style = {
|
2951 | width: '100%',
|
2952 | height: '100%'
|
2953 | };
|
2954 | return _react2['default'].createElement('iframe', {
|
2955 | ref: this.ref,
|
2956 | src: 'https://streamable.com/o/' + id,
|
2957 | frameBorder: '0',
|
2958 | scrolling: 'no',
|
2959 | style: style,
|
2960 | allowFullScreen: true
|
2961 | });
|
2962 | }
|
2963 | }]);
|
2964 |
|
2965 | return Streamable;
|
2966 | }(_react.Component);
|
2967 |
|
2968 | Streamable.displayName = 'Streamable';
|
2969 |
|
2970 | Streamable.canPlay = function (url) {
|
2971 | return MATCH_URL.test(url);
|
2972 | };
|
2973 |
|
2974 | exports['default'] = (0, _singlePlayer2['default'])(Streamable);
|
2975 |
|
2976 | }),
|
2977 |
|
2978 | (function(module, exports, __webpack_require__) {
|
2979 |
|
2980 | "use strict";
|
2981 |
|
2982 |
|
2983 | Object.defineProperty(exports, "__esModule", {
|
2984 | value: true
|
2985 | });
|
2986 | exports.FaceMask = undefined;
|
2987 |
|
2988 | 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; }; }();
|
2989 |
|
2990 | var _react = __webpack_require__(0);
|
2991 |
|
2992 | var _react2 = _interopRequireDefault(_react);
|
2993 |
|
2994 | var _utils = __webpack_require__(1);
|
2995 |
|
2996 | var _singlePlayer = __webpack_require__(2);
|
2997 |
|
2998 | var _singlePlayer2 = _interopRequireDefault(_singlePlayer);
|
2999 |
|
3000 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
3001 |
|
3002 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
3003 |
|
3004 | 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; }
|
3005 |
|
3006 | 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; }
|
3007 |
|
3008 | var SDK_URL = 'https://www.nfl.com/libs/playaction/api.js';
|
3009 | var SDK_GLOBAL = 'nfl';
|
3010 | var MATCH_FILE_URL = /nflent-vh\.akamaihd\.net\/.+\.m3u8/;
|
3011 | var PLAYER_ID_PREFIX = 'facemask-player-';
|
3012 |
|
3013 | var FaceMask = exports.FaceMask = function (_Component) {
|
3014 | _inherits(FaceMask, _Component);
|
3015 |
|
3016 | function FaceMask() {
|
3017 | var _ref;
|
3018 |
|
3019 | var _temp, _this, _ret;
|
3020 |
|
3021 | _classCallCheck(this, FaceMask);
|
3022 |
|
3023 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
3024 | args[_key] = arguments[_key];
|
3025 | }
|
3026 |
|
3027 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = FaceMask.__proto__ || Object.getPrototypeOf(FaceMask)).call.apply(_ref, [this].concat(args))), _this), _this.callPlayer = _utils.callPlayer, _this.duration = null, _this.volume = null, _this.currentTime = null, _this.secondsLoaded = null, _this.playerID = PLAYER_ID_PREFIX + (0, _utils.randomString)(), _this.ref = function (container) {
|
3028 | _this.container = container;
|
3029 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
3030 | }
|
3031 |
|
3032 | _createClass(FaceMask, [{
|
3033 | key: 'load',
|
3034 | value: function load(url) {
|
3035 | var _this2 = this;
|
3036 |
|
3037 | this.duration = null;
|
3038 | (0, _utils.getSDK)(SDK_URL, SDK_GLOBAL).then(function (nfl) {
|
3039 | if (!_this2.container) return;
|
3040 |
|
3041 | _this2.player = new nfl.playaction({
|
3042 | containerId: _this2.playerID,
|
3043 | initialVideo: { url: url },
|
3044 | height: '100%',
|
3045 | width: '100%'
|
3046 | });
|
3047 | var _nfl$playaction$EVENT = nfl.playaction.EVENTS,
|
3048 | PLAYER_READY = _nfl$playaction$EVENT.PLAYER_READY,
|
3049 | STATUS = _nfl$playaction$EVENT.STATUS,
|
3050 | TIME_UPDATE = _nfl$playaction$EVENT.TIME_UPDATE,
|
3051 | VOLUME = _nfl$playaction$EVENT.VOLUME;
|
3052 | var _nfl$playaction$STATU = nfl.playaction.STATUS,
|
3053 | COMPLETE = _nfl$playaction$STATU.COMPLETE,
|
3054 | ERROR = _nfl$playaction$STATU.ERROR,
|
3055 | PAUSED = _nfl$playaction$STATU.PAUSED,
|
3056 | PLAYING = _nfl$playaction$STATU.PLAYING;
|
3057 |
|
3058 | _this2.player.on(PLAYER_READY, _this2.props.onReady);
|
3059 | _this2.player.on(VOLUME, _this2.props.onVolumeChange);
|
3060 | _this2.player.on(STATUS, function (e) {
|
3061 | switch (e.status) {
|
3062 | case COMPLETE:
|
3063 | {
|
3064 | _this2.props.onEnded();
|
3065 | break;
|
3066 | }
|
3067 | case ERROR:
|
3068 | {
|
3069 | _this2.props.onError(e);
|
3070 | break;
|
3071 | }
|
3072 | case PAUSED:
|
3073 | {
|
3074 | _this2.props.onPause();
|
3075 | break;
|
3076 | }
|
3077 | case PLAYING:
|
3078 | {
|
3079 | _this2.props.onPlay();
|
3080 | break;
|
3081 | }
|
3082 | }
|
3083 | });
|
3084 | _this2.player.on(TIME_UPDATE, function (_ref2) {
|
3085 | var currentTime = _ref2.currentTime,
|
3086 | duration = _ref2.duration;
|
3087 |
|
3088 | _this2.currentTime = currentTime;
|
3089 | _this2.duration = duration || Infinity;
|
3090 | });
|
3091 | }, this.props.onError);
|
3092 | }
|
3093 | }, {
|
3094 | key: 'play',
|
3095 | value: function play() {
|
3096 | this.callPlayer('play');
|
3097 | }
|
3098 | }, {
|
3099 | key: 'pause',
|
3100 | value: function pause() {
|
3101 | this.callPlayer('pause');
|
3102 | }
|
3103 | }, {
|
3104 | key: 'stop',
|
3105 | value: function stop() {
|
3106 | this.callPlayer('destroy');
|
3107 | }
|
3108 | }, {
|
3109 | key: 'seekTo',
|
3110 | value: function seekTo(seconds) {
|
3111 | this.callPlayer('seek', seconds);
|
3112 | }
|
3113 | }, {
|
3114 | key: 'setVolume',
|
3115 | value: function setVolume(fraction) {
|
3116 |
|
3117 | }
|
3118 | }, {
|
3119 | key: 'mute',
|
3120 | value: function mute() {
|
3121 | this.callPlayer('mute');
|
3122 | }
|
3123 | }, {
|
3124 | key: 'unmute',
|
3125 | value: function unmute() {
|
3126 | this.callPlayer('unmute');
|
3127 | }
|
3128 | }, {
|
3129 | key: 'getDuration',
|
3130 | value: function getDuration() {
|
3131 | return this.duration;
|
3132 | }
|
3133 | }, {
|
3134 | key: 'getCurrentTime',
|
3135 | value: function getCurrentTime() {
|
3136 | return this.currentTime;
|
3137 | }
|
3138 | }, {
|
3139 | key: 'getSecondsLoaded',
|
3140 | value: function getSecondsLoaded() {
|
3141 | return this.secondsLoaded;
|
3142 | }
|
3143 | }, {
|
3144 | key: 'render',
|
3145 | value: function render() {
|
3146 | var style = {
|
3147 | width: '100%',
|
3148 | height: '100%'
|
3149 | };
|
3150 | return _react2['default'].createElement('div', {
|
3151 | id: this.playerID,
|
3152 | ref: this.ref,
|
3153 | style: style
|
3154 | });
|
3155 | }
|
3156 | }]);
|
3157 |
|
3158 | return FaceMask;
|
3159 | }(_react.Component);
|
3160 |
|
3161 | FaceMask.displayName = 'FaceMask';
|
3162 |
|
3163 | FaceMask.canPlay = function (url) {
|
3164 | return MATCH_FILE_URL.test(url);
|
3165 | };
|
3166 |
|
3167 | exports['default'] = (0, _singlePlayer2['default'])(FaceMask);
|
3168 |
|
3169 | }),
|
3170 |
|
3171 | (function(module, exports, __webpack_require__) {
|
3172 |
|
3173 | "use strict";
|
3174 |
|
3175 |
|
3176 | Object.defineProperty(exports, "__esModule", {
|
3177 | value: true
|
3178 | });
|
3179 | exports.Wistia = undefined;
|
3180 |
|
3181 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
3182 |
|
3183 | 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; }; }();
|
3184 |
|
3185 | var _react = __webpack_require__(0);
|
3186 |
|
3187 | var _react2 = _interopRequireDefault(_react);
|
3188 |
|
3189 | var _utils = __webpack_require__(1);
|
3190 |
|
3191 | var _singlePlayer = __webpack_require__(2);
|
3192 |
|
3193 | var _singlePlayer2 = _interopRequireDefault(_singlePlayer);
|
3194 |
|
3195 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
3196 |
|
3197 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
3198 |
|
3199 | 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; }
|
3200 |
|
3201 | 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; }
|
3202 |
|
3203 | var SDK_URL = '//fast.wistia.com/assets/external/E-v1.js';
|
3204 | var SDK_GLOBAL = 'Wistia';
|
3205 | var MATCH_URL = /(?:wistia\.com|wi\.st)\/(?:medias|embed)\/(.*)$/;
|
3206 |
|
3207 | var Wistia = exports.Wistia = function (_Component) {
|
3208 | _inherits(Wistia, _Component);
|
3209 |
|
3210 | function Wistia() {
|
3211 | var _ref;
|
3212 |
|
3213 | var _temp, _this, _ret;
|
3214 |
|
3215 | _classCallCheck(this, Wistia);
|
3216 |
|
3217 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
3218 | args[_key] = arguments[_key];
|
3219 | }
|
3220 |
|
3221 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Wistia.__proto__ || Object.getPrototypeOf(Wistia)).call.apply(_ref, [this].concat(args))), _this), _this.callPlayer = _utils.callPlayer, _this.mute = function () {
|
3222 | _this.callPlayer('mute');
|
3223 | }, _this.unmute = function () {
|
3224 | _this.callPlayer('unmute');
|
3225 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
3226 | }
|
3227 |
|
3228 | _createClass(Wistia, [{
|
3229 | key: 'getID',
|
3230 | value: function getID(url) {
|
3231 | return url && url.match(MATCH_URL)[1];
|
3232 | }
|
3233 | }, {
|
3234 | key: 'load',
|
3235 | value: function load(url) {
|
3236 | var _this2 = this;
|
3237 |
|
3238 | var _props = this.props,
|
3239 | playing = _props.playing,
|
3240 | muted = _props.muted,
|
3241 | controls = _props.controls,
|
3242 | _onReady = _props.onReady,
|
3243 | onPlay = _props.onPlay,
|
3244 | onPause = _props.onPause,
|
3245 | onSeek = _props.onSeek,
|
3246 | onEnded = _props.onEnded,
|
3247 | config = _props.config,
|
3248 | onError = _props.onError;
|
3249 |
|
3250 | (0, _utils.getSDK)(SDK_URL, SDK_GLOBAL).then(function () {
|
3251 | window._wq = window._wq || [];
|
3252 | window._wq.push({
|
3253 | id: _this2.getID(url),
|
3254 | options: _extends({
|
3255 | autoPlay: playing,
|
3256 | silentAutoPlay: 'allow',
|
3257 | muted: muted,
|
3258 | controlsVisibleOnLoad: controls
|
3259 | }, config.wistia.options),
|
3260 | onReady: function onReady(player) {
|
3261 | _this2.player = player;
|
3262 | _this2.unbind();
|
3263 | _this2.player.bind('play', onPlay);
|
3264 | _this2.player.bind('pause', onPause);
|
3265 | _this2.player.bind('seek', onSeek);
|
3266 | _this2.player.bind('end', onEnded);
|
3267 | _onReady();
|
3268 | }
|
3269 | });
|
3270 | }, onError);
|
3271 | }
|
3272 | }, {
|
3273 | key: 'play',
|
3274 | value: function play() {
|
3275 | this.callPlayer('play');
|
3276 | }
|
3277 | }, {
|
3278 | key: 'pause',
|
3279 | value: function pause() {
|
3280 | this.callPlayer('pause');
|
3281 | }
|
3282 | }, {
|
3283 | key: 'unbind',
|
3284 | value: function unbind() {
|
3285 | var _props2 = this.props,
|
3286 | onPlay = _props2.onPlay,
|
3287 | onPause = _props2.onPause,
|
3288 | onSeek = _props2.onSeek,
|
3289 | onEnded = _props2.onEnded;
|
3290 |
|
3291 | this.player.unbind('play', onPlay);
|
3292 | this.player.unbind('pause', onPause);
|
3293 | this.player.unbind('seek', onSeek);
|
3294 | this.player.unbind('end', onEnded);
|
3295 | }
|
3296 | }, {
|
3297 | key: 'stop',
|
3298 | value: function stop() {
|
3299 | this.unbind();
|
3300 | this.callPlayer('remove');
|
3301 | }
|
3302 | }, {
|
3303 | key: 'seekTo',
|
3304 | value: function seekTo(seconds) {
|
3305 | this.callPlayer('time', seconds);
|
3306 | }
|
3307 | }, {
|
3308 | key: 'setVolume',
|
3309 | value: function setVolume(fraction) {
|
3310 | this.callPlayer('volume', fraction);
|
3311 | }
|
3312 | }, {
|
3313 | key: 'setPlaybackRate',
|
3314 | value: function setPlaybackRate(rate) {
|
3315 | this.callPlayer('playbackRate', rate);
|
3316 | }
|
3317 | }, {
|
3318 | key: 'getDuration',
|
3319 | value: function getDuration() {
|
3320 | return this.callPlayer('duration');
|
3321 | }
|
3322 | }, {
|
3323 | key: 'getCurrentTime',
|
3324 | value: function getCurrentTime() {
|
3325 | return this.callPlayer('time');
|
3326 | }
|
3327 | }, {
|
3328 | key: 'getSecondsLoaded',
|
3329 | value: function getSecondsLoaded() {
|
3330 | return null;
|
3331 | }
|
3332 | }, {
|
3333 | key: 'render',
|
3334 | value: function render() {
|
3335 | var id = this.getID(this.props.url);
|
3336 | var className = 'wistia_embed wistia_async_' + id;
|
3337 | var style = {
|
3338 | width: '100%',
|
3339 | height: '100%'
|
3340 | };
|
3341 | return _react2['default'].createElement('div', { key: id, className: className, style: style });
|
3342 | }
|
3343 | }]);
|
3344 |
|
3345 | return Wistia;
|
3346 | }(_react.Component);
|
3347 |
|
3348 | Wistia.displayName = 'Wistia';
|
3349 |
|
3350 | Wistia.canPlay = function (url) {
|
3351 | return MATCH_URL.test(url);
|
3352 | };
|
3353 |
|
3354 | Wistia.loopOnEnded = true;
|
3355 | exports['default'] = (0, _singlePlayer2['default'])(Wistia);
|
3356 |
|
3357 | }),
|
3358 |
|
3359 | (function(module, exports, __webpack_require__) {
|
3360 |
|
3361 | "use strict";
|
3362 |
|
3363 |
|
3364 | Object.defineProperty(exports, "__esModule", {
|
3365 | value: true
|
3366 | });
|
3367 | exports.Twitch = undefined;
|
3368 |
|
3369 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
3370 |
|
3371 | 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; }; }();
|
3372 |
|
3373 | var _react = __webpack_require__(0);
|
3374 |
|
3375 | var _react2 = _interopRequireDefault(_react);
|
3376 |
|
3377 | var _utils = __webpack_require__(1);
|
3378 |
|
3379 | var _singlePlayer = __webpack_require__(2);
|
3380 |
|
3381 | var _singlePlayer2 = _interopRequireDefault(_singlePlayer);
|
3382 |
|
3383 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
3384 |
|
3385 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
3386 |
|
3387 | 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; }
|
3388 |
|
3389 | 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; }
|
3390 |
|
3391 | var SDK_URL = 'https://player.twitch.tv/js/embed/v1.js';
|
3392 | var SDK_GLOBAL = 'Twitch';
|
3393 | var MATCH_VIDEO_URL = /(?:www\.|go\.)?twitch\.tv\/videos\/(\d+)($|\?)/;
|
3394 | var MATCH_CHANNEL_URL = /(?:www\.|go\.)?twitch\.tv\/([a-z0-9_]+)($|\?)/;
|
3395 | var PLAYER_ID_PREFIX = 'twitch-player-';
|
3396 |
|
3397 | var Twitch = exports.Twitch = function (_Component) {
|
3398 | _inherits(Twitch, _Component);
|
3399 |
|
3400 | function Twitch() {
|
3401 | var _ref;
|
3402 |
|
3403 | var _temp, _this, _ret;
|
3404 |
|
3405 | _classCallCheck(this, Twitch);
|
3406 |
|
3407 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
3408 | args[_key] = arguments[_key];
|
3409 | }
|
3410 |
|
3411 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Twitch.__proto__ || Object.getPrototypeOf(Twitch)).call.apply(_ref, [this].concat(args))), _this), _this.callPlayer = _utils.callPlayer, _this.playerID = PLAYER_ID_PREFIX + (0, _utils.randomString)(), _this.mute = function () {
|
3412 | _this.callPlayer('setMuted', true);
|
3413 | }, _this.unmute = function () {
|
3414 | _this.callPlayer('setMuted', false);
|
3415 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
3416 | }
|
3417 |
|
3418 | _createClass(Twitch, [{
|
3419 | key: 'load',
|
3420 | value: function load(url, isReady) {
|
3421 | var _this2 = this;
|
3422 |
|
3423 | var _props = this.props,
|
3424 | playsinline = _props.playsinline,
|
3425 | onError = _props.onError,
|
3426 | config = _props.config;
|
3427 |
|
3428 | var isChannel = MATCH_CHANNEL_URL.test(url);
|
3429 | var id = isChannel ? url.match(MATCH_CHANNEL_URL)[1] : url.match(MATCH_VIDEO_URL)[1];
|
3430 | if (isReady) {
|
3431 | if (isChannel) {
|
3432 | this.player.setChannel(id);
|
3433 | } else {
|
3434 | this.player.setVideo('v' + id);
|
3435 | }
|
3436 | return;
|
3437 | }
|
3438 | (0, _utils.getSDK)(SDK_URL, SDK_GLOBAL).then(function (Twitch) {
|
3439 | _this2.player = new Twitch.Player(_this2.playerID, _extends({
|
3440 | video: isChannel ? '' : id,
|
3441 | channel: isChannel ? id : '',
|
3442 | height: '100%',
|
3443 | width: '100%',
|
3444 | playsinline: playsinline,
|
3445 | autoplay: _this2.props.playing,
|
3446 | muted: _this2.props.muted
|
3447 | }, config.twitch.options));
|
3448 | var _Twitch$Player = Twitch.Player,
|
3449 | READY = _Twitch$Player.READY,
|
3450 | PLAYING = _Twitch$Player.PLAYING,
|
3451 | PAUSE = _Twitch$Player.PAUSE,
|
3452 | ENDED = _Twitch$Player.ENDED;
|
3453 |
|
3454 | _this2.player.addEventListener(READY, _this2.props.onReady);
|
3455 | _this2.player.addEventListener(PLAYING, _this2.props.onPlay);
|
3456 | _this2.player.addEventListener(PAUSE, _this2.props.onPause);
|
3457 | _this2.player.addEventListener(ENDED, _this2.props.onEnded);
|
3458 | }, onError);
|
3459 | }
|
3460 | }, {
|
3461 | key: 'play',
|
3462 | value: function play() {
|
3463 | this.callPlayer('play');
|
3464 | }
|
3465 | }, {
|
3466 | key: 'pause',
|
3467 | value: function pause() {
|
3468 | this.callPlayer('pause');
|
3469 | }
|
3470 | }, {
|
3471 | key: 'stop',
|
3472 | value: function stop() {
|
3473 | this.callPlayer('pause');
|
3474 | }
|
3475 | }, {
|
3476 | key: 'seekTo',
|
3477 | value: function seekTo(seconds) {
|
3478 | this.callPlayer('seek', seconds);
|
3479 | }
|
3480 | }, {
|
3481 | key: 'getVolume',
|
3482 | value: function getVolume() {
|
3483 | return this.callPlayer('getVolume');
|
3484 | }
|
3485 | }, {
|
3486 | key: 'getMuted',
|
3487 | value: function getMuted() {
|
3488 | return this.callPlayer('getMuted');
|
3489 | }
|
3490 | }, {
|
3491 | key: 'setVolume',
|
3492 | value: function setVolume(fraction) {
|
3493 | this.callPlayer('setVolume', fraction);
|
3494 | }
|
3495 | }, {
|
3496 | key: 'getDuration',
|
3497 | value: function getDuration() {
|
3498 | return this.callPlayer('getDuration');
|
3499 | }
|
3500 | }, {
|
3501 | key: 'getCurrentTime',
|
3502 | value: function getCurrentTime() {
|
3503 | return this.callPlayer('getCurrentTime');
|
3504 | }
|
3505 | }, {
|
3506 | key: 'getSecondsLoaded',
|
3507 | value: function getSecondsLoaded() {
|
3508 | return null;
|
3509 | }
|
3510 | }, {
|
3511 | key: 'render',
|
3512 | value: function render() {
|
3513 | var style = {
|
3514 | width: '100%',
|
3515 | height: '100%'
|
3516 | };
|
3517 | return _react2['default'].createElement('div', { style: style, id: this.playerID });
|
3518 | }
|
3519 | }]);
|
3520 |
|
3521 | return Twitch;
|
3522 | }(_react.Component);
|
3523 |
|
3524 | Twitch.displayName = 'Twitch';
|
3525 |
|
3526 | Twitch.canPlay = function (url) {
|
3527 | return MATCH_VIDEO_URL.test(url) || MATCH_CHANNEL_URL.test(url);
|
3528 | };
|
3529 |
|
3530 | Twitch.loopOnEnded = true;
|
3531 | exports['default'] = (0, _singlePlayer2['default'])(Twitch);
|
3532 |
|
3533 | }),
|
3534 |
|
3535 | (function(module, exports, __webpack_require__) {
|
3536 |
|
3537 | "use strict";
|
3538 |
|
3539 |
|
3540 | Object.defineProperty(exports, "__esModule", {
|
3541 | value: true
|
3542 | });
|
3543 | exports.UstreamLive = undefined;
|
3544 |
|
3545 | 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; }; }();
|
3546 |
|
3547 | var _react = __webpack_require__(0);
|
3548 |
|
3549 | var _react2 = _interopRequireDefault(_react);
|
3550 |
|
3551 | var _utils = __webpack_require__(1);
|
3552 |
|
3553 | var _singlePlayer = __webpack_require__(2);
|
3554 |
|
3555 | var _singlePlayer2 = _interopRequireDefault(_singlePlayer);
|
3556 |
|
3557 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
3558 |
|
3559 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
3560 |
|
3561 | 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; }
|
3562 |
|
3563 | 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; }
|
3564 |
|
3565 | var SDK_URL = 'https://developers.ustream.tv/js/ustream-embedapi.min.js';
|
3566 | var SDK_GLOBAL = 'UstreamEmbed';
|
3567 | var MATCH_URL = /(ustream.tv\/channel\/)([^#&?/]*)/;
|
3568 | var PLAYER_ID_PREFIX = 'UstreamLive-player-';
|
3569 |
|
3570 | var UstreamLive = exports.UstreamLive = function (_Component) {
|
3571 | _inherits(UstreamLive, _Component);
|
3572 |
|
3573 | function UstreamLive() {
|
3574 | var _ref;
|
3575 |
|
3576 | var _temp, _this, _ret;
|
3577 |
|
3578 | _classCallCheck(this, UstreamLive);
|
3579 |
|
3580 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
3581 | args[_key] = arguments[_key];
|
3582 | }
|
3583 |
|
3584 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = UstreamLive.__proto__ || Object.getPrototypeOf(UstreamLive)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
|
3585 | ustreamSrc: null
|
3586 | }, _this.playerID = PLAYER_ID_PREFIX + (0, _utils.randomString)(), _this.callPlayer = _utils.callPlayer, _this.mute = function () {}, _this.unmute = function () {}, _this.ref = function (container) {
|
3587 | _this.container = container;
|
3588 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
3589 | }
|
3590 |
|
3591 | _createClass(UstreamLive, [{
|
3592 | key: 'parseId',
|
3593 | value: function parseId(url) {
|
3594 | var m = url.match(MATCH_URL);
|
3595 | return m[2];
|
3596 | }
|
3597 | }, {
|
3598 | key: 'componentDidUpdate',
|
3599 | value: function componentDidUpdate(prevProps) {
|
3600 |
|
3601 | if (prevProps.url && prevProps.url !== this.props.url) {
|
3602 | this.setState({
|
3603 | ustreamSrc: null
|
3604 | });
|
3605 | }
|
3606 | }
|
3607 | }, {
|
3608 | key: 'load',
|
3609 | value: function load() {
|
3610 | var _this2 = this;
|
3611 |
|
3612 | var _props = this.props,
|
3613 | onEnded = _props.onEnded,
|
3614 | onError = _props.onError,
|
3615 | onPause = _props.onPause,
|
3616 | onPlay = _props.onPlay,
|
3617 | onReady = _props.onReady,
|
3618 | playing = _props.playing,
|
3619 | url = _props.url;
|
3620 |
|
3621 | var channelId = this.parseId(url);
|
3622 | this.setState({
|
3623 | ustreamSrc: 'https://www.ustream.tv/embed/' + channelId + '?html5ui=1&autoplay=' + playing + '&controls=false&showtitle=false'
|
3624 | });
|
3625 | (0, _utils.getSDK)(SDK_URL, SDK_GLOBAL).then(function (UstreamEmbed) {
|
3626 | if (!_this2.container) return;
|
3627 | _this2.currentTime = 0;
|
3628 | _this2.player = UstreamEmbed(_this2.playerID);
|
3629 | _this2.player.addListener('playing', function (type, playing) {
|
3630 | if (playing) {
|
3631 | _this2.playTime = Date.now();
|
3632 | onPlay();
|
3633 | } else {
|
3634 | _this2.currentTime = _this2.getCurrentTime();
|
3635 | _this2.playTime = null;
|
3636 | onPause();
|
3637 | }
|
3638 | });
|
3639 | _this2.player.addListener('live', onReady);
|
3640 | _this2.player.addListener('offline', onReady);
|
3641 | _this2.player.addListener('finished', onEnded);
|
3642 | _this2.player.getProperty('duration', function (duration) {
|
3643 | _this2.player.duration = duration || Infinity;
|
3644 | });
|
3645 | }, onError);
|
3646 | }
|
3647 |
|
3648 |
|
3649 |
|
3650 |
|
3651 | }, {
|
3652 | key: 'play',
|
3653 | value: function play() {
|
3654 | this.callPlayer('callMethod', 'play');
|
3655 | }
|
3656 | }, {
|
3657 | key: 'pause',
|
3658 | value: function pause() {
|
3659 | this.callPlayer('callMethod', 'pause');
|
3660 | }
|
3661 | }, {
|
3662 | key: 'stop',
|
3663 | value: function stop() {
|
3664 | this.callPlayer('callMethod', 'stop');
|
3665 | }
|
3666 | }, {
|
3667 | key: 'seekTo',
|
3668 | value: function seekTo(seconds) {
|
3669 | this.callPlayer('callMethod', 'seek', seconds);
|
3670 | }
|
3671 | }, {
|
3672 | key: 'setVolume',
|
3673 | value: function setVolume(fraction) {
|
3674 | this.callPlayer('callMethod', 'volume', fraction * 100);
|
3675 | }
|
3676 | }, {
|
3677 | key: 'getDuration',
|
3678 | value: function getDuration() {
|
3679 | return Infinity;
|
3680 | }
|
3681 | }, {
|
3682 | key: 'getCurrentTime',
|
3683 | value: function getCurrentTime() {
|
3684 | var playing = 0;
|
3685 | if (this.playTime) {
|
3686 | playing = (Date.now() - this.playTime) / 1000;
|
3687 | }
|
3688 | return this.currentTime + playing;
|
3689 | }
|
3690 | }, {
|
3691 | key: 'getSecondsLoaded',
|
3692 | value: function getSecondsLoaded() {
|
3693 | return null;
|
3694 | }
|
3695 | }, {
|
3696 | key: 'render',
|
3697 | value: function render() {
|
3698 | var style = {
|
3699 | width: '100%',
|
3700 | height: '100%'
|
3701 | };
|
3702 |
|
3703 | var ustreamSrc = this.state.ustreamSrc;
|
3704 |
|
3705 | return ustreamSrc && _react2['default'].createElement('iframe', {
|
3706 | id: this.playerID,
|
3707 | ref: this.ref,
|
3708 | src: ustreamSrc,
|
3709 | frameBorder: '0',
|
3710 | scrolling: 'no',
|
3711 | style: style,
|
3712 | allowFullScreen: true
|
3713 | });
|
3714 | }
|
3715 | }]);
|
3716 |
|
3717 | return UstreamLive;
|
3718 | }(_react.Component);
|
3719 |
|
3720 | UstreamLive.displayName = 'UstreamLive';
|
3721 |
|
3722 | UstreamLive.canPlay = function (url) {
|
3723 | return MATCH_URL.test(url);
|
3724 | };
|
3725 |
|
3726 | UstreamLive.loopOnEnded = false;
|
3727 | exports['default'] = (0, _singlePlayer2['default'])(UstreamLive);
|
3728 |
|
3729 | }),
|
3730 |
|
3731 | (function(module, exports, __webpack_require__) {
|
3732 |
|
3733 | "use strict";
|
3734 |
|
3735 |
|
3736 | Object.defineProperty(exports, "__esModule", {
|
3737 | value: true
|
3738 | });
|
3739 | exports.UstreamVideo = undefined;
|
3740 |
|
3741 | 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; }; }();
|
3742 |
|
3743 | var _react = __webpack_require__(0);
|
3744 |
|
3745 | var _react2 = _interopRequireDefault(_react);
|
3746 |
|
3747 | var _utils = __webpack_require__(1);
|
3748 |
|
3749 | var _singlePlayer = __webpack_require__(2);
|
3750 |
|
3751 | var _singlePlayer2 = _interopRequireDefault(_singlePlayer);
|
3752 |
|
3753 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
3754 |
|
3755 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
3756 |
|
3757 | 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; }
|
3758 |
|
3759 | 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; }
|
3760 |
|
3761 | var SDK_URL = 'https://developers.ustream.tv/js/ustream-embedapi.min.js';
|
3762 | var SDK_GLOBAL = 'UstreamEmbed';
|
3763 | var MATCH_URL = /(ustream.tv\/recorded\/)([^#&?/]*)/;
|
3764 | var PLAYER_ID_PREFIX = 'UstreamVideo-player-';
|
3765 |
|
3766 | var UstreamVideo = exports.UstreamVideo = function (_Component) {
|
3767 | _inherits(UstreamVideo, _Component);
|
3768 |
|
3769 | function UstreamVideo() {
|
3770 | var _ref;
|
3771 |
|
3772 | var _temp, _this, _ret;
|
3773 |
|
3774 | _classCallCheck(this, UstreamVideo);
|
3775 |
|
3776 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
3777 | args[_key] = arguments[_key];
|
3778 | }
|
3779 |
|
3780 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = UstreamVideo.__proto__ || Object.getPrototypeOf(UstreamVideo)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
|
3781 | ustreamSrc: null
|
3782 | }, _this.playerID = PLAYER_ID_PREFIX + (0, _utils.randomString)(), _this.callPlayer = _utils.callPlayer, _this.mute = function () {}, _this.unmute = function () {}, _this.ref = function (container) {
|
3783 | _this.container = container;
|
3784 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
3785 | }
|
3786 |
|
3787 | _createClass(UstreamVideo, [{
|
3788 | key: 'parseId',
|
3789 | value: function parseId(url) {
|
3790 | var m = url.match(MATCH_URL);
|
3791 | return m[2];
|
3792 | }
|
3793 | }, {
|
3794 | key: 'componentDidUpdate',
|
3795 | value: function componentDidUpdate(prevProps) {
|
3796 |
|
3797 | if (prevProps.url && prevProps.url !== this.props.url) {
|
3798 | this.setState({
|
3799 | ustreamSrc: null
|
3800 | });
|
3801 | }
|
3802 | }
|
3803 | }, {
|
3804 | key: 'componentWillUnmount',
|
3805 | value: function componentWillUnmount() {
|
3806 |
|
3807 | if (this.currentTimeInterval) {
|
3808 | clearInterval(this.currentTimeInterval);
|
3809 | }
|
3810 | }
|
3811 |
|
3812 |
|
3813 |
|
3814 |
|
3815 |
|
3816 |
|
3817 | }, {
|
3818 | key: 'initInterval',
|
3819 | value: function initInterval() {
|
3820 | var _this2 = this;
|
3821 |
|
3822 | if (this.currentTimeInterval) {
|
3823 | return;
|
3824 | }
|
3825 | this.currentTimeInterval = setInterval(function () {
|
3826 | if (_this2.player) {
|
3827 | _this2.player.getProperty('progress', function (progress) {
|
3828 | _this2.player.currentTime = progress;
|
3829 | });
|
3830 | _this2.player.getProperty('duration', function (duration) {
|
3831 | _this2.player.duration = duration;
|
3832 | });
|
3833 | }
|
3834 | }, 500);
|
3835 | }
|
3836 | }, {
|
3837 | key: 'load',
|
3838 | value: function load() {
|
3839 | var _this3 = this;
|
3840 |
|
3841 | var _props = this.props,
|
3842 | onEnded = _props.onEnded,
|
3843 | onError = _props.onError,
|
3844 | onPause = _props.onPause,
|
3845 | onPlay = _props.onPlay,
|
3846 | onReady = _props.onReady,
|
3847 | playing = _props.playing,
|
3848 | url = _props.url;
|
3849 |
|
3850 | var videoId = this.parseId(url);
|
3851 | this.setState({
|
3852 | ustreamSrc: 'https://www.ustream.tv/embed/recorded/' + videoId + '?html5ui=1&autoplay=' + playing + '&controls=false&showtitle=false'
|
3853 | });
|
3854 | (0, _utils.getSDK)(SDK_URL, SDK_GLOBAL).then(function (UstreamEmbed) {
|
3855 | if (!_this3.container) return;
|
3856 | _this3.player = UstreamEmbed(_this3.playerID);
|
3857 | _this3.player.addListener('playing', function (type, playing) {
|
3858 | playing ? onPlay() : onPause();
|
3859 | });
|
3860 | _this3.player.addListener('ready', function () {
|
3861 | _this3.initInterval();
|
3862 | onReady();
|
3863 | });
|
3864 | _this3.player.addListener('finished', onEnded);
|
3865 | }, onError);
|
3866 | }
|
3867 |
|
3868 |
|
3869 |
|
3870 |
|
3871 | }, {
|
3872 | key: 'play',
|
3873 | value: function play() {
|
3874 | this.callPlayer('callMethod', 'play');
|
3875 | }
|
3876 | }, {
|
3877 | key: 'pause',
|
3878 | value: function pause() {
|
3879 | this.callPlayer('callMethod', 'pause');
|
3880 | }
|
3881 | }, {
|
3882 | key: 'stop',
|
3883 | value: function stop() {
|
3884 | this.callPlayer('callMethod', 'stop');
|
3885 | }
|
3886 | }, {
|
3887 | key: 'seekTo',
|
3888 | value: function seekTo(seconds) {
|
3889 | this.callPlayer('callMethod', 'seek', seconds);
|
3890 | }
|
3891 | }, {
|
3892 | key: 'setVolume',
|
3893 | value: function setVolume(fraction) {
|
3894 | this.callPlayer('callMethod', 'volume', fraction * 100);
|
3895 | }
|
3896 | }, {
|
3897 | key: 'getDuration',
|
3898 | value: function getDuration() {
|
3899 | return this.player.duration;
|
3900 | }
|
3901 | }, {
|
3902 | key: 'getCurrentTime',
|
3903 | value: function getCurrentTime() {
|
3904 | return this.player.currentTime;
|
3905 | }
|
3906 | }, {
|
3907 | key: 'getSecondsLoaded',
|
3908 | value: function getSecondsLoaded() {
|
3909 | return null;
|
3910 | }
|
3911 | }, {
|
3912 | key: 'render',
|
3913 | value: function render() {
|
3914 | var style = {
|
3915 | width: '100%',
|
3916 | height: '100%'
|
3917 | };
|
3918 |
|
3919 | var ustreamSrc = this.state.ustreamSrc;
|
3920 |
|
3921 | return ustreamSrc && _react2['default'].createElement('iframe', {
|
3922 | id: this.playerID,
|
3923 | ref: this.ref,
|
3924 | src: ustreamSrc,
|
3925 | frameBorder: '0',
|
3926 | scrolling: 'no',
|
3927 | style: style,
|
3928 | allowFullScreen: true
|
3929 | });
|
3930 | }
|
3931 | }]);
|
3932 |
|
3933 | return UstreamVideo;
|
3934 | }(_react.Component);
|
3935 |
|
3936 | UstreamVideo.displayName = 'UstreamVideo';
|
3937 |
|
3938 | UstreamVideo.canPlay = function (url) {
|
3939 | return MATCH_URL.test(url);
|
3940 | };
|
3941 |
|
3942 | UstreamVideo.loopOnEnded = false;
|
3943 | exports['default'] = (0, _singlePlayer2['default'])(UstreamVideo);
|
3944 |
|
3945 | }),
|
3946 |
|
3947 | (function(module, exports, __webpack_require__) {
|
3948 |
|
3949 | "use strict";
|
3950 |
|
3951 |
|
3952 | Object.defineProperty(exports, "__esModule", {
|
3953 | value: true
|
3954 | });
|
3955 | exports.Iframe = undefined;
|
3956 |
|
3957 | 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; }; }();
|
3958 |
|
3959 | var _react = __webpack_require__(0);
|
3960 |
|
3961 | var _react2 = _interopRequireDefault(_react);
|
3962 |
|
3963 | var _utils = __webpack_require__(1);
|
3964 |
|
3965 | var _singlePlayer = __webpack_require__(2);
|
3966 |
|
3967 | var _singlePlayer2 = _interopRequireDefault(_singlePlayer);
|
3968 |
|
3969 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
3970 |
|
3971 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
3972 |
|
3973 | 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; }
|
3974 |
|
3975 | 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; }
|
3976 |
|
3977 | var PLAYER_ID_PREFIX = 'Iframe-player-';
|
3978 |
|
3979 | var Iframe = exports.Iframe = function (_Component) {
|
3980 | _inherits(Iframe, _Component);
|
3981 |
|
3982 | function Iframe() {
|
3983 | var _ref;
|
3984 |
|
3985 | var _temp, _this, _ret;
|
3986 |
|
3987 | _classCallCheck(this, Iframe);
|
3988 |
|
3989 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
3990 | args[_key] = arguments[_key];
|
3991 | }
|
3992 |
|
3993 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Iframe.__proto__ || Object.getPrototypeOf(Iframe)).call.apply(_ref, [this].concat(args))), _this), _this.playerID = PLAYER_ID_PREFIX + (0, _utils.randomString)(), _this.player = {
|
3994 | currentTime: 0
|
3995 | }, _this.mute = function () {
|
3996 |
|
3997 | }, _this.unmute = function () {
|
3998 |
|
3999 | }, _this.ref = function (container) {
|
4000 | _this.container = container;
|
4001 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
4002 | }
|
4003 |
|
4004 | _createClass(Iframe, [{
|
4005 | key: 'load',
|
4006 | value: function load(url) {
|
4007 | var _this2 = this;
|
4008 |
|
4009 | if (!this.container) {
|
4010 | this.props.onReady();
|
4011 | } else {
|
4012 | setTimeout(function () {
|
4013 | return _this2.props.onReady();
|
4014 | }, 3000);
|
4015 | }
|
4016 | }
|
4017 | }, {
|
4018 | key: 'play',
|
4019 | value: function play() {
|
4020 | this.playTime = Date.now();
|
4021 | this.props.onPlay();
|
4022 | }
|
4023 | }, {
|
4024 | key: 'pause',
|
4025 | value: function pause() {
|
4026 | this.player.currentTime = this.getCurrentTime();
|
4027 | this.playTime = null;
|
4028 | this.props.onPause();
|
4029 | }
|
4030 | }, {
|
4031 | key: 'stop',
|
4032 | value: function stop() {
|
4033 | this.player.currentTime = this.getCurrentTime();
|
4034 | this.playTime = null;
|
4035 | this.props.onPause();
|
4036 | }
|
4037 | }, {
|
4038 | key: 'seekTo',
|
4039 | value: function seekTo(seconds) {
|
4040 |
|
4041 | }
|
4042 | }, {
|
4043 | key: 'setVolume',
|
4044 | value: function setVolume(fraction) {
|
4045 |
|
4046 | }
|
4047 | }, {
|
4048 | key: 'getDuration',
|
4049 | value: function getDuration() {
|
4050 | return Infinity;
|
4051 | }
|
4052 | }, {
|
4053 | key: 'getCurrentTime',
|
4054 | value: function getCurrentTime() {
|
4055 | var playing = 0;
|
4056 | if (this.playTime) {
|
4057 | playing = (Date.now() - this.playTime) / 1000;
|
4058 | }
|
4059 | return this.player.currentTime + playing;
|
4060 | }
|
4061 | }, {
|
4062 | key: 'getSecondsLoaded',
|
4063 | value: function getSecondsLoaded() {
|
4064 | return null;
|
4065 | }
|
4066 | }, {
|
4067 | key: 'render',
|
4068 | value: function render() {
|
4069 | var style = {
|
4070 | width: '100%',
|
4071 | height: '100%'
|
4072 | };
|
4073 | var _props = this.props,
|
4074 | url = _props.url,
|
4075 | playing = _props.playing;
|
4076 |
|
4077 | if (playing) {
|
4078 | return _react2['default'].createElement('iframe', {
|
4079 | id: this.playerID,
|
4080 | ref: this.ref,
|
4081 | src: playing && url,
|
4082 | frameBorder: '0',
|
4083 | scrolling: 'no',
|
4084 | style: style,
|
4085 | allowFullScreen: true
|
4086 | });
|
4087 | } else {
|
4088 |
|
4089 | return _react2['default'].createElement(
|
4090 | 'div',
|
4091 | { style: style },
|
4092 | _react2['default'].createElement(
|
4093 | 'div',
|
4094 | { style: {
|
4095 | alignItems: 'center',
|
4096 | background: 'rgba(255,255,255,0.3)',
|
4097 | display: 'flex',
|
4098 | height: '100%',
|
4099 | justifyContent: 'center',
|
4100 | width: '100%'
|
4101 | } },
|
4102 | _react2['default'].createElement('div', { className: 'pause', style: {
|
4103 | borderStyle: 'double',
|
4104 | borderWidth: '0px 0px 0px 50px',
|
4105 | color: 'gray',
|
4106 | height: '60px'
|
4107 | } })
|
4108 | )
|
4109 | );
|
4110 | }
|
4111 | }
|
4112 | }]);
|
4113 |
|
4114 | return Iframe;
|
4115 | }(_react.Component);
|
4116 |
|
4117 | Iframe.displayName = 'Iframe';
|
4118 |
|
4119 | Iframe.canPlay = function (url) {
|
4120 | return true;
|
4121 | };
|
4122 |
|
4123 | exports['default'] = (0, _singlePlayer2['default'])(Iframe);
|
4124 |
|
4125 | }),
|
4126 |
|
4127 | (function(module, exports, __webpack_require__) {
|
4128 |
|
4129 | "use strict";
|
4130 |
|
4131 |
|
4132 | Object.defineProperty(exports, "__esModule", {
|
4133 | value: true
|
4134 | });
|
4135 | exports.Mixcloud = undefined;
|
4136 |
|
4137 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
4138 |
|
4139 | 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; }; }();
|
4140 |
|
4141 | var _react = __webpack_require__(0);
|
4142 |
|
4143 | var _react2 = _interopRequireDefault(_react);
|
4144 |
|
4145 | var _utils = __webpack_require__(1);
|
4146 |
|
4147 | var _singlePlayer = __webpack_require__(2);
|
4148 |
|
4149 | var _singlePlayer2 = _interopRequireDefault(_singlePlayer);
|
4150 |
|
4151 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
4152 |
|
4153 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
4154 |
|
4155 | 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; }
|
4156 |
|
4157 | 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; }
|
4158 |
|
4159 | var SDK_URL = '//widget.mixcloud.com/media/js/widgetApi.js';
|
4160 | var SDK_GLOBAL = 'Mixcloud';
|
4161 | var MATCH_URL = /mixcloud\.com\/([^/]+\/[^/]+)/;
|
4162 |
|
4163 | var Mixcloud = exports.Mixcloud = function (_Component) {
|
4164 | _inherits(Mixcloud, _Component);
|
4165 |
|
4166 | function Mixcloud() {
|
4167 | var _ref;
|
4168 |
|
4169 | var _temp, _this, _ret;
|
4170 |
|
4171 | _classCallCheck(this, Mixcloud);
|
4172 |
|
4173 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
4174 | args[_key] = arguments[_key];
|
4175 | }
|
4176 |
|
4177 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Mixcloud.__proto__ || Object.getPrototypeOf(Mixcloud)).call.apply(_ref, [this].concat(args))), _this), _this.callPlayer = _utils.callPlayer, _this.duration = null, _this.currentTime = null, _this.secondsLoaded = null, _this.mute = function () {
|
4178 |
|
4179 | }, _this.unmute = function () {
|
4180 |
|
4181 | }, _this.ref = function (iframe) {
|
4182 | _this.iframe = iframe;
|
4183 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
4184 | }
|
4185 |
|
4186 | _createClass(Mixcloud, [{
|
4187 | key: 'load',
|
4188 | value: function load(url) {
|
4189 | var _this2 = this;
|
4190 |
|
4191 | (0, _utils.getSDK)(SDK_URL, SDK_GLOBAL).then(function (Mixcloud) {
|
4192 | _this2.player = Mixcloud.PlayerWidget(_this2.iframe);
|
4193 | _this2.player.ready.then(function () {
|
4194 | _this2.player.events.play.on(_this2.props.onPlay);
|
4195 | _this2.player.events.pause.on(_this2.props.onPause);
|
4196 | _this2.player.events.ended.on(_this2.props.onEnded);
|
4197 | _this2.player.events.error.on(_this2.props.error);
|
4198 | _this2.player.events.progress.on(function (seconds, duration) {
|
4199 | _this2.currentTime = seconds;
|
4200 | _this2.duration = duration;
|
4201 | });
|
4202 | _this2.props.onReady();
|
4203 | });
|
4204 | }, this.props.onError);
|
4205 | }
|
4206 | }, {
|
4207 | key: 'play',
|
4208 | value: function play() {
|
4209 | this.callPlayer('play');
|
4210 | }
|
4211 | }, {
|
4212 | key: 'pause',
|
4213 | value: function pause() {
|
4214 | this.callPlayer('pause');
|
4215 | }
|
4216 | }, {
|
4217 | key: 'stop',
|
4218 | value: function stop() {
|
4219 |
|
4220 | }
|
4221 | }, {
|
4222 | key: 'seekTo',
|
4223 | value: function seekTo(seconds) {
|
4224 | this.callPlayer('seek', seconds);
|
4225 | }
|
4226 | }, {
|
4227 | key: 'setVolume',
|
4228 | value: function setVolume(fraction) {
|
4229 |
|
4230 | }
|
4231 | }, {
|
4232 | key: 'getDuration',
|
4233 | value: function getDuration() {
|
4234 | return this.duration;
|
4235 | }
|
4236 | }, {
|
4237 | key: 'getCurrentTime',
|
4238 | value: function getCurrentTime() {
|
4239 | return this.currentTime;
|
4240 | }
|
4241 | }, {
|
4242 | key: 'getSecondsLoaded',
|
4243 | value: function getSecondsLoaded() {
|
4244 | return null;
|
4245 | }
|
4246 | }, {
|
4247 | key: 'render',
|
4248 | value: function render() {
|
4249 | var _props = this.props,
|
4250 | url = _props.url,
|
4251 | config = _props.config;
|
4252 |
|
4253 | var id = url.match(MATCH_URL)[1];
|
4254 | var style = {
|
4255 | width: '100%',
|
4256 | height: '100%'
|
4257 | };
|
4258 | var query = (0, _utils.queryString)(_extends({}, config.mixcloud.options, {
|
4259 | feed: '/' + id + '/'
|
4260 | }));
|
4261 |
|
4262 |
|
4263 | return _react2['default'].createElement('iframe', {
|
4264 | key: id,
|
4265 | ref: this.ref,
|
4266 | style: style,
|
4267 | src: 'https://www.mixcloud.com/widget/iframe/?' + query,
|
4268 | frameBorder: '0'
|
4269 | });
|
4270 | }
|
4271 | }]);
|
4272 |
|
4273 | return Mixcloud;
|
4274 | }(_react.Component);
|
4275 |
|
4276 | Mixcloud.displayName = 'Mixcloud';
|
4277 |
|
4278 | Mixcloud.canPlay = function (url) {
|
4279 | return MATCH_URL.test(url);
|
4280 | };
|
4281 |
|
4282 | Mixcloud.loopOnEnded = true;
|
4283 | exports['default'] = (0, _singlePlayer2['default'])(Mixcloud);
|
4284 |
|
4285 | }),
|
4286 |
|
4287 | (function(module, exports, __webpack_require__) {
|
4288 |
|
4289 | "use strict";
|
4290 |
|
4291 |
|
4292 | Object.defineProperty(exports, "__esModule", {
|
4293 | value: true
|
4294 | });
|
4295 | exports.VAST = undefined;
|
4296 |
|
4297 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
4298 |
|
4299 | 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; }; }();
|
4300 |
|
4301 | var _react = __webpack_require__(0);
|
4302 |
|
4303 | var _react2 = _interopRequireDefault(_react);
|
4304 |
|
4305 | var _vpaidHtml5Client = __webpack_require__(39);
|
4306 |
|
4307 | var _vpaidHtml5Client2 = _interopRequireDefault(_vpaidHtml5Client);
|
4308 |
|
4309 | var _vastClient = __webpack_require__(43);
|
4310 |
|
4311 | var _utils = __webpack_require__(1);
|
4312 |
|
4313 | var _singlePlayer = __webpack_require__(2);
|
4314 |
|
4315 | var _singlePlayer2 = _interopRequireDefault(_singlePlayer);
|
4316 |
|
4317 | var _FilePlayer = __webpack_require__(10);
|
4318 |
|
4319 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
4320 |
|
4321 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
4322 |
|
4323 | 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; }
|
4324 |
|
4325 | 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; }
|
4326 |
|
4327 | var PLAYER_ID_PREFIX = 'vast-player-';
|
4328 | var CONTENT_ID_PREFIX = 'vast-content-';
|
4329 | var SKIP_ID_PREFIX = 'vast-skip-';
|
4330 | var MATCH_URL = /^VAST:https:\/\//i;
|
4331 |
|
4332 | var VAST = exports.VAST = function (_Component) {
|
4333 | _inherits(VAST, _Component);
|
4334 |
|
4335 | function VAST() {
|
4336 | var _ref;
|
4337 |
|
4338 | var _temp, _this, _ret;
|
4339 |
|
4340 | _classCallCheck(this, VAST);
|
4341 |
|
4342 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
4343 | args[_key] = arguments[_key];
|
4344 | }
|
4345 |
|
4346 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = VAST.__proto__ || Object.getPrototypeOf(VAST)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
|
4347 | canSkip: false,
|
4348 | framework: null,
|
4349 | preMuteVolume: 0.0,
|
4350 | sources: [],
|
4351 | tracker: null,
|
4352 | type: null,
|
4353 | vastClient: new _vastClient.VASTClient(),
|
4354 | vpaidAdUnit: null,
|
4355 | vpaidClient: null
|
4356 | }, _this.playerID = PLAYER_ID_PREFIX + (0, _utils.randomString)(), _this.contentID = CONTENT_ID_PREFIX + (0, _utils.randomString)(), _this.skipID = SKIP_ID_PREFIX + (0, _utils.randomString)(), _this.callPlayer = _utils.callPlayer, _this.mute = function () {
|
4357 | var _this$state = _this.state,
|
4358 | framework = _this$state.framework,
|
4359 | vpaidAdUnit = _this$state.vpaidAdUnit;
|
4360 |
|
4361 | if (framework === 'VPAID') {
|
4362 | _this.setState({
|
4363 | preMuteVolume: _this.container.volume
|
4364 | });
|
4365 | vpaidAdUnit.setAdVolume(0.0);
|
4366 | } else {
|
4367 | _this.container.mute();
|
4368 | }
|
4369 | }, _this.unmute = function () {
|
4370 | var _this$state2 = _this.state,
|
4371 | framework = _this$state2.framework,
|
4372 | preMuteVolume = _this$state2.preMuteVolume,
|
4373 | vpaidAdUnit = _this$state2.vpaidAdUnit;
|
4374 |
|
4375 | if (framework === 'VPAID') {
|
4376 | vpaidAdUnit.setAdVolume(preMuteVolume);
|
4377 | } else {
|
4378 | _this.container.unmute();
|
4379 | }
|
4380 | }, _this.ref = function (container) {
|
4381 | _this.container = container;
|
4382 | }, _this.onAdClick = function () {
|
4383 | var _this$state3 = _this.state,
|
4384 | framework = _this$state3.framework,
|
4385 | tracker = _this$state3.tracker;
|
4386 |
|
4387 | if (framework === 'VAST' && tracker) {
|
4388 | tracker.click();
|
4389 | }
|
4390 | }, _this.onEnded = function (event) {
|
4391 | var onEnded = _this.props.onEnded;
|
4392 | var _this$state4 = _this.state,
|
4393 | framework = _this$state4.framework,
|
4394 | tracker = _this$state4.tracker;
|
4395 |
|
4396 | if (framework === 'VAST' && tracker) {
|
4397 | tracker.complete();
|
4398 | }
|
4399 | onEnded(event);
|
4400 | }, _this.onError = function (event) {
|
4401 | var onError = _this.props.onError;
|
4402 | var _this$state5 = _this.state,
|
4403 | framework = _this$state5.framework,
|
4404 | tracker = _this$state5.tracker;
|
4405 |
|
4406 | if (framework === 'VAST' && tracker) {
|
4407 | tracker.errorWithCode(405);
|
4408 | }
|
4409 | onError(event);
|
4410 | }, _this.onPause = function (event) {
|
4411 | var onPause = _this.props.onPause;
|
4412 | var _this$state6 = _this.state,
|
4413 | framework = _this$state6.framework,
|
4414 | tracker = _this$state6.tracker;
|
4415 |
|
4416 | if (framework === 'VAST' && tracker) {
|
4417 | tracker.setPaused(true);
|
4418 | }
|
4419 | onPause(event);
|
4420 | }, _this.onPlay = function (event) {
|
4421 | var onPlay = _this.props.onPlay;
|
4422 | var _this$state7 = _this.state,
|
4423 | framework = _this$state7.framework,
|
4424 | tracker = _this$state7.tracker;
|
4425 |
|
4426 | if (framework === 'VAST' && tracker) {
|
4427 | tracker.setPaused(false);
|
4428 | }
|
4429 | onPlay(event);
|
4430 | }, _this.onProgress = function (event) {
|
4431 | var onProgress = _this.props.onProgress;
|
4432 | var _this$state8 = _this.state,
|
4433 | framework = _this$state8.framework,
|
4434 | tracker = _this$state8.tracker;
|
4435 |
|
4436 | if (framework === 'VAST' && tracker) {
|
4437 | tracker.setProgress(event.playedSeconds);
|
4438 | }
|
4439 | onProgress(event);
|
4440 | }, _this.onReady = function (event) {
|
4441 | var onReady = _this.props.onReady;
|
4442 | var _this$state9 = _this.state,
|
4443 | framework = _this$state9.framework,
|
4444 | tracker = _this$state9.tracker;
|
4445 |
|
4446 | if (framework === 'VAST' && tracker) {
|
4447 | if (Number.isNaN(tracker.assetDuration)) {
|
4448 | tracker.assetDuration = _this.container.getDuration();
|
4449 | }
|
4450 | }
|
4451 |
|
4452 | onReady(event);
|
4453 | }, _this.onVolumeChange = function (event) {
|
4454 | var onVolumeChange = _this.props.onVolumeChange;
|
4455 | var _this$state10 = _this.state,
|
4456 | framework = _this$state10.framework,
|
4457 | tracker = _this$state10.tracker;
|
4458 |
|
4459 | if (framework === 'VAST' && tracker) {
|
4460 | tracker.setMuted(_this.container.muted);
|
4461 | }
|
4462 | onVolumeChange(event);
|
4463 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
4464 | }
|
4465 |
|
4466 | _createClass(VAST, [{
|
4467 | key: 'createSourceFiles',
|
4468 | value: function createSourceFiles() {
|
4469 | var mediaFiles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
4470 |
|
4471 | return mediaFiles.map(function () {
|
4472 | var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
4473 | apiFramework = _ref2.apiFramework,
|
4474 | src = _ref2.fileURL,
|
4475 | type = _ref2.mimeType;
|
4476 |
|
4477 | return { apiFramework: apiFramework, src: src, type: type };
|
4478 | }).filter(function (_ref3) {
|
4479 | var apiFramework = _ref3.apiFramework,
|
4480 | src = _ref3.src;
|
4481 | return apiFramework === 'VPAID' || _FilePlayer.FilePlayer.canPlay(src);
|
4482 | });
|
4483 | }
|
4484 | }, {
|
4485 | key: 'componentWillUnmount',
|
4486 | value: function componentWillUnmount() {
|
4487 | if (this.state.framework === 'VPAID') {
|
4488 | this.removeVPAIDListeners();
|
4489 | }
|
4490 | }
|
4491 | }, {
|
4492 | key: 'parseResponse',
|
4493 | value: function parseResponse(response) {
|
4494 | var onEnded = this.props.onEnded;
|
4495 | var _response$ads = response.ads,
|
4496 | ads = _response$ads === undefined ? [] : _response$ads;
|
4497 |
|
4498 |
|
4499 |
|
4500 |
|
4501 | var _iteratorNormalCompletion = true;
|
4502 | var _didIteratorError = false;
|
4503 | var _iteratorError = undefined;
|
4504 |
|
4505 | try {
|
4506 | for (var _iterator = ads[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
4507 | var ad = _step.value;
|
4508 | var _ad$creatives = ad.creatives,
|
4509 | creatives = _ad$creatives === undefined ? [] : _ad$creatives;
|
4510 | var _iteratorNormalCompletion2 = true;
|
4511 | var _didIteratorError2 = false;
|
4512 | var _iteratorError2 = undefined;
|
4513 |
|
4514 | try {
|
4515 | for (var _iterator2 = creatives[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
4516 | var creative = _step2.value;
|
4517 | var _creative$mediaFiles = creative.mediaFiles,
|
4518 | mediaFiles = _creative$mediaFiles === undefined ? [] : _creative$mediaFiles,
|
4519 | type = creative.type;
|
4520 |
|
4521 | if (type === 'linear') {
|
4522 | var sources = this.createSourceFiles(mediaFiles);
|
4523 | if (sources.length) {
|
4524 | return this.setState({
|
4525 | framework: sources[0].apiFramework || 'VAST',
|
4526 | sources: sources,
|
4527 |
|
4528 | tracker: new _vastClient.VASTTracker(this.state.vastClient, ad, creative)
|
4529 | });
|
4530 | }
|
4531 | }
|
4532 | }
|
4533 | } catch (err) {
|
4534 | _didIteratorError2 = true;
|
4535 | _iteratorError2 = err;
|
4536 | } finally {
|
4537 | try {
|
4538 | if (!_iteratorNormalCompletion2 && _iterator2['return']) {
|
4539 | _iterator2['return']();
|
4540 | }
|
4541 | } finally {
|
4542 | if (_didIteratorError2) {
|
4543 | throw _iteratorError2;
|
4544 | }
|
4545 | }
|
4546 | }
|
4547 |
|
4548 | return onEnded();
|
4549 | }
|
4550 | } catch (err) {
|
4551 | _didIteratorError = true;
|
4552 | _iteratorError = err;
|
4553 | } finally {
|
4554 | try {
|
4555 | if (!_iteratorNormalCompletion && _iterator['return']) {
|
4556 | _iterator['return']();
|
4557 | }
|
4558 | } finally {
|
4559 | if (_didIteratorError) {
|
4560 | throw _iteratorError;
|
4561 | }
|
4562 | }
|
4563 | }
|
4564 | }
|
4565 | }, {
|
4566 | key: 'addVPAIDListeners',
|
4567 | value: function addVPAIDListeners() {
|
4568 | var framework = this.state.framework;
|
4569 |
|
4570 | if (framework !== 'VPAID') {
|
4571 | return null;
|
4572 | }
|
4573 | var _props = this.props,
|
4574 | onReady = _props.onReady,
|
4575 | onPlay = _props.onPlay,
|
4576 | onBuffer = _props.onBuffer,
|
4577 | onBufferEnd = _props.onBufferEnd,
|
4578 | onPause = _props.onPause,
|
4579 | onEnded = _props.onEnded,
|
4580 | onError = _props.onError,
|
4581 | onVolumeChange = _props.onVolumeChange;
|
4582 |
|
4583 |
|
4584 | this.container.addEventListener('canplay', onReady);
|
4585 | this.container.addEventListener('play', onPlay);
|
4586 | this.container.addEventListener('waiting', onBuffer);
|
4587 | this.container.addEventListener('playing', onBufferEnd);
|
4588 | this.container.addEventListener('pause', onPause);
|
4589 | this.container.addEventListener('ended', onEnded);
|
4590 | this.container.addEventListener('error', onError);
|
4591 | this.container.addEventListener('volumeChange', onVolumeChange);
|
4592 |
|
4593 |
|
4594 | this.state.vpaidAdUnit.subscribe('AdLoaded', this.onVPAIDAdLoaded.bind(this));
|
4595 | this.state.vpaidAdUnit.subscribe('AdSkippableStateChange', this.props.onAdSkippable.bind(this));
|
4596 | }
|
4597 | }, {
|
4598 | key: 'skip',
|
4599 | value: function skip() {
|
4600 | var _state = this.state,
|
4601 | framework = _state.framework,
|
4602 | tracker = _state.tracker,
|
4603 | vpaidAdUnit = _state.vpaidAdUnit;
|
4604 |
|
4605 | if (framework === 'VAST' && tracker) {
|
4606 | tracker.skip();
|
4607 | } else {
|
4608 | vpaidAdUnit.skipAd();
|
4609 | }
|
4610 | }
|
4611 | }, {
|
4612 | key: 'onVPAIDAdLoaded',
|
4613 | value: function onVPAIDAdLoaded() {
|
4614 | var _props2 = this.props,
|
4615 | onReady = _props2.onReady,
|
4616 | playing = _props2.playing;
|
4617 | var vpaidAdUnit = this.state.vpaidAdUnit;
|
4618 |
|
4619 | onReady();
|
4620 | if (playing) {
|
4621 | vpaidAdUnit.startAd();
|
4622 | this.setVolume(0.0);
|
4623 | }
|
4624 | }
|
4625 | }, {
|
4626 | key: 'removeVPAIDListeners',
|
4627 | value: function removeVPAIDListeners() {
|
4628 | var _props3 = this.props,
|
4629 | onReady = _props3.onReady,
|
4630 | onPlay = _props3.onPlay,
|
4631 | onBuffer = _props3.onBuffer,
|
4632 | onBufferEnd = _props3.onBufferEnd,
|
4633 | onPause = _props3.onPause,
|
4634 | onEnded = _props3.onEnded,
|
4635 | onError = _props3.onError,
|
4636 | onVolumeChange = _props3.onVolumeChange;
|
4637 |
|
4638 | this.container.removeEventListener('canplay', onReady);
|
4639 | this.container.removeEventListener('play', onPlay);
|
4640 | this.container.removeEventListener('waiting', onBuffer);
|
4641 | this.container.removeEventListener('playing', onBufferEnd);
|
4642 | this.container.removeEventListener('pause', onPause);
|
4643 | this.container.removeEventListener('ended', onEnded);
|
4644 | this.container.removeEventListener('error', onError);
|
4645 | this.container.removeEventListener('volumeChange', onVolumeChange);
|
4646 | this.state.vpaidAdUnit.unsubscribe('AdLoaded');
|
4647 | this.state.vpaidAdUnit.unsubscribe('AdSkippableStateChange');
|
4648 | }
|
4649 | }, {
|
4650 | key: 'loadVPAID',
|
4651 | value: function loadVPAID(url) {
|
4652 | var _this2 = this;
|
4653 |
|
4654 | this.state.vpaidClient = new _vpaidHtml5Client2['default'](document.getElementById(this.contentID), document.getElementById(this.playerID));
|
4655 | var onError = this.props.onError;
|
4656 | var vpaidClient = this.state.vpaidClient;
|
4657 |
|
4658 | vpaidClient.loadAdUnit(url, function (error, adUnit) {
|
4659 | if (error) {
|
4660 | return onError(error);
|
4661 | }
|
4662 | _this2.state.vpaidAdUnit = adUnit;
|
4663 | _this2.addVPAIDListeners();
|
4664 | adUnit.initAd('100%', '100%', 'normal', -1, {}, {});
|
4665 | });
|
4666 | }
|
4667 | }, {
|
4668 | key: 'load',
|
4669 | value: function load(rawUrl) {
|
4670 | var _this3 = this;
|
4671 |
|
4672 |
|
4673 | var ord = Math.random() * 10000000000000000;
|
4674 | var url = rawUrl.replace(/\[random]/ig, ord);
|
4675 | this.state.vastClient.get(url.slice('VAST:'.length), { withCredentials: true }).then(function (response) {
|
4676 | _this3.parseResponse(response);
|
4677 | var _state2 = _this3.state,
|
4678 | framework = _state2.framework,
|
4679 | sources = _state2.sources,
|
4680 | tracker = _state2.tracker;
|
4681 |
|
4682 | if (framework === 'VPAID') {
|
4683 | _this3.loadVPAID(sources[0].src);
|
4684 | } else {
|
4685 | if (tracker) {
|
4686 | tracker.on('clickthrough', _this3.openAdLink);
|
4687 | }
|
4688 | }
|
4689 | })['catch'](function (error) {
|
4690 | return _this3.props.onError(error);
|
4691 | });
|
4692 | }
|
4693 | }, {
|
4694 | key: 'play',
|
4695 | value: function play() {
|
4696 | var _state3 = this.state,
|
4697 | framework = _state3.framework,
|
4698 | vpaidAdUnit = _state3.vpaidAdUnit;
|
4699 |
|
4700 | if (framework === 'VPAID') {
|
4701 | vpaidAdUnit.resumeAd();
|
4702 | } else {
|
4703 | this.container.play();
|
4704 | }
|
4705 | }
|
4706 | }, {
|
4707 | key: 'pause',
|
4708 | value: function pause() {
|
4709 | var _state4 = this.state,
|
4710 | framework = _state4.framework,
|
4711 | vpaidAdUnit = _state4.vpaidAdUnit;
|
4712 |
|
4713 | if (framework === 'VPAID') {
|
4714 | vpaidAdUnit.pauseAd();
|
4715 | } else {
|
4716 | this.container.pause();
|
4717 | }
|
4718 | }
|
4719 | }, {
|
4720 | key: 'stop',
|
4721 | value: function stop() {
|
4722 | var _state5 = this.state,
|
4723 | framework = _state5.framework,
|
4724 | vpaidAdUnit = _state5.vpaidAdUnit;
|
4725 |
|
4726 | if (framework === 'VPAID') {
|
4727 | vpaidAdUnit.stopAd();
|
4728 | } else {
|
4729 | this.container.stop();
|
4730 | }
|
4731 | }
|
4732 |
|
4733 |
|
4734 |
|
4735 | }, {
|
4736 | key: 'seekTo',
|
4737 | value: function seekTo(seconds) {
|
4738 | var framework = this.state.framework;
|
4739 |
|
4740 | if (framework === 'VAST') {
|
4741 | if (seconds < this.getCurrentTime()) {
|
4742 | this.container.seekTo(seconds);
|
4743 | }
|
4744 | }
|
4745 | }
|
4746 | }, {
|
4747 | key: 'setVolume',
|
4748 | value: function setVolume(fraction) {
|
4749 | var _state6 = this.state,
|
4750 | framework = _state6.framework,
|
4751 | vpaidAdUnit = _state6.vpaidAdUnit;
|
4752 |
|
4753 | if (framework === 'VPAID') {
|
4754 | vpaidAdUnit.setAdVolume(fraction);
|
4755 | } else {
|
4756 | this.container.setVolume(fraction);
|
4757 | }
|
4758 | }
|
4759 | }, {
|
4760 | key: 'getDuration',
|
4761 | value: function getDuration() {
|
4762 | var framework = this.state.framework;
|
4763 |
|
4764 | if (framework === 'VPAID') {
|
4765 | if (!this.container) return null;
|
4766 | var duration = this.container.duration;
|
4767 |
|
4768 | return duration;
|
4769 | } else {
|
4770 | return this.container.getDuration();
|
4771 | }
|
4772 | }
|
4773 | }, {
|
4774 | key: 'getCurrentTime',
|
4775 | value: function getCurrentTime() {
|
4776 | var framework = this.state.framework;
|
4777 |
|
4778 | if (framework === 'VPAID') {
|
4779 | return this.container ? this.container.currentTime : null;
|
4780 | } else {
|
4781 | return this.container.getCurrentTime();
|
4782 | }
|
4783 | }
|
4784 | }, {
|
4785 | key: 'getSecondsLoaded',
|
4786 | value: function getSecondsLoaded() {
|
4787 | var framework = this.state.framework;
|
4788 |
|
4789 | if (framework === 'VPAID') {
|
4790 | if (!this.container) return null;
|
4791 | var buffered = this.container.buffered;
|
4792 |
|
4793 | if (buffered.length === 0) {
|
4794 | return 0;
|
4795 | }
|
4796 | var end = buffered.end(buffered.length - 1);
|
4797 | var duration = this.getDuration();
|
4798 | if (end > duration) {
|
4799 | return duration;
|
4800 | }
|
4801 | return end;
|
4802 | } else {
|
4803 | return this.container.getCurrentTime();
|
4804 | }
|
4805 | }
|
4806 | }, {
|
4807 | key: 'openAdLink',
|
4808 | value: function openAdLink(url) {
|
4809 | window.open(url, '_blank');
|
4810 | }
|
4811 |
|
4812 |
|
4813 |
|
4814 |
|
4815 |
|
4816 |
|
4817 |
|
4818 |
|
4819 |
|
4820 |
|
4821 |
|
4822 |
|
4823 |
|
4824 |
|
4825 |
|
4826 |
|
4827 |
|
4828 |
|
4829 | }, {
|
4830 | key: 'renderVAST',
|
4831 | value: function renderVAST() {
|
4832 | var _state7 = this.state,
|
4833 | sources = _state7.sources,
|
4834 | clickTrackingURLTemplate = _state7.tracker;
|
4835 | var _props4 = this.props,
|
4836 | width = _props4.width,
|
4837 | height = _props4.height;
|
4838 |
|
4839 | var wrapperStyle = {
|
4840 | cursor: clickTrackingURLTemplate ? 'pointer' : 'default',
|
4841 | height: '100%'
|
4842 | };
|
4843 | var videoStyle = {
|
4844 | width: width === 'auto' ? width : '100%',
|
4845 | height: height === 'auto' ? height : '100%'
|
4846 | };
|
4847 | return sources.length ? _react2['default'].createElement(
|
4848 | 'div',
|
4849 | { onClick: this.onAdClick, style: wrapperStyle },
|
4850 | _react2['default'].createElement(_FilePlayer.FilePlayer, _extends({}, this.props, {
|
4851 | onEnded: this.onEnded,
|
4852 | onError: this.onError,
|
4853 | onPause: this.onPause,
|
4854 | onPlay: this.onPlay,
|
4855 | onProgress: this.onProgress,
|
4856 | onReady: this.onReady,
|
4857 | onVolumeChange: this.onVolumeChange,
|
4858 | ref: this.ref,
|
4859 | style: videoStyle,
|
4860 | url: this.state.sources[0].src
|
4861 | }))
|
4862 | ) : null;
|
4863 | }
|
4864 | }, {
|
4865 | key: 'renderVPAID',
|
4866 | value: function renderVPAID() {
|
4867 | var _this4 = this;
|
4868 |
|
4869 | var _props5 = this.props,
|
4870 | width = _props5.width,
|
4871 | height = _props5.height;
|
4872 | var canSkip = this.state.canSkip;
|
4873 |
|
4874 | var dimensions = {
|
4875 | width: width === 'auto' ? width : '100%',
|
4876 | height: height === 'auto' ? height : '100%'
|
4877 | };
|
4878 | var contentStyle = _extends({}, dimensions, {
|
4879 | top: 0,
|
4880 | left: 0,
|
4881 | position: 'absolute',
|
4882 | zIndex: 1
|
4883 | });
|
4884 | var skipStyle = {
|
4885 | cursor: 'pointer',
|
4886 | display: 'block',
|
4887 | position: 'absolute',
|
4888 | bottom: '10px',
|
4889 | right: '10px',
|
4890 | zIndex: 2
|
4891 | };
|
4892 | return _react2['default'].createElement(
|
4893 | 'div',
|
4894 | { style: _extends({}, dimensions, { position: 'relative' }) },
|
4895 | canSkip && _react2['default'].createElement(
|
4896 | 'button',
|
4897 | {
|
4898 | id: this.skipID,
|
4899 | style: skipStyle,
|
4900 | onClick: function onClick() {
|
4901 | return _this4.skip();
|
4902 | } },
|
4903 | 'Skip'
|
4904 | ),
|
4905 | _react2['default'].createElement('div', { id: this.contentID, style: contentStyle }),
|
4906 | _react2['default'].createElement('video', {
|
4907 | ref: this.ref,
|
4908 | controls: false,
|
4909 | style: dimensions,
|
4910 | id: this.playerID
|
4911 | })
|
4912 | );
|
4913 | }
|
4914 | }, {
|
4915 | key: 'render',
|
4916 | value: function render() {
|
4917 | var framework = this.state.framework;
|
4918 |
|
4919 | if (!framework) {
|
4920 | return null;
|
4921 | }
|
4922 | if (framework === 'VPAID') {
|
4923 | return this.renderVPAID();
|
4924 | } else {
|
4925 | return this.renderVAST();
|
4926 | }
|
4927 | }
|
4928 | }]);
|
4929 |
|
4930 | return VAST;
|
4931 | }(_react.Component);
|
4932 |
|
4933 | VAST.displayName = 'VAST';
|
4934 |
|
4935 | VAST.canPlay = function (url) {
|
4936 | return MATCH_URL.test(url);
|
4937 | };
|
4938 |
|
4939 | exports['default'] = (0, _singlePlayer2['default'])(VAST);
|
4940 |
|
4941 | }),
|
4942 |
|
4943 | (function(module, exports, __webpack_require__) {
|
4944 |
|
4945 | "use strict";
|
4946 |
|
4947 |
|
4948 |
|
4949 |
|
4950 |
|
4951 |
|
4952 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
4953 |
|
4954 | function noop() {}
|
4955 |
|
4956 |
|
4957 |
|
4958 |
|
4959 |
|
4960 |
|
4961 |
|
4962 | function validate(isValid, message) {
|
4963 | return isValid ? null : new Error(message);
|
4964 | }
|
4965 |
|
4966 | var timeouts = {};
|
4967 |
|
4968 |
|
4969 |
|
4970 |
|
4971 |
|
4972 | function clearCallbackTimeout(func) {
|
4973 | var timeout = timeouts[func];
|
4974 | if (timeout) {
|
4975 | clearTimeout(timeout);
|
4976 | delete timeouts[func];
|
4977 | }
|
4978 | }
|
4979 |
|
4980 |
|
4981 |
|
4982 |
|
4983 |
|
4984 |
|
4985 |
|
4986 |
|
4987 | function callbackTimeout(timer, onSuccess, onTimeout) {
|
4988 | var _callback, timeout;
|
4989 |
|
4990 | timeout = setTimeout(function () {
|
4991 | onSuccess = noop;
|
4992 | delete timeout[_callback];
|
4993 | onTimeout();
|
4994 | }, timer);
|
4995 |
|
4996 | _callback = function callback() {
|
4997 |
|
4998 |
|
4999 | if (onSuccess.apply(this, arguments)) {
|
5000 | clearCallbackTimeout(_callback);
|
5001 | }
|
5002 | };
|
5003 |
|
5004 | timeouts[_callback] = timeout;
|
5005 |
|
5006 | return _callback;
|
5007 | }
|
5008 |
|
5009 |
|
5010 |
|
5011 |
|
5012 |
|
5013 |
|
5014 |
|
5015 |
|
5016 | function createElementInEl(parent, tagName, id) {
|
5017 | var nEl = document.createElement(tagName);
|
5018 | if (id) nEl.id = id;
|
5019 | parent.appendChild(nEl);
|
5020 | return nEl;
|
5021 | }
|
5022 |
|
5023 |
|
5024 |
|
5025 |
|
5026 |
|
5027 |
|
5028 |
|
5029 |
|
5030 | function createIframeWithContent(parent, template, data) {
|
5031 | var iframe = createIframe(parent, null, data.zIndex);
|
5032 | if (!setIframeContent(iframe, simpleTemplate(template, data))) return;
|
5033 | return iframe;
|
5034 | }
|
5035 |
|
5036 |
|
5037 |
|
5038 |
|
5039 |
|
5040 |
|
5041 |
|
5042 | function createIframe(parent, url, zIndex) {
|
5043 | var nEl = document.createElement('iframe');
|
5044 | nEl.src = url || 'about:blank';
|
5045 | nEl.marginWidth = '0';
|
5046 | nEl.marginHeight = '0';
|
5047 | nEl.frameBorder = '0';
|
5048 | nEl.width = '100%';
|
5049 | nEl.height = '100%';
|
5050 | setFullSizeStyle(nEl);
|
5051 |
|
5052 | if (zIndex) {
|
5053 | nEl.style.zIndex = zIndex;
|
5054 | }
|
5055 |
|
5056 | nEl.setAttribute('SCROLLING', 'NO');
|
5057 | parent.innerHTML = '';
|
5058 | parent.appendChild(nEl);
|
5059 | return nEl;
|
5060 | }
|
5061 |
|
5062 | function setFullSizeStyle(element) {
|
5063 | element.style.position = 'absolute';
|
5064 | element.style.left = '0';
|
5065 | element.style.top = '0';
|
5066 | element.style.margin = '0px';
|
5067 | element.style.padding = '0px';
|
5068 | element.style.border = 'none';
|
5069 | element.style.width = '100%';
|
5070 | element.style.height = '100%';
|
5071 | }
|
5072 |
|
5073 |
|
5074 |
|
5075 |
|
5076 |
|
5077 |
|
5078 |
|
5079 | function simpleTemplate(template, data) {
|
5080 | Object.keys(data).forEach(function (key) {
|
5081 | var value = (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' ? JSON.stringify(data[key]) : data[key];
|
5082 | template = template.replace(new RegExp('{{' + key + '}}', 'g'), value);
|
5083 | });
|
5084 | return template;
|
5085 | }
|
5086 |
|
5087 |
|
5088 |
|
5089 |
|
5090 |
|
5091 |
|
5092 |
|
5093 | function setIframeContent(iframeEl, content) {
|
5094 | var iframeDoc = iframeEl.contentWindow && iframeEl.contentWindow.document;
|
5095 | if (!iframeDoc) return false;
|
5096 |
|
5097 | iframeDoc.write(content);
|
5098 |
|
5099 | return true;
|
5100 | }
|
5101 |
|
5102 |
|
5103 |
|
5104 |
|
5105 |
|
5106 |
|
5107 |
|
5108 | function extend(toExtend, fromSource) {
|
5109 | Object.keys(fromSource).forEach(function (key) {
|
5110 | toExtend[key] = fromSource[key];
|
5111 | });
|
5112 | return toExtend;
|
5113 | }
|
5114 |
|
5115 |
|
5116 |
|
5117 |
|
5118 |
|
5119 |
|
5120 | function unique(prefix) {
|
5121 | var count = -1;
|
5122 | return function () {
|
5123 | return prefix + '_' + ++count;
|
5124 | };
|
5125 | }
|
5126 |
|
5127 | module.exports = {
|
5128 | noop: noop,
|
5129 | validate: validate,
|
5130 | clearCallbackTimeout: clearCallbackTimeout,
|
5131 | callbackTimeout: callbackTimeout,
|
5132 | createElementInEl: createElementInEl,
|
5133 | createIframeWithContent: createIframeWithContent,
|
5134 | createIframe: createIframe,
|
5135 | setFullSizeStyle: setFullSizeStyle,
|
5136 | simpleTemplate: simpleTemplate,
|
5137 | setIframeContent: setIframeContent,
|
5138 | extend: extend,
|
5139 | unique: unique
|
5140 | };
|
5141 |
|
5142 | }),
|
5143 |
|
5144 | (function(module, exports, __webpack_require__) {
|
5145 |
|
5146 | "use strict";
|
5147 |
|
5148 |
|
5149 | Object.defineProperty(exports, "__esModule", {
|
5150 | value: true
|
5151 | });
|
5152 | exports.VASTParser = undefined;
|
5153 |
|
5154 | 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; }; }();
|
5155 |
|
5156 | var _ad_parser = __webpack_require__(44);
|
5157 |
|
5158 | var _events = __webpack_require__(28);
|
5159 |
|
5160 | var _parser_utils = __webpack_require__(3);
|
5161 |
|
5162 | var _url_handler = __webpack_require__(55);
|
5163 |
|
5164 | var _util = __webpack_require__(12);
|
5165 |
|
5166 | var _vast_response = __webpack_require__(59);
|
5167 |
|
5168 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5169 |
|
5170 | 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; }
|
5171 |
|
5172 | 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; }
|
5173 |
|
5174 | var DEFAULT_MAX_WRAPPER_DEPTH = 10;
|
5175 | var DEFAULT_EVENT_DATA = {
|
5176 | ERRORCODE: 900,
|
5177 | extensions: []
|
5178 | };
|
5179 |
|
5180 |
|
5181 |
|
5182 |
|
5183 |
|
5184 |
|
5185 |
|
5186 |
|
5187 | var VASTParser = exports.VASTParser = function (_EventEmitter) {
|
5188 | _inherits(VASTParser, _EventEmitter);
|
5189 |
|
5190 | |
5191 |
|
5192 |
|
5193 |
|
5194 | function VASTParser() {
|
5195 | _classCallCheck(this, VASTParser);
|
5196 |
|
5197 | var _this = _possibleConstructorReturn(this, (VASTParser.__proto__ || Object.getPrototypeOf(VASTParser)).call(this));
|
5198 |
|
5199 | _this.remainingAds = [];
|
5200 | _this.parentURLs = [];
|
5201 | _this.errorURLTemplates = [];
|
5202 | _this.rootErrorURLTemplates = [];
|
5203 | _this.maxWrapperDepth = null;
|
5204 | _this.URLTemplateFilters = [];
|
5205 | _this.fetchingOptions = {};
|
5206 | return _this;
|
5207 | }
|
5208 |
|
5209 | |
5210 |
|
5211 |
|
5212 |
|
5213 |
|
5214 |
|
5215 |
|
5216 | _createClass(VASTParser, [{
|
5217 | key: 'addURLTemplateFilter',
|
5218 | value: function addURLTemplateFilter(filter) {
|
5219 | if (typeof filter === 'function') {
|
5220 | this.URLTemplateFilters.push(filter);
|
5221 | }
|
5222 | }
|
5223 |
|
5224 | |
5225 |
|
5226 |
|
5227 |
|
5228 |
|
5229 | }, {
|
5230 | key: 'removeURLTemplateFilter',
|
5231 | value: function removeURLTemplateFilter() {
|
5232 | this.URLTemplateFilters.pop();
|
5233 | }
|
5234 |
|
5235 | |
5236 |
|
5237 |
|
5238 |
|
5239 |
|
5240 | }, {
|
5241 | key: 'countURLTemplateFilters',
|
5242 | value: function countURLTemplateFilters() {
|
5243 | return this.URLTemplateFilters.length;
|
5244 | }
|
5245 |
|
5246 | |
5247 |
|
5248 |
|
5249 |
|
5250 |
|
5251 | }, {
|
5252 | key: 'clearURLTemplateFilters',
|
5253 | value: function clearURLTemplateFilters() {
|
5254 | this.URLTemplateFilters = [];
|
5255 | }
|
5256 |
|
5257 | |
5258 |
|
5259 |
|
5260 |
|
5261 |
|
5262 |
|
5263 |
|
5264 |
|
5265 |
|
5266 | }, {
|
5267 | key: 'trackVastError',
|
5268 | value: function trackVastError(urlTemplates, errorCode) {
|
5269 | for (var _len = arguments.length, data = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
5270 | data[_key - 2] = arguments[_key];
|
5271 | }
|
5272 |
|
5273 | this.emit('VAST-error', Object.assign.apply(Object, [DEFAULT_EVENT_DATA, errorCode].concat(data)));
|
5274 | _util.util.track(urlTemplates, errorCode);
|
5275 | }
|
5276 |
|
5277 | |
5278 |
|
5279 |
|
5280 |
|
5281 |
|
5282 | }, {
|
5283 | key: 'getErrorURLTemplates',
|
5284 | value: function getErrorURLTemplates() {
|
5285 | return this.rootErrorURLTemplates.concat(this.errorURLTemplates);
|
5286 | }
|
5287 |
|
5288 | |
5289 |
|
5290 |
|
5291 |
|
5292 |
|
5293 |
|
5294 |
|
5295 |
|
5296 |
|
5297 |
|
5298 |
|
5299 | }, {
|
5300 | key: 'fetchVAST',
|
5301 | value: function fetchVAST(url, wrapperDepth, originalUrl) {
|
5302 | var _this2 = this;
|
5303 |
|
5304 | return new Promise(function (resolve, reject) {
|
5305 |
|
5306 | _this2.URLTemplateFilters.forEach(function (filter) {
|
5307 | url = filter(url);
|
5308 | });
|
5309 |
|
5310 | _this2.parentURLs.push(url);
|
5311 | _this2.emit('VAST-resolving', { url: url, wrapperDepth: wrapperDepth, originalUrl: originalUrl });
|
5312 |
|
5313 | _this2.urlHandler.get(url, _this2.fetchingOptions, function (err, xml) {
|
5314 | _this2.emit('VAST-resolved', { url: url, error: err });
|
5315 |
|
5316 | if (err) {
|
5317 | reject(err);
|
5318 | } else {
|
5319 | resolve(xml);
|
5320 | }
|
5321 | });
|
5322 | });
|
5323 | }
|
5324 |
|
5325 | |
5326 |
|
5327 |
|
5328 |
|
5329 |
|
5330 | }, {
|
5331 | key: 'initParsingStatus',
|
5332 | value: function initParsingStatus() {
|
5333 | var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
5334 |
|
5335 | this.rootURL = '';
|
5336 | this.remainingAds = [];
|
5337 | this.parentURLs = [];
|
5338 | this.errorURLTemplates = [];
|
5339 | this.rootErrorURLTemplates = [];
|
5340 | this.maxWrapperDepth = options.wrapperLimit || DEFAULT_MAX_WRAPPER_DEPTH;
|
5341 | this.fetchingOptions = {
|
5342 | timeout: options.timeout,
|
5343 | withCredentials: options.withCredentials
|
5344 | };
|
5345 |
|
5346 | this.urlHandler = options.urlHandler || options.urlhandler || _url_handler.urlHandler;
|
5347 | }
|
5348 |
|
5349 | |
5350 |
|
5351 |
|
5352 |
|
5353 |
|
5354 |
|
5355 | }, {
|
5356 | key: 'getRemainingAds',
|
5357 | value: function getRemainingAds(all) {
|
5358 | var _this3 = this;
|
5359 |
|
5360 | if (this.remainingAds.length === 0) {
|
5361 | return Promise.reject(new Error('No more ads are available for the given VAST'));
|
5362 | }
|
5363 |
|
5364 | var ads = all ? _util.util.flatten(this.remainingAds) : this.remainingAds.shift();
|
5365 | this.errorURLTemplates = [];
|
5366 | this.parentURLs = [];
|
5367 |
|
5368 | return this.resolveAds(ads, {
|
5369 | wrapperDepth: 0,
|
5370 | originalUrl: this.rootURL
|
5371 | }).then(function (resolvedAds) {
|
5372 | return _this3.buildVASTResponse(resolvedAds);
|
5373 | });
|
5374 | }
|
5375 |
|
5376 | |
5377 |
|
5378 |
|
5379 |
|
5380 |
|
5381 |
|
5382 |
|
5383 |
|
5384 |
|
5385 |
|
5386 | }, {
|
5387 | key: 'getAndParseVAST',
|
5388 | value: function getAndParseVAST(url) {
|
5389 | var _this4 = this;
|
5390 |
|
5391 | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
5392 |
|
5393 | this.initParsingStatus(options);
|
5394 | this.rootURL = url;
|
5395 |
|
5396 | return this.fetchVAST(url).then(function (xml) {
|
5397 | options.originalUrl = url;
|
5398 | options.isRootVAST = true;
|
5399 |
|
5400 | return _this4.parse(xml, options).then(function (ads) {
|
5401 | return _this4.buildVASTResponse(ads);
|
5402 | });
|
5403 | });
|
5404 | }
|
5405 |
|
5406 | |
5407 |
|
5408 |
|
5409 |
|
5410 |
|
5411 |
|
5412 |
|
5413 |
|
5414 |
|
5415 |
|
5416 | }, {
|
5417 | key: 'parseVAST',
|
5418 | value: function parseVAST(vastXml) {
|
5419 | var _this5 = this;
|
5420 |
|
5421 | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
5422 |
|
5423 | this.initParsingStatus(options);
|
5424 |
|
5425 | options.isRootVAST = true;
|
5426 |
|
5427 | return this.parse(vastXml, options).then(function (ads) {
|
5428 | return _this5.buildVASTResponse(ads);
|
5429 | });
|
5430 | }
|
5431 |
|
5432 | |
5433 |
|
5434 |
|
5435 |
|
5436 |
|
5437 |
|
5438 | }, {
|
5439 | key: 'buildVASTResponse',
|
5440 | value: function buildVASTResponse(ads) {
|
5441 | var response = new _vast_response.VASTResponse();
|
5442 | response.ads = ads;
|
5443 | response.errorURLTemplates = this.getErrorURLTemplates();
|
5444 | this.completeWrapperResolving(response);
|
5445 |
|
5446 | return response;
|
5447 | }
|
5448 |
|
5449 | |
5450 |
|
5451 |
|
5452 |
|
5453 |
|
5454 |
|
5455 |
|
5456 |
|
5457 |
|
5458 | }, {
|
5459 | key: 'parseVastXml',
|
5460 | value: function parseVastXml(vastXml, _ref) {
|
5461 | var _ref$isRootVAST = _ref.isRootVAST,
|
5462 | isRootVAST = _ref$isRootVAST === undefined ? false : _ref$isRootVAST;
|
5463 |
|
5464 |
|
5465 | if (!vastXml || !vastXml.documentElement || vastXml.documentElement.nodeName !== 'VAST') {
|
5466 | throw new Error('Invalid VAST XMLDocument');
|
5467 | }
|
5468 |
|
5469 | var ads = [];
|
5470 | var childNodes = vastXml.documentElement.childNodes;
|
5471 |
|
5472 |
|
5473 | for (var nodeKey in childNodes) {
|
5474 | var node = childNodes[nodeKey];
|
5475 |
|
5476 | if (node.nodeName === 'Error') {
|
5477 | var errorURLTemplate = _parser_utils.parserUtils.parseNodeText(node);
|
5478 |
|
5479 |
|
5480 | isRootVAST ? this.rootErrorURLTemplates.push(errorURLTemplate) : this.errorURLTemplates.push(errorURLTemplate);
|
5481 | }
|
5482 |
|
5483 | if (node.nodeName === 'Ad') {
|
5484 | var ad = (0, _ad_parser.parseAd)(node);
|
5485 |
|
5486 | if (ad) {
|
5487 | ads.push(ad);
|
5488 | } else {
|
5489 |
|
5490 | this.trackVastError(this.getErrorURLTemplates(), {
|
5491 | ERRORCODE: 101
|
5492 | });
|
5493 | }
|
5494 | }
|
5495 | }
|
5496 |
|
5497 | return ads;
|
5498 | }
|
5499 |
|
5500 | |
5501 |
|
5502 |
|
5503 |
|
5504 |
|
5505 |
|
5506 |
|
5507 |
|
5508 |
|
5509 |
|
5510 | }, {
|
5511 | key: 'parse',
|
5512 | value: function parse(vastXml, _ref2) {
|
5513 | var _ref2$resolveAll = _ref2.resolveAll,
|
5514 | resolveAll = _ref2$resolveAll === undefined ? true : _ref2$resolveAll,
|
5515 | _ref2$wrapperSequence = _ref2.wrapperSequence,
|
5516 | wrapperSequence = _ref2$wrapperSequence === undefined ? null : _ref2$wrapperSequence,
|
5517 | _ref2$originalUrl = _ref2.originalUrl,
|
5518 | originalUrl = _ref2$originalUrl === undefined ? null : _ref2$originalUrl,
|
5519 | _ref2$wrapperDepth = _ref2.wrapperDepth,
|
5520 | wrapperDepth = _ref2$wrapperDepth === undefined ? 0 : _ref2$wrapperDepth,
|
5521 | _ref2$isRootVAST = _ref2.isRootVAST,
|
5522 | isRootVAST = _ref2$isRootVAST === undefined ? false : _ref2$isRootVAST;
|
5523 |
|
5524 | var ads = [];
|
5525 | try {
|
5526 | ads = this.parseVastXml(vastXml, { isRootVAST: isRootVAST });
|
5527 | } catch (e) {
|
5528 | return Promise.reject(e);
|
5529 | }
|
5530 |
|
5531 | var adsCount = ads.length;
|
5532 | var lastAddedAd = ads[adsCount - 1];
|
5533 |
|
5534 |
|
5535 |
|
5536 | if (adsCount === 1 && wrapperSequence !== undefined && wrapperSequence !== null && lastAddedAd && !lastAddedAd.sequence) {
|
5537 | lastAddedAd.sequence = wrapperSequence;
|
5538 | }
|
5539 |
|
5540 |
|
5541 | if (resolveAll === false) {
|
5542 | this.remainingAds = _parser_utils.parserUtils.splitVAST(ads);
|
5543 |
|
5544 | ads = this.remainingAds.shift();
|
5545 | }
|
5546 |
|
5547 | return this.resolveAds(ads, { wrapperDepth: wrapperDepth, originalUrl: originalUrl });
|
5548 | }
|
5549 |
|
5550 | |
5551 |
|
5552 |
|
5553 |
|
5554 |
|
5555 |
|
5556 |
|
5557 |
|
5558 | }, {
|
5559 | key: 'resolveAds',
|
5560 | value: function resolveAds() {
|
5561 | var _this6 = this;
|
5562 |
|
5563 | var ads = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
5564 | var _ref3 = arguments[1];
|
5565 | var wrapperDepth = _ref3.wrapperDepth,
|
5566 | originalUrl = _ref3.originalUrl;
|
5567 |
|
5568 | var resolveWrappersPromises = [];
|
5569 |
|
5570 | ads.forEach(function (ad) {
|
5571 | var resolveWrappersPromise = _this6.resolveWrappers(ad, wrapperDepth, originalUrl);
|
5572 |
|
5573 | resolveWrappersPromises.push(resolveWrappersPromise);
|
5574 | });
|
5575 |
|
5576 | return Promise.all(resolveWrappersPromises).then(function (unwrappedAds) {
|
5577 | var resolvedAds = _util.util.flatten(unwrappedAds);
|
5578 |
|
5579 | if (!resolvedAds && _this6.remainingAds.length > 0) {
|
5580 | var remainingAdsToResolve = _this6.remainingAds.shift();
|
5581 |
|
5582 | return _this6.resolveAds(remainingAdsToResolve, {
|
5583 | wrapperDepth: wrapperDepth,
|
5584 | originalUrl: originalUrl
|
5585 | });
|
5586 | }
|
5587 |
|
5588 | return resolvedAds;
|
5589 | });
|
5590 | }
|
5591 |
|
5592 | |
5593 |
|
5594 |
|
5595 |
|
5596 |
|
5597 |
|
5598 |
|
5599 |
|
5600 |
|
5601 | }, {
|
5602 | key: 'resolveWrappers',
|
5603 | value: function resolveWrappers(ad, wrapperDepth, originalUrl) {
|
5604 | var _this7 = this;
|
5605 |
|
5606 | return new Promise(function (resolve) {
|
5607 |
|
5608 | wrapperDepth++;
|
5609 |
|
5610 | if (!ad.nextWrapperURL) {
|
5611 | delete ad.nextWrapperURL;
|
5612 | return resolve(ad);
|
5613 | }
|
5614 |
|
5615 | if (wrapperDepth >= _this7.maxWrapperDepth || _this7.parentURLs.indexOf(ad.nextWrapperURL) !== -1) {
|
5616 |
|
5617 |
|
5618 | ad.errorCode = 302;
|
5619 | delete ad.nextWrapperURL;
|
5620 | return resolve(ad);
|
5621 | }
|
5622 |
|
5623 |
|
5624 | ad.nextWrapperURL = _parser_utils.parserUtils.resolveVastAdTagURI(ad.nextWrapperURL, originalUrl);
|
5625 |
|
5626 |
|
5627 | var wrapperSequence = ad.sequence;
|
5628 | originalUrl = ad.nextWrapperURL;
|
5629 |
|
5630 | _this7.fetchVAST(ad.nextWrapperURL, wrapperDepth, originalUrl).then(function (xml) {
|
5631 | return _this7.parse(xml, {
|
5632 | originalUrl: originalUrl,
|
5633 | wrapperSequence: wrapperSequence,
|
5634 | wrapperDepth: wrapperDepth
|
5635 | }).then(function (unwrappedAds) {
|
5636 | delete ad.nextWrapperURL;
|
5637 | if (unwrappedAds.length === 0) {
|
5638 |
|
5639 | ad.creatives = [];
|
5640 | return resolve(ad);
|
5641 | }
|
5642 |
|
5643 | unwrappedAds.forEach(function (unwrappedAd) {
|
5644 | if (unwrappedAd) {
|
5645 | _parser_utils.parserUtils.mergeWrapperAdData(unwrappedAd, ad);
|
5646 | }
|
5647 | });
|
5648 |
|
5649 | resolve(unwrappedAds);
|
5650 | });
|
5651 | }).catch(function (err) {
|
5652 |
|
5653 |
|
5654 | ad.errorCode = 301;
|
5655 | ad.errorMessage = err.message;
|
5656 |
|
5657 | resolve(ad);
|
5658 | });
|
5659 | });
|
5660 | }
|
5661 |
|
5662 | |
5663 |
|
5664 |
|
5665 |
|
5666 |
|
5667 | }, {
|
5668 | key: 'completeWrapperResolving',
|
5669 | value: function completeWrapperResolving(vastResponse) {
|
5670 |
|
5671 |
|
5672 |
|
5673 |
|
5674 |
|
5675 | if (vastResponse.ads.length === 0) {
|
5676 | this.trackVastError(vastResponse.errorURLTemplates, { ERRORCODE: 303 });
|
5677 | } else {
|
5678 | for (var index = vastResponse.ads.length - 1; index >= 0; index--) {
|
5679 |
|
5680 |
|
5681 |
|
5682 | var ad = vastResponse.ads[index];
|
5683 | if (ad.errorCode || ad.creatives.length === 0) {
|
5684 | this.trackVastError(ad.errorURLTemplates.concat(vastResponse.errorURLTemplates), { ERRORCODE: ad.errorCode || 303 }, { ERRORMESSAGE: ad.errorMessage || '' }, { extensions: ad.extensions }, { system: ad.system });
|
5685 | vastResponse.ads.splice(index, 1);
|
5686 | }
|
5687 | }
|
5688 | }
|
5689 | }
|
5690 | }]);
|
5691 |
|
5692 | return VASTParser;
|
5693 | }(_events.EventEmitter);
|
5694 |
|
5695 | }),
|
5696 |
|
5697 | (function(module, exports, __webpack_require__) {
|
5698 |
|
5699 | "use strict";
|
5700 |
|
5701 |
|
5702 | Object.defineProperty(exports, "__esModule", {
|
5703 | value: true
|
5704 | });
|
5705 |
|
5706 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5707 |
|
5708 | var CompanionAd = exports.CompanionAd = function CompanionAd() {
|
5709 | _classCallCheck(this, CompanionAd);
|
5710 |
|
5711 | this.id = null;
|
5712 | this.width = 0;
|
5713 | this.height = 0;
|
5714 | this.type = null;
|
5715 | this.staticResource = null;
|
5716 | this.htmlResource = null;
|
5717 | this.iframeResource = null;
|
5718 | this.altText = null;
|
5719 | this.companionClickThroughURLTemplate = null;
|
5720 | this.companionClickTrackingURLTemplates = [];
|
5721 | this.trackingEvents = {};
|
5722 | };
|
5723 |
|
5724 | }),
|
5725 |
|
5726 | (function(module, exports, __webpack_require__) {
|
5727 |
|
5728 | "use strict";
|
5729 |
|
5730 |
|
5731 | Object.defineProperty(exports, "__esModule", {
|
5732 | value: true
|
5733 | });
|
5734 | exports.CreativeLinear = undefined;
|
5735 |
|
5736 | var _creative = __webpack_require__(11);
|
5737 |
|
5738 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5739 |
|
5740 | 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; }
|
5741 |
|
5742 | 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; }
|
5743 |
|
5744 | var CreativeLinear = exports.CreativeLinear = function (_Creative) {
|
5745 | _inherits(CreativeLinear, _Creative);
|
5746 |
|
5747 | function CreativeLinear() {
|
5748 | var creativeAttributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
5749 |
|
5750 | _classCallCheck(this, CreativeLinear);
|
5751 |
|
5752 | var _this = _possibleConstructorReturn(this, (CreativeLinear.__proto__ || Object.getPrototypeOf(CreativeLinear)).call(this, creativeAttributes));
|
5753 |
|
5754 | _this.type = 'linear';
|
5755 | _this.duration = 0;
|
5756 | _this.skipDelay = null;
|
5757 | _this.mediaFiles = [];
|
5758 | _this.videoClickThroughURLTemplate = null;
|
5759 | _this.videoClickTrackingURLTemplates = [];
|
5760 | _this.videoCustomClickURLTemplates = [];
|
5761 | _this.adParameters = null;
|
5762 | _this.icons = [];
|
5763 | return _this;
|
5764 | }
|
5765 |
|
5766 | return CreativeLinear;
|
5767 | }(_creative.Creative);
|
5768 |
|
5769 | }),
|
5770 |
|
5771 | (function(module, exports, __webpack_require__) {
|
5772 |
|
5773 | "use strict";
|
5774 |
|
5775 |
|
5776 | Object.defineProperty(exports, "__esModule", {
|
5777 | value: true
|
5778 | });
|
5779 |
|
5780 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5781 |
|
5782 | var NonLinearAd = exports.NonLinearAd = function NonLinearAd() {
|
5783 | _classCallCheck(this, NonLinearAd);
|
5784 |
|
5785 | this.id = null;
|
5786 | this.width = 0;
|
5787 | this.height = 0;
|
5788 | this.expandedWidth = 0;
|
5789 | this.expandedHeight = 0;
|
5790 | this.scalable = true;
|
5791 | this.maintainAspectRatio = true;
|
5792 | this.minSuggestedDuration = 0;
|
5793 | this.apiFramework = 'static';
|
5794 | this.type = null;
|
5795 | this.staticResource = null;
|
5796 | this.htmlResource = null;
|
5797 | this.iframeResource = null;
|
5798 | this.nonlinearClickThroughURLTemplate = null;
|
5799 | this.nonlinearClickTrackingURLTemplates = [];
|
5800 | this.adParameters = null;
|
5801 | };
|
5802 |
|
5803 | }),
|
5804 |
|
5805 | (function(module, exports, __webpack_require__) {
|
5806 |
|
5807 | "use strict";
|
5808 |
|
5809 |
|
5810 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
5811 |
|
5812 |
|
5813 |
|
5814 |
|
5815 |
|
5816 |
|
5817 |
|
5818 |
|
5819 |
|
5820 |
|
5821 |
|
5822 |
|
5823 |
|
5824 |
|
5825 |
|
5826 |
|
5827 |
|
5828 |
|
5829 |
|
5830 |
|
5831 |
|
5832 |
|
5833 | function EventEmitter() {
|
5834 | this._events = this._events || {};
|
5835 | this._maxListeners = this._maxListeners || undefined;
|
5836 | }
|
5837 | module.exports = EventEmitter;
|
5838 |
|
5839 |
|
5840 | EventEmitter.EventEmitter = EventEmitter;
|
5841 |
|
5842 | EventEmitter.prototype._events = undefined;
|
5843 | EventEmitter.prototype._maxListeners = undefined;
|
5844 |
|
5845 |
|
5846 |
|
5847 | EventEmitter.defaultMaxListeners = 10;
|
5848 |
|
5849 |
|
5850 |
|
5851 | EventEmitter.prototype.setMaxListeners = function (n) {
|
5852 | if (!isNumber(n) || n < 0 || isNaN(n)) throw TypeError('n must be a positive number');
|
5853 | this._maxListeners = n;
|
5854 | return this;
|
5855 | };
|
5856 |
|
5857 | EventEmitter.prototype.emit = function (type) {
|
5858 | var er, handler, len, args, i, listeners;
|
5859 |
|
5860 | if (!this._events) this._events = {};
|
5861 |
|
5862 |
|
5863 | if (type === 'error') {
|
5864 | if (!this._events.error || isObject(this._events.error) && !this._events.error.length) {
|
5865 | er = arguments[1];
|
5866 | if (er instanceof Error) {
|
5867 | throw er;
|
5868 | } else {
|
5869 |
|
5870 | var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
|
5871 | err.context = er;
|
5872 | throw err;
|
5873 | }
|
5874 | }
|
5875 | }
|
5876 |
|
5877 | handler = this._events[type];
|
5878 |
|
5879 | if (isUndefined(handler)) return false;
|
5880 |
|
5881 | if (isFunction(handler)) {
|
5882 | switch (arguments.length) {
|
5883 |
|
5884 | case 1:
|
5885 | handler.call(this);
|
5886 | break;
|
5887 | case 2:
|
5888 | handler.call(this, arguments[1]);
|
5889 | break;
|
5890 | case 3:
|
5891 | handler.call(this, arguments[1], arguments[2]);
|
5892 | break;
|
5893 |
|
5894 | default:
|
5895 | args = Array.prototype.slice.call(arguments, 1);
|
5896 | handler.apply(this, args);
|
5897 | }
|
5898 | } else if (isObject(handler)) {
|
5899 | args = Array.prototype.slice.call(arguments, 1);
|
5900 | listeners = handler.slice();
|
5901 | len = listeners.length;
|
5902 | for (i = 0; i < len; i++) {
|
5903 | listeners[i].apply(this, args);
|
5904 | }
|
5905 | }
|
5906 |
|
5907 | return true;
|
5908 | };
|
5909 |
|
5910 | EventEmitter.prototype.addListener = function (type, listener) {
|
5911 | var m;
|
5912 |
|
5913 | if (!isFunction(listener)) throw TypeError('listener must be a function');
|
5914 |
|
5915 | if (!this._events) this._events = {};
|
5916 |
|
5917 |
|
5918 |
|
5919 | if (this._events.newListener) this.emit('newListener', type, isFunction(listener.listener) ? listener.listener : listener);
|
5920 |
|
5921 | if (!this._events[type])
|
5922 |
|
5923 | this._events[type] = listener;else if (isObject(this._events[type]))
|
5924 |
|
5925 | this._events[type].push(listener);else
|
5926 |
|
5927 | this._events[type] = [this._events[type], listener];
|
5928 |
|
5929 |
|
5930 | if (isObject(this._events[type]) && !this._events[type].warned) {
|
5931 | if (!isUndefined(this._maxListeners)) {
|
5932 | m = this._maxListeners;
|
5933 | } else {
|
5934 | m = EventEmitter.defaultMaxListeners;
|
5935 | }
|
5936 |
|
5937 | if (m && m > 0 && this._events[type].length > m) {
|
5938 | this._events[type].warned = true;
|
5939 | console.error('(node) warning: possible EventEmitter memory ' + 'leak detected. %d listeners added. ' + 'Use emitter.setMaxListeners() to increase limit.', this._events[type].length);
|
5940 | if (typeof console.trace === 'function') {
|
5941 |
|
5942 | console.trace();
|
5943 | }
|
5944 | }
|
5945 | }
|
5946 |
|
5947 | return this;
|
5948 | };
|
5949 |
|
5950 | EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
5951 |
|
5952 | EventEmitter.prototype.once = function (type, listener) {
|
5953 | if (!isFunction(listener)) throw TypeError('listener must be a function');
|
5954 |
|
5955 | var fired = false;
|
5956 |
|
5957 | function g() {
|
5958 | this.removeListener(type, g);
|
5959 |
|
5960 | if (!fired) {
|
5961 | fired = true;
|
5962 | listener.apply(this, arguments);
|
5963 | }
|
5964 | }
|
5965 |
|
5966 | g.listener = listener;
|
5967 | this.on(type, g);
|
5968 |
|
5969 | return this;
|
5970 | };
|
5971 |
|
5972 |
|
5973 | EventEmitter.prototype.removeListener = function (type, listener) {
|
5974 | var list, position, length, i;
|
5975 |
|
5976 | if (!isFunction(listener)) throw TypeError('listener must be a function');
|
5977 |
|
5978 | if (!this._events || !this._events[type]) return this;
|
5979 |
|
5980 | list = this._events[type];
|
5981 | length = list.length;
|
5982 | position = -1;
|
5983 |
|
5984 | if (list === listener || isFunction(list.listener) && list.listener === listener) {
|
5985 | delete this._events[type];
|
5986 | if (this._events.removeListener) this.emit('removeListener', type, listener);
|
5987 | } else if (isObject(list)) {
|
5988 | for (i = length; i-- > 0;) {
|
5989 | if (list[i] === listener || list[i].listener && list[i].listener === listener) {
|
5990 | position = i;
|
5991 | break;
|
5992 | }
|
5993 | }
|
5994 |
|
5995 | if (position < 0) return this;
|
5996 |
|
5997 | if (list.length === 1) {
|
5998 | list.length = 0;
|
5999 | delete this._events[type];
|
6000 | } else {
|
6001 | list.splice(position, 1);
|
6002 | }
|
6003 |
|
6004 | if (this._events.removeListener) this.emit('removeListener', type, listener);
|
6005 | }
|
6006 |
|
6007 | return this;
|
6008 | };
|
6009 |
|
6010 | EventEmitter.prototype.removeAllListeners = function (type) {
|
6011 | var key, listeners;
|
6012 |
|
6013 | if (!this._events) return this;
|
6014 |
|
6015 |
|
6016 | if (!this._events.removeListener) {
|
6017 | if (arguments.length === 0) this._events = {};else if (this._events[type]) delete this._events[type];
|
6018 | return this;
|
6019 | }
|
6020 |
|
6021 |
|
6022 | if (arguments.length === 0) {
|
6023 | for (key in this._events) {
|
6024 | if (key === 'removeListener') continue;
|
6025 | this.removeAllListeners(key);
|
6026 | }
|
6027 | this.removeAllListeners('removeListener');
|
6028 | this._events = {};
|
6029 | return this;
|
6030 | }
|
6031 |
|
6032 | listeners = this._events[type];
|
6033 |
|
6034 | if (isFunction(listeners)) {
|
6035 | this.removeListener(type, listeners);
|
6036 | } else if (listeners) {
|
6037 |
|
6038 | while (listeners.length) {
|
6039 | this.removeListener(type, listeners[listeners.length - 1]);
|
6040 | }
|
6041 | }
|
6042 | delete this._events[type];
|
6043 |
|
6044 | return this;
|
6045 | };
|
6046 |
|
6047 | EventEmitter.prototype.listeners = function (type) {
|
6048 | var ret;
|
6049 | if (!this._events || !this._events[type]) ret = [];else if (isFunction(this._events[type])) ret = [this._events[type]];else ret = this._events[type].slice();
|
6050 | return ret;
|
6051 | };
|
6052 |
|
6053 | EventEmitter.prototype.listenerCount = function (type) {
|
6054 | if (this._events) {
|
6055 | var evlistener = this._events[type];
|
6056 |
|
6057 | if (isFunction(evlistener)) return 1;else if (evlistener) return evlistener.length;
|
6058 | }
|
6059 | return 0;
|
6060 | };
|
6061 |
|
6062 | EventEmitter.listenerCount = function (emitter, type) {
|
6063 | return emitter.listenerCount(type);
|
6064 | };
|
6065 |
|
6066 | function isFunction(arg) {
|
6067 | return typeof arg === 'function';
|
6068 | }
|
6069 |
|
6070 | function isNumber(arg) {
|
6071 | return typeof arg === 'number';
|
6072 | }
|
6073 |
|
6074 | function isObject(arg) {
|
6075 | return (typeof arg === 'undefined' ? 'undefined' : _typeof(arg)) === 'object' && arg !== null;
|
6076 | }
|
6077 |
|
6078 | function isUndefined(arg) {
|
6079 | return arg === void 0;
|
6080 | }
|
6081 |
|
6082 | }),
|
6083 |
|
6084 | (function(module, exports, __webpack_require__) {
|
6085 |
|
6086 | "use strict";
|
6087 |
|
6088 |
|
6089 | Object.defineProperty(exports, "__esModule", {
|
6090 | value: true
|
6091 | });
|
6092 | exports.JWPlayer = undefined;
|
6093 |
|
6094 | 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; }; }();
|
6095 |
|
6096 | var _react = __webpack_require__(0);
|
6097 |
|
6098 | var _react2 = _interopRequireDefault(_react);
|
6099 |
|
6100 | var _utils = __webpack_require__(1);
|
6101 |
|
6102 | var _singlePlayer = __webpack_require__(2);
|
6103 |
|
6104 | var _singlePlayer2 = _interopRequireDefault(_singlePlayer);
|
6105 |
|
6106 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
6107 |
|
6108 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
6109 |
|
6110 | 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; }
|
6111 |
|
6112 | 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; }
|
6113 |
|
6114 | var SDK_URL = '//cdn.jwplayer.com/libraries/8DNY8ff0.js';
|
6115 | var SDK_GLOBAL = 'jwplayer';
|
6116 |
|
6117 | var MATCH_VIDEO_URL = /jwplayer/;
|
6118 | var PLAYER_ID_PREFIX = 'jw-player-';
|
6119 |
|
6120 | var JWPlayer = exports.JWPlayer = function (_Component) {
|
6121 | _inherits(JWPlayer, _Component);
|
6122 |
|
6123 | function JWPlayer() {
|
6124 | var _ref;
|
6125 |
|
6126 | var _temp, _this, _ret;
|
6127 |
|
6128 | _classCallCheck(this, JWPlayer);
|
6129 |
|
6130 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
6131 | args[_key] = arguments[_key];
|
6132 | }
|
6133 |
|
6134 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = JWPlayer.__proto__ || Object.getPrototypeOf(JWPlayer)).call.apply(_ref, [this].concat(args))), _this), _this.callPlayer = _utils.callPlayer, _this.playerID = PLAYER_ID_PREFIX + (0, _utils.randomString)(), _this.mute = function () {
|
6135 | _this.callPlayer('setMute', true);
|
6136 | }, _this.unmute = function () {
|
6137 | _this.callPlayer('setMute', false);
|
6138 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
6139 | }
|
6140 |
|
6141 | _createClass(JWPlayer, [{
|
6142 | key: 'load',
|
6143 | value: function load(url, isReady) {
|
6144 | var _this2 = this;
|
6145 |
|
6146 | var onError = this.props.onError;
|
6147 |
|
6148 | if (isReady) {
|
6149 | this.player.setup({
|
6150 | file: url
|
6151 | });
|
6152 | } else {
|
6153 | (0, _utils.getSDK)(SDK_URL, SDK_GLOBAL).then(function (jwplayer) {
|
6154 | _this2.player = jwplayer(_this2.playerID).setup({
|
6155 | file: url
|
6156 | });
|
6157 | _this2.player.on('ready', _this2.props.onReady);
|
6158 | _this2.player.on('play', _this2.props.onPlay);
|
6159 | _this2.player.on('pause', _this2.props.onPause);
|
6160 | _this2.player.on('error', onError);
|
6161 | }, onError);
|
6162 | }
|
6163 | }
|
6164 | }, {
|
6165 | key: 'handleUnmount',
|
6166 | value: function handleUnmount() {
|
6167 | this.callPlayer('remove');
|
6168 | }
|
6169 | }, {
|
6170 | key: 'play',
|
6171 | value: function play() {
|
6172 | this.callPlayer('play');
|
6173 | }
|
6174 | }, {
|
6175 | key: 'pause',
|
6176 | value: function pause() {
|
6177 | this.callPlayer('pause');
|
6178 | }
|
6179 | }, {
|
6180 | key: 'stop',
|
6181 | value: function stop() {
|
6182 | this.callPlayer('stop');
|
6183 | }
|
6184 | }, {
|
6185 | key: 'seekTo',
|
6186 | value: function seekTo(seconds) {
|
6187 | this.callPlayer('seek', seconds);
|
6188 | }
|
6189 | }, {
|
6190 | key: 'getVolume',
|
6191 | value: function getVolume() {
|
6192 | return this.callPlayer('getVolume') / 100;
|
6193 | }
|
6194 | }, {
|
6195 | key: 'getMuted',
|
6196 | value: function getMuted() {
|
6197 | return this.callPlayer('getMute');
|
6198 | }
|
6199 | }, {
|
6200 | key: 'setVolume',
|
6201 | value: function setVolume(fraction) {
|
6202 | this.callPlayer('setVolume', fraction * 100);
|
6203 | }
|
6204 | }, {
|
6205 | key: 'getDuration',
|
6206 | value: function getDuration() {
|
6207 | return this.callPlayer('getDuration');
|
6208 | }
|
6209 | }, {
|
6210 | key: 'getCurrentTime',
|
6211 | value: function getCurrentTime() {
|
6212 | return this.callPlayer('getCurrentPosition');
|
6213 | }
|
6214 | }, {
|
6215 | key: 'getSecondsLoaded',
|
6216 | value: function getSecondsLoaded() {
|
6217 | return null;
|
6218 | }
|
6219 | }, {
|
6220 | key: 'render',
|
6221 | value: function render() {
|
6222 | var style = {
|
6223 | width: '100%',
|
6224 | height: '100%'
|
6225 | };
|
6226 | return _react2['default'].createElement('div', { style: style, id: this.playerID });
|
6227 | }
|
6228 | }]);
|
6229 |
|
6230 | return JWPlayer;
|
6231 | }(_react.Component);
|
6232 |
|
6233 | JWPlayer.displayName = 'JWPlayer';
|
6234 |
|
6235 | JWPlayer.canPlay = function (url) {
|
6236 | return MATCH_VIDEO_URL.test(url);
|
6237 | };
|
6238 |
|
6239 | JWPlayer.loopOnEnded = true;
|
6240 | exports['default'] = (0, _singlePlayer2['default'])(JWPlayer);
|
6241 |
|
6242 | }),
|
6243 |
|
6244 | (function(module, exports, __webpack_require__) {
|
6245 |
|
6246 | "use strict";
|
6247 |
|
6248 |
|
6249 | Object.defineProperty(exports, "__esModule", {
|
6250 | value: true
|
6251 | });
|
6252 | exports.PhenixPlayer = undefined;
|
6253 |
|
6254 | 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; }; }();
|
6255 |
|
6256 | var _react = __webpack_require__(0);
|
6257 |
|
6258 | var _react2 = _interopRequireDefault(_react);
|
6259 |
|
6260 | var _utils = __webpack_require__(1);
|
6261 |
|
6262 | var _singlePlayer = __webpack_require__(2);
|
6263 |
|
6264 | var _singlePlayer2 = _interopRequireDefault(_singlePlayer);
|
6265 |
|
6266 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
6267 |
|
6268 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
6269 |
|
6270 | 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; }
|
6271 |
|
6272 | 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; }
|
6273 |
|
6274 |
|
6275 |
|
6276 | var PHENIX_SDK_URL = 'https://unpkg.com/phenix-web-sdk@2019.2.3/dist/phenix-web-sdk.min.js';
|
6277 | var PHENIX_SDK_GLOBAL = 'phenix-web-sdk';
|
6278 |
|
6279 |
|
6280 | var PHENIX_URL_REGEX = /^phenix:(.+?)\|(.+?)(?:\|(.+?))?$/i;
|
6281 |
|
6282 | function getPhenixSdk() {
|
6283 | return (0, _utils.getSDK)(PHENIX_SDK_URL, PHENIX_SDK_GLOBAL);
|
6284 | }
|
6285 |
|
6286 | function canPlay(url) {
|
6287 | return PHENIX_URL_REGEX.test(url);
|
6288 | }
|
6289 |
|
6290 | var PhenixPlayer = exports.PhenixPlayer = function (_Component) {
|
6291 | _inherits(PhenixPlayer, _Component);
|
6292 |
|
6293 | function PhenixPlayer() {
|
6294 | var _ref;
|
6295 |
|
6296 | var _temp, _this, _ret;
|
6297 |
|
6298 | _classCallCheck(this, PhenixPlayer);
|
6299 |
|
6300 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
6301 | args[_key] = arguments[_key];
|
6302 | }
|
6303 |
|
6304 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = PhenixPlayer.__proto__ || Object.getPrototypeOf(PhenixPlayer)).call.apply(_ref, [this].concat(args))), _this), _this.player = null, _this.channelExpress = null, _this.playerRef = function (player) {
|
6305 | if (player === _this.player) {
|
6306 | return;
|
6307 | }
|
6308 | if (_this.player) {
|
6309 | _this.removeListeners();
|
6310 | }
|
6311 | _this.player = player;
|
6312 | if (_this.player) {
|
6313 | _this.addListeners();
|
6314 | }
|
6315 | }, _this.onSeek = function (e) {
|
6316 | _this.props.onSeek(e.target.currentTime);
|
6317 | }, _this.mute = function () {
|
6318 | _this.player.muted = true;
|
6319 | }, _this.unmute = function () {
|
6320 | _this.player.muted = false;
|
6321 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
6322 | }
|
6323 |
|
6324 | _createClass(PhenixPlayer, [{
|
6325 | key: 'componentWillUnmount',
|
6326 | value: function componentWillUnmount() {
|
6327 |
|
6328 | if (this.player) {
|
6329 | this.removeListeners();
|
6330 | this.player = null;
|
6331 | }
|
6332 | if (this.channelExpress) {
|
6333 | this.channelExpress.dispose();
|
6334 | this.channelExpress = null;
|
6335 | }
|
6336 | }
|
6337 | }, {
|
6338 | key: 'addListeners',
|
6339 | value: function addListeners() {
|
6340 | var _props = this.props,
|
6341 | onReady = _props.onReady,
|
6342 | onPlay = _props.onPlay,
|
6343 | onPause = _props.onPause,
|
6344 | onEnded = _props.onEnded,
|
6345 | onVolumeChange = _props.onVolumeChange,
|
6346 | onError = _props.onError,
|
6347 | playsinline = _props.playsinline,
|
6348 | videoElementId = _props.videoElementId;
|
6349 |
|
6350 | this.player.addEventListener('canplay', onReady);
|
6351 | this.player.addEventListener('play', onPlay);
|
6352 | this.player.addEventListener('pause', onPause);
|
6353 | this.player.addEventListener('seeked', this.onSeek);
|
6354 | this.player.addEventListener('ended', onEnded);
|
6355 | this.player.addEventListener('error', onError);
|
6356 | this.player.addEventListener('volumechange', onVolumeChange);
|
6357 |
|
6358 | this.player.setAttribute('id', videoElementId);
|
6359 | if (playsinline) {
|
6360 | this.player.setAttribute('playsinline', '');
|
6361 | this.player.setAttribute('webkit-playsinline', '');
|
6362 | }
|
6363 | }
|
6364 | }, {
|
6365 | key: 'removeListeners',
|
6366 | value: function removeListeners() {
|
6367 | var _props2 = this.props,
|
6368 | onReady = _props2.onReady,
|
6369 | onPlay = _props2.onPlay,
|
6370 | onPause = _props2.onPause,
|
6371 | onEnded = _props2.onEnded,
|
6372 | onVolumeChange = _props2.onVolumeChange,
|
6373 | onError = _props2.onError;
|
6374 |
|
6375 | this.player.removeEventListener('canplay', onReady);
|
6376 | this.player.removeEventListener('play', onPlay);
|
6377 | this.player.removeEventListener('pause', onPause);
|
6378 | this.player.removeEventListener('seeked', this.onSeek);
|
6379 | this.player.removeEventListener('ended', onEnded);
|
6380 | this.player.removeEventListener('error', onError);
|
6381 | this.player.removeEventListener('volumechange', onVolumeChange);
|
6382 | }
|
6383 | }, {
|
6384 | key: 'getPhenixBackendUri',
|
6385 | value: function getPhenixBackendUri() {
|
6386 | var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.props.url;
|
6387 |
|
6388 | return PHENIX_URL_REGEX.exec(url)[1];
|
6389 | }
|
6390 | }, {
|
6391 | key: 'getPhenixChannelId',
|
6392 | value: function getPhenixChannelId() {
|
6393 | var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.props.url;
|
6394 |
|
6395 | return PHENIX_URL_REGEX.exec(url)[2];
|
6396 | }
|
6397 | }, {
|
6398 | key: 'getPhenixAuthenticationData',
|
6399 | value: function getPhenixAuthenticationData() {
|
6400 | var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.props.url;
|
6401 |
|
6402 | var match = PHENIX_URL_REGEX.exec(url)[3];
|
6403 | return match ? JSON.parse(match) : {};
|
6404 | }
|
6405 | }, {
|
6406 | key: 'load',
|
6407 | value: function load(url) {
|
6408 | var _this2 = this;
|
6409 |
|
6410 | var backendUri = this.getPhenixBackendUri(url);
|
6411 | var channelId = this.getPhenixChannelId(url);
|
6412 | var authenticationData = this.getPhenixAuthenticationData(url);
|
6413 |
|
6414 | var joinChannelCallback = function joinChannelCallback(err, response) {
|
6415 | var success = !err && response.status === 'ok';
|
6416 | if (!success) {
|
6417 | var error = err || new Error('Response status: ' + response.status);
|
6418 | _this2.props.onError(error);
|
6419 | }
|
6420 | };
|
6421 |
|
6422 | var subscriberCallback = function subscriberCallback(err, response) {
|
6423 | var success = !err && ['ok', 'no-stream-playing'].includes(response.status);
|
6424 | if (!success) {
|
6425 | var error = err || new Error('Response status: ' + response.status);
|
6426 | _this2.props.onError(error);
|
6427 | }
|
6428 |
|
6429 | };
|
6430 |
|
6431 | getPhenixSdk().then(function (phenix) {
|
6432 |
|
6433 | if (url !== _this2.props.url) {
|
6434 | return;
|
6435 | }
|
6436 | if (_this2.channelExpress) {
|
6437 | _this2.channelExpress.dispose();
|
6438 | _this2.channelExpress = null;
|
6439 | }
|
6440 | _this2.channelExpress = new phenix.express.ChannelExpress({
|
6441 | authenticationData: authenticationData,
|
6442 | backendUri: backendUri
|
6443 | });
|
6444 | _this2.channelExpress.joinChannel({
|
6445 | channelId: channelId,
|
6446 | videoElement: _this2.player
|
6447 | }, joinChannelCallback, subscriberCallback);
|
6448 | });
|
6449 | }
|
6450 | }, {
|
6451 | key: 'play',
|
6452 | value: function play() {
|
6453 | var promise = this.player.play();
|
6454 | if (promise) {
|
6455 | promise['catch'](this.props.onError);
|
6456 | }
|
6457 | }
|
6458 | }, {
|
6459 | key: 'pause',
|
6460 | value: function pause() {
|
6461 | this.player.pause();
|
6462 | }
|
6463 | }, {
|
6464 | key: 'stop',
|
6465 | value: function stop() {
|
6466 | if (this.channelExpress) {
|
6467 | this.channelExpress.dispose();
|
6468 | this.channelExpress = null;
|
6469 | }
|
6470 | }
|
6471 | }, {
|
6472 | key: 'seekTo',
|
6473 | value: function seekTo(seconds) {
|
6474 | if (seconds === Infinity || this.getDuration() === Infinity) {
|
6475 | return;
|
6476 | }
|
6477 | this.player.currentTime = seconds;
|
6478 | }
|
6479 | }, {
|
6480 | key: 'setVolume',
|
6481 | value: function setVolume(fraction) {
|
6482 | this.player.volume = fraction;
|
6483 | }
|
6484 | }, {
|
6485 | key: 'setPlaybackRate',
|
6486 | value: function setPlaybackRate(rate) {
|
6487 | this.player.playbackRate = rate;
|
6488 | }
|
6489 | }, {
|
6490 | key: 'getDuration',
|
6491 | value: function getDuration() {
|
6492 | return this.player.duration;
|
6493 | }
|
6494 | }, {
|
6495 | key: 'getCurrentTime',
|
6496 | value: function getCurrentTime() {
|
6497 | return this.player.currentTime;
|
6498 | }
|
6499 | }, {
|
6500 | key: 'getSecondsLoaded',
|
6501 | value: function getSecondsLoaded() {
|
6502 | var buffered = this.player.buffered;
|
6503 |
|
6504 | if (buffered.length === 0) {
|
6505 | return 0;
|
6506 | }
|
6507 | var end = buffered.end(buffered.length - 1);
|
6508 | var duration = this.getDuration();
|
6509 | if (end > duration) {
|
6510 | return duration;
|
6511 | }
|
6512 | return end;
|
6513 | }
|
6514 | }, {
|
6515 | key: 'render',
|
6516 | value: function render() {
|
6517 | var _props3 = this.props,
|
6518 | playing = _props3.playing,
|
6519 | loop = _props3.loop,
|
6520 | controls = _props3.controls,
|
6521 | muted = _props3.muted,
|
6522 | width = _props3.width,
|
6523 | height = _props3.height;
|
6524 |
|
6525 | var style = {
|
6526 | width: width === 'auto' ? width : '100%',
|
6527 | height: height === 'auto' ? height : '100%'
|
6528 | };
|
6529 | return _react2['default'].createElement('video', {
|
6530 | ref: this.playerRef,
|
6531 | style: style,
|
6532 | preload: 'auto'
|
6533 | , autoPlay: playing
|
6534 | , controls: controls
|
6535 | , muted: muted,
|
6536 | loop: loop
|
6537 | });
|
6538 | }
|
6539 | }]);
|
6540 |
|
6541 | return PhenixPlayer;
|
6542 | }(_react.Component);
|
6543 |
|
6544 | PhenixPlayer.displayName = 'PhenixPlayer';
|
6545 | PhenixPlayer.canPlay = canPlay;
|
6546 | exports['default'] = (0, _singlePlayer2['default'])(PhenixPlayer);
|
6547 |
|
6548 | }),
|
6549 |
|
6550 | (function(module, exports, __webpack_require__) {
|
6551 |
|
6552 | "use strict";
|
6553 |
|
6554 |
|
6555 | Object.defineProperty(exports, "__esModule", {
|
6556 | value: true
|
6557 | });
|
6558 | exports.PhenixPlayer = exports.JWPlayer = exports.VAST = exports.FilePlayer = exports.Mixcloud = exports.Iframe = exports.UstreamVideo = exports.UstreamLive = exports.DailyMotion = exports.Twitch = exports.Wistia = exports.FaceMask = exports.Streamable = exports.Facebook = exports.Vimeo = exports.SoundCloud = exports.YouTube = undefined;
|
6559 |
|
6560 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
6561 |
|
6562 | 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; }; }();
|
6563 |
|
6564 | var _YouTube = __webpack_require__(5);
|
6565 |
|
6566 | Object.defineProperty(exports, 'YouTube', {
|
6567 | enumerable: true,
|
6568 | get: function get() {
|
6569 | return _interopRequireDefault(_YouTube)['default'];
|
6570 | }
|
6571 | });
|
6572 |
|
6573 | var _SoundCloud = __webpack_require__(7);
|
6574 |
|
6575 | Object.defineProperty(exports, 'SoundCloud', {
|
6576 | enumerable: true,
|
6577 | get: function get() {
|
6578 | return _interopRequireDefault(_SoundCloud)['default'];
|
6579 | }
|
6580 | });
|
6581 |
|
6582 | var _Vimeo = __webpack_require__(8);
|
6583 |
|
6584 | Object.defineProperty(exports, 'Vimeo', {
|
6585 | enumerable: true,
|
6586 | get: function get() {
|
6587 | return _interopRequireDefault(_Vimeo)['default'];
|
6588 | }
|
6589 | });
|
6590 |
|
6591 | var _Facebook = __webpack_require__(13);
|
6592 |
|
6593 | Object.defineProperty(exports, 'Facebook', {
|
6594 | enumerable: true,
|
6595 | get: function get() {
|
6596 | return _interopRequireDefault(_Facebook)['default'];
|
6597 | }
|
6598 | });
|
6599 |
|
6600 | var _Streamable = __webpack_require__(14);
|
6601 |
|
6602 | Object.defineProperty(exports, 'Streamable', {
|
6603 | enumerable: true,
|
6604 | get: function get() {
|
6605 | return _interopRequireDefault(_Streamable)['default'];
|
6606 | }
|
6607 | });
|
6608 |
|
6609 | var _FaceMask = __webpack_require__(15);
|
6610 |
|
6611 | Object.defineProperty(exports, 'FaceMask', {
|
6612 | enumerable: true,
|
6613 | get: function get() {
|
6614 | return _interopRequireDefault(_FaceMask)['default'];
|
6615 | }
|
6616 | });
|
6617 |
|
6618 | var _Wistia = __webpack_require__(16);
|
6619 |
|
6620 | Object.defineProperty(exports, 'Wistia', {
|
6621 | enumerable: true,
|
6622 | get: function get() {
|
6623 | return _interopRequireDefault(_Wistia)['default'];
|
6624 | }
|
6625 | });
|
6626 |
|
6627 | var _Twitch = __webpack_require__(17);
|
6628 |
|
6629 | Object.defineProperty(exports, 'Twitch', {
|
6630 | enumerable: true,
|
6631 | get: function get() {
|
6632 | return _interopRequireDefault(_Twitch)['default'];
|
6633 | }
|
6634 | });
|
6635 |
|
6636 | var _DailyMotion = __webpack_require__(9);
|
6637 |
|
6638 | Object.defineProperty(exports, 'DailyMotion', {
|
6639 | enumerable: true,
|
6640 | get: function get() {
|
6641 | return _interopRequireDefault(_DailyMotion)['default'];
|
6642 | }
|
6643 | });
|
6644 |
|
6645 | var _UstreamLive = __webpack_require__(18);
|
6646 |
|
6647 | Object.defineProperty(exports, 'UstreamLive', {
|
6648 | enumerable: true,
|
6649 | get: function get() {
|
6650 | return _interopRequireDefault(_UstreamLive)['default'];
|
6651 | }
|
6652 | });
|
6653 |
|
6654 | var _UstreamVideo = __webpack_require__(19);
|
6655 |
|
6656 | Object.defineProperty(exports, 'UstreamVideo', {
|
6657 | enumerable: true,
|
6658 | get: function get() {
|
6659 | return _interopRequireDefault(_UstreamVideo)['default'];
|
6660 | }
|
6661 | });
|
6662 |
|
6663 | var _Iframe = __webpack_require__(20);
|
6664 |
|
6665 | Object.defineProperty(exports, 'Iframe', {
|
6666 | enumerable: true,
|
6667 | get: function get() {
|
6668 | return _interopRequireDefault(_Iframe)['default'];
|
6669 | }
|
6670 | });
|
6671 |
|
6672 | var _Mixcloud = __webpack_require__(21);
|
6673 |
|
6674 | Object.defineProperty(exports, 'Mixcloud', {
|
6675 | enumerable: true,
|
6676 | get: function get() {
|
6677 | return _interopRequireDefault(_Mixcloud)['default'];
|
6678 | }
|
6679 | });
|
6680 |
|
6681 | var _FilePlayer = __webpack_require__(10);
|
6682 |
|
6683 | Object.defineProperty(exports, 'FilePlayer', {
|
6684 | enumerable: true,
|
6685 | get: function get() {
|
6686 | return _interopRequireDefault(_FilePlayer)['default'];
|
6687 | }
|
6688 | });
|
6689 |
|
6690 | var _VAST = __webpack_require__(22);
|
6691 |
|
6692 | Object.defineProperty(exports, 'VAST', {
|
6693 | enumerable: true,
|
6694 | get: function get() {
|
6695 | return _interopRequireDefault(_VAST)['default'];
|
6696 | }
|
6697 | });
|
6698 |
|
6699 | var _JWPlayer = __webpack_require__(29);
|
6700 |
|
6701 | Object.defineProperty(exports, 'JWPlayer', {
|
6702 | enumerable: true,
|
6703 | get: function get() {
|
6704 | return _interopRequireDefault(_JWPlayer)['default'];
|
6705 | }
|
6706 | });
|
6707 |
|
6708 | var _PhenixPlayer = __webpack_require__(30);
|
6709 |
|
6710 | Object.defineProperty(exports, 'PhenixPlayer', {
|
6711 | enumerable: true,
|
6712 | get: function get() {
|
6713 | return _interopRequireDefault(_PhenixPlayer)['default'];
|
6714 | }
|
6715 | });
|
6716 |
|
6717 | var _react = __webpack_require__(0);
|
6718 |
|
6719 | var _react2 = _interopRequireDefault(_react);
|
6720 |
|
6721 | var _props2 = __webpack_require__(4);
|
6722 |
|
6723 | var _utils = __webpack_require__(1);
|
6724 |
|
6725 | var _players = __webpack_require__(63);
|
6726 |
|
6727 | var _players2 = _interopRequireDefault(_players);
|
6728 |
|
6729 | var _Player4 = __webpack_require__(6);
|
6730 |
|
6731 | var _Player5 = _interopRequireDefault(_Player4);
|
6732 |
|
6733 | var _Preview = __webpack_require__(64);
|
6734 |
|
6735 | var _Preview2 = _interopRequireDefault(_Preview);
|
6736 |
|
6737 | var _preload = __webpack_require__(65);
|
6738 |
|
6739 | var _preload2 = _interopRequireDefault(_preload);
|
6740 |
|
6741 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
6742 |
|
6743 | function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
6744 |
|
6745 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
6746 |
|
6747 | 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; }
|
6748 |
|
6749 | 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; }
|
6750 |
|
6751 | var SUPPORTED_PROPS = Object.keys(_props2.propTypes);
|
6752 |
|
6753 | var customPlayers = [];
|
6754 |
|
6755 | var ReactPlayer = function (_Component) {
|
6756 | _inherits(ReactPlayer, _Component);
|
6757 |
|
6758 | function ReactPlayer() {
|
6759 | var _ref;
|
6760 |
|
6761 | var _temp, _this, _ret;
|
6762 |
|
6763 | _classCallCheck(this, ReactPlayer);
|
6764 |
|
6765 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
6766 | args[_key] = arguments[_key];
|
6767 | }
|
6768 |
|
6769 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ReactPlayer.__proto__ || Object.getPrototypeOf(ReactPlayer)).call.apply(_ref, [this].concat(args))), _this), _this.config = (0, _utils.getConfig)(_this.props, _props2.defaultProps, true), _this.state = {
|
6770 | showPreview: !!_this.props.light
|
6771 | }, _this.onClickPreview = function () {
|
6772 | _this.setState({ showPreview: false });
|
6773 | }, _this.getDuration = function () {
|
6774 | if (!_this.player) return null;
|
6775 | return _this.player.getDuration();
|
6776 | }, _this.getCurrentTime = function () {
|
6777 | if (!_this.player) return null;
|
6778 | return _this.player.getCurrentTime();
|
6779 | }, _this.getSecondsLoaded = function () {
|
6780 | if (!_this.player) return null;
|
6781 | return _this.player.getSecondsLoaded();
|
6782 | }, _this.getInternalPlayer = function () {
|
6783 | var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'player';
|
6784 |
|
6785 | if (!_this.player) return null;
|
6786 | return _this.player.getInternalPlayer(key);
|
6787 | }, _this.seekTo = function (fraction, type) {
|
6788 | if (!_this.player) return null;
|
6789 | _this.player.seekTo(fraction, type);
|
6790 | }, _this.onReady = function () {
|
6791 | _this.props.onReady(_this);
|
6792 | }, _this.wrapperRef = function (wrapper) {
|
6793 | _this.wrapper = wrapper;
|
6794 | }, _this.activePlayerRef = function (player) {
|
6795 | _this.player = player;
|
6796 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
6797 | }
|
6798 |
|
6799 | _createClass(ReactPlayer, [{
|
6800 | key: 'componentDidMount',
|
6801 | value: function componentDidMount() {
|
6802 | if (this.props.progressFrequency) {
|
6803 | var message = 'ReactPlayer: %cprogressFrequency%c is deprecated, please use %cprogressInterval%c instead';
|
6804 | console.warn(message, 'font-weight: bold', '', 'font-weight: bold', '');
|
6805 | }
|
6806 | }
|
6807 | }, {
|
6808 | key: 'shouldComponentUpdate',
|
6809 | value: function shouldComponentUpdate(nextProps, nextState) {
|
6810 | return !(0, _utils.isEqual)(this.props, nextProps) || !(0, _utils.isEqual)(this.state, nextState);
|
6811 | }
|
6812 | }, {
|
6813 | key: 'componentWillUpdate',
|
6814 | value: function componentWillUpdate(nextProps) {
|
6815 | this.config = (0, _utils.getConfig)(nextProps, _props2.defaultProps);
|
6816 | if (!this.props.light && nextProps.light) {
|
6817 | this.setState({ showPreview: true });
|
6818 | }
|
6819 | }
|
6820 | }, {
|
6821 | key: 'getActivePlayer',
|
6822 | value: function getActivePlayer(url) {
|
6823 | var _arr = [].concat(_toConsumableArray(customPlayers), _toConsumableArray(_players2['default']));
|
6824 |
|
6825 | for (var _i = 0; _i < _arr.length; _i++) {
|
6826 | var _Player = _arr[_i];
|
6827 | if (_Player.canPlay(url)) {
|
6828 | return _Player;
|
6829 | }
|
6830 | }
|
6831 |
|
6832 | return _Iframe.Iframe;
|
6833 | }
|
6834 | }, {
|
6835 | key: 'renderActivePlayer',
|
6836 | value: function renderActivePlayer(url, activePlayer) {
|
6837 | if (!url) return null;
|
6838 | return _react2['default'].createElement(_Player5['default'], _extends({}, this.props, {
|
6839 | key: activePlayer.displayName,
|
6840 | ref: this.activePlayerRef,
|
6841 | config: this.config,
|
6842 | activePlayer: activePlayer,
|
6843 | onReady: this.onReady
|
6844 | }));
|
6845 | }
|
6846 | }, {
|
6847 | key: 'sortPlayers',
|
6848 | value: function sortPlayers(a, b) {
|
6849 |
|
6850 | if (a && b) {
|
6851 | return a.key < b.key ? -1 : 1;
|
6852 | }
|
6853 | return 0;
|
6854 | }
|
6855 | }, {
|
6856 | key: 'render',
|
6857 | value: function render() {
|
6858 | var _props = this.props,
|
6859 | url = _props.url,
|
6860 | controls = _props.controls,
|
6861 | style = _props.style,
|
6862 | width = _props.width,
|
6863 | height = _props.height,
|
6864 | light = _props.light,
|
6865 | Wrapper = _props.wrapper;
|
6866 |
|
6867 | var showPreview = this.state.showPreview && url;
|
6868 | var otherProps = (0, _utils.omit)(this.props, SUPPORTED_PROPS, _props2.DEPRECATED_CONFIG_PROPS);
|
6869 | var activePlayer = this.getActivePlayer(url);
|
6870 | var renderedActivePlayer = this.renderActivePlayer(url, activePlayer);
|
6871 | var preloadPlayers = (0, _preload2['default'])(url, controls, this.config);
|
6872 | var players = [renderedActivePlayer].concat(_toConsumableArray(preloadPlayers)).sort(this.sortPlayers);
|
6873 | var preview = _react2['default'].createElement(_Preview2['default'], { url: url, light: light, onClick: this.onClickPreview });
|
6874 | return _react2['default'].createElement(
|
6875 | Wrapper,
|
6876 | _extends({ ref: this.wrapperRef, style: _extends({}, style, { width: width, height: height }) }, otherProps),
|
6877 | showPreview ? preview : players
|
6878 | );
|
6879 | }
|
6880 | }]);
|
6881 |
|
6882 | return ReactPlayer;
|
6883 | }(_react.Component);
|
6884 |
|
6885 | ReactPlayer.addCustomPlayer = function (player) {
|
6886 | customPlayers.push(player);
|
6887 | };
|
6888 |
|
6889 | ReactPlayer.removeCustomPlayers = function () {
|
6890 | customPlayers = [];
|
6891 | };
|
6892 |
|
6893 | ReactPlayer.displayName = 'ReactPlayer';
|
6894 | ReactPlayer.propTypes = _props2.propTypes;
|
6895 | ReactPlayer.defaultProps = _props2.defaultProps;
|
6896 |
|
6897 | ReactPlayer.canPlay = function (url) {
|
6898 | var _arr2 = [].concat(_toConsumableArray(customPlayers), _toConsumableArray(_players2['default']));
|
6899 |
|
6900 | for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
|
6901 | var _Player2 = _arr2[_i2];
|
6902 | if (_Player2.canPlay(url)) {
|
6903 | return true;
|
6904 | }
|
6905 | }
|
6906 | return false;
|
6907 | };
|
6908 |
|
6909 | ReactPlayer.canEnablePIP = function (url) {
|
6910 | var _arr3 = [].concat(_toConsumableArray(customPlayers), _toConsumableArray(_players2['default']));
|
6911 |
|
6912 | for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
|
6913 | var _Player3 = _arr3[_i3];
|
6914 | if (_Player3.canEnablePIP && _Player3.canEnablePIP(url)) {
|
6915 | return true;
|
6916 | }
|
6917 | }
|
6918 | return false;
|
6919 | };
|
6920 |
|
6921 | exports['default'] = ReactPlayer;
|
6922 |
|
6923 | }),
|
6924 |
|
6925 | (function(module, exports, __webpack_require__) {
|
6926 |
|
6927 | "use strict";
|
6928 |
|
6929 |
|
6930 | module.exports = function load(src, opts, cb) {
|
6931 | var head = document.head || document.getElementsByTagName('head')[0];
|
6932 | var script = document.createElement('script');
|
6933 |
|
6934 | if (typeof opts === 'function') {
|
6935 | cb = opts;
|
6936 | opts = {};
|
6937 | }
|
6938 |
|
6939 | opts = opts || {};
|
6940 | cb = cb || function () {};
|
6941 |
|
6942 | script.type = opts.type || 'text/javascript';
|
6943 | script.charset = opts.charset || 'utf8';
|
6944 | script.async = 'async' in opts ? !!opts.async : true;
|
6945 | script.src = src;
|
6946 |
|
6947 | if (opts.attrs) {
|
6948 | setAttributes(script, opts.attrs);
|
6949 | }
|
6950 |
|
6951 | if (opts.text) {
|
6952 | script.text = '' + opts.text;
|
6953 | }
|
6954 |
|
6955 | var onend = 'onload' in script ? stdOnEnd : ieOnEnd;
|
6956 | onend(script, cb);
|
6957 |
|
6958 |
|
6959 |
|
6960 |
|
6961 | if (!script.onload) {
|
6962 | stdOnEnd(script, cb);
|
6963 | }
|
6964 |
|
6965 | head.appendChild(script);
|
6966 | };
|
6967 |
|
6968 | function setAttributes(script, attrs) {
|
6969 | for (var attr in attrs) {
|
6970 | script.setAttribute(attr, attrs[attr]);
|
6971 | }
|
6972 | }
|
6973 |
|
6974 | function stdOnEnd(script, cb) {
|
6975 | script.onload = function () {
|
6976 | this.onerror = this.onload = null;
|
6977 | cb(null, script);
|
6978 | };
|
6979 | script.onerror = function () {
|
6980 |
|
6981 |
|
6982 | this.onerror = this.onload = null;
|
6983 | cb(new Error('Failed to load ' + this.src), script);
|
6984 | };
|
6985 | }
|
6986 |
|
6987 | function ieOnEnd(script, cb) {
|
6988 | script.onreadystatechange = function () {
|
6989 | if (this.readyState != 'complete' && this.readyState != 'loaded') return;
|
6990 | this.onreadystatechange = null;
|
6991 | cb(null, script);
|
6992 | };
|
6993 | }
|
6994 |
|
6995 | }),
|
6996 |
|
6997 | (function(module, exports, __webpack_require__) {
|
6998 |
|
6999 | "use strict";
|
7000 | var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;
|
7001 |
|
7002 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
7003 |
|
7004 | (function (global, factory) {
|
7005 | ( false ? 'undefined' : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory() : true ? !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
|
7006 | __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
|
7007 | (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
|
7008 | __WEBPACK_AMD_DEFINE_FACTORY__),
|
7009 | __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) : global.deepmerge = factory();
|
7010 | })(undefined, function () {
|
7011 | 'use strict';
|
7012 |
|
7013 | var isMergeableObject = function isMergeableObject(value) {
|
7014 | return isNonNullObject(value) && !isSpecial(value);
|
7015 | };
|
7016 |
|
7017 | function isNonNullObject(value) {
|
7018 | return !!value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object';
|
7019 | }
|
7020 |
|
7021 | function isSpecial(value) {
|
7022 | var stringValue = Object.prototype.toString.call(value);
|
7023 |
|
7024 | return stringValue === '[object RegExp]' || stringValue === '[object Date]' || isReactElement(value);
|
7025 | }
|
7026 |
|
7027 |
|
7028 | var canUseSymbol = typeof Symbol === 'function' && Symbol['for'];
|
7029 | var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol['for']('react.element') : 0xeac7;
|
7030 |
|
7031 | function isReactElement(value) {
|
7032 | return value.$$typeof === REACT_ELEMENT_TYPE;
|
7033 | }
|
7034 |
|
7035 | function emptyTarget(val) {
|
7036 | return Array.isArray(val) ? [] : {};
|
7037 | }
|
7038 |
|
7039 | function cloneUnlessOtherwiseSpecified(value, options) {
|
7040 | return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value;
|
7041 | }
|
7042 |
|
7043 | function defaultArrayMerge(target, source, options) {
|
7044 | return target.concat(source).map(function (element) {
|
7045 | return cloneUnlessOtherwiseSpecified(element, options);
|
7046 | });
|
7047 | }
|
7048 |
|
7049 | function mergeObject(target, source, options) {
|
7050 | var destination = {};
|
7051 | if (options.isMergeableObject(target)) {
|
7052 | Object.keys(target).forEach(function (key) {
|
7053 | destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
|
7054 | });
|
7055 | }
|
7056 | Object.keys(source).forEach(function (key) {
|
7057 | if (!options.isMergeableObject(source[key]) || !target[key]) {
|
7058 | destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
|
7059 | } else {
|
7060 | destination[key] = deepmerge(target[key], source[key], options);
|
7061 | }
|
7062 | });
|
7063 | return destination;
|
7064 | }
|
7065 |
|
7066 | function deepmerge(target, source, options) {
|
7067 | options = options || {};
|
7068 | options.arrayMerge = options.arrayMerge || defaultArrayMerge;
|
7069 | options.isMergeableObject = options.isMergeableObject || isMergeableObject;
|
7070 |
|
7071 | var sourceIsArray = Array.isArray(source);
|
7072 | var targetIsArray = Array.isArray(target);
|
7073 | var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
|
7074 |
|
7075 | if (!sourceAndTargetTypesMatch) {
|
7076 | return cloneUnlessOtherwiseSpecified(source, options);
|
7077 | } else if (sourceIsArray) {
|
7078 | return options.arrayMerge(target, source, options);
|
7079 | } else {
|
7080 | return mergeObject(target, source, options);
|
7081 | }
|
7082 | }
|
7083 |
|
7084 | deepmerge.all = function deepmergeAll(array, options) {
|
7085 | if (!Array.isArray(array)) {
|
7086 | throw new Error('first argument should be an array');
|
7087 | }
|
7088 |
|
7089 | return array.reduce(function (prev, next) {
|
7090 | return deepmerge(prev, next, options);
|
7091 | }, {});
|
7092 | };
|
7093 |
|
7094 | var deepmerge_1 = deepmerge;
|
7095 |
|
7096 | return deepmerge_1;
|
7097 | });
|
7098 |
|
7099 | }),
|
7100 |
|
7101 | (function(module, exports, __webpack_require__) {
|
7102 |
|
7103 | "use strict";
|
7104 |
|
7105 |
|
7106 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
7107 |
|
7108 |
|
7109 |
|
7110 |
|
7111 |
|
7112 |
|
7113 |
|
7114 |
|
7115 | if (false) {
|
7116 | var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
|
7117 |
|
7118 | var isValidElement = function isValidElement(object) {
|
7119 | return (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
7120 | };
|
7121 |
|
7122 |
|
7123 |
|
7124 | var throwOnDirectAccess = true;
|
7125 | module.exports = require('./factoryWithTypeCheckers')(isValidElement, throwOnDirectAccess);
|
7126 | } else {
|
7127 |
|
7128 |
|
7129 | module.exports = __webpack_require__(35)();
|
7130 | }
|
7131 |
|
7132 | }),
|
7133 |
|
7134 | (function(module, exports, __webpack_require__) {
|
7135 |
|
7136 | "use strict";
|
7137 |
|
7138 |
|
7139 |
|
7140 |
|
7141 |
|
7142 |
|
7143 |
|
7144 |
|
7145 |
|
7146 | var emptyFunction = __webpack_require__(36);
|
7147 | var invariant = __webpack_require__(37);
|
7148 | var ReactPropTypesSecret = __webpack_require__(38);
|
7149 |
|
7150 | module.exports = function () {
|
7151 | function shim(props, propName, componentName, location, propFullName, secret) {
|
7152 | if (secret === ReactPropTypesSecret) {
|
7153 |
|
7154 | return;
|
7155 | }
|
7156 | invariant(false, 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use PropTypes.checkPropTypes() to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
|
7157 | };
|
7158 | shim.isRequired = shim;
|
7159 | function getShim() {
|
7160 | return shim;
|
7161 | };
|
7162 |
|
7163 |
|
7164 | var ReactPropTypes = {
|
7165 | array: shim,
|
7166 | bool: shim,
|
7167 | func: shim,
|
7168 | number: shim,
|
7169 | object: shim,
|
7170 | string: shim,
|
7171 | symbol: shim,
|
7172 |
|
7173 | any: shim,
|
7174 | arrayOf: getShim,
|
7175 | element: shim,
|
7176 | instanceOf: getShim,
|
7177 | node: shim,
|
7178 | objectOf: getShim,
|
7179 | oneOf: getShim,
|
7180 | oneOfType: getShim,
|
7181 | shape: getShim,
|
7182 | exact: getShim
|
7183 | };
|
7184 |
|
7185 | ReactPropTypes.checkPropTypes = emptyFunction;
|
7186 | ReactPropTypes.PropTypes = ReactPropTypes;
|
7187 |
|
7188 | return ReactPropTypes;
|
7189 | };
|
7190 |
|
7191 | }),
|
7192 |
|
7193 | (function(module, exports, __webpack_require__) {
|
7194 |
|
7195 | "use strict";
|
7196 |
|
7197 |
|
7198 |
|
7199 |
|
7200 |
|
7201 |
|
7202 |
|
7203 |
|
7204 |
|
7205 |
|
7206 |
|
7207 | function makeEmptyFunction(arg) {
|
7208 | return function () {
|
7209 | return arg;
|
7210 | };
|
7211 | }
|
7212 |
|
7213 |
|
7214 |
|
7215 |
|
7216 |
|
7217 |
|
7218 | var emptyFunction = function emptyFunction() {};
|
7219 |
|
7220 | emptyFunction.thatReturns = makeEmptyFunction;
|
7221 | emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
|
7222 | emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
|
7223 | emptyFunction.thatReturnsNull = makeEmptyFunction(null);
|
7224 | emptyFunction.thatReturnsThis = function () {
|
7225 | return this;
|
7226 | };
|
7227 | emptyFunction.thatReturnsArgument = function (arg) {
|
7228 | return arg;
|
7229 | };
|
7230 |
|
7231 | module.exports = emptyFunction;
|
7232 |
|
7233 | }),
|
7234 |
|
7235 | (function(module, exports, __webpack_require__) {
|
7236 |
|
7237 | "use strict";
|
7238 |
|
7239 |
|
7240 |
|
7241 |
|
7242 |
|
7243 |
|
7244 |
|
7245 |
|
7246 |
|
7247 |
|
7248 |
|
7249 |
|
7250 |
|
7251 |
|
7252 |
|
7253 |
|
7254 |
|
7255 |
|
7256 |
|
7257 |
|
7258 |
|
7259 | var validateFormat = function validateFormat(format) {};
|
7260 |
|
7261 | if (false) {
|
7262 | validateFormat = function validateFormat(format) {
|
7263 | if (format === undefined) {
|
7264 | throw new Error('invariant requires an error message argument');
|
7265 | }
|
7266 | };
|
7267 | }
|
7268 |
|
7269 | function invariant(condition, format, a, b, c, d, e, f) {
|
7270 | validateFormat(format);
|
7271 |
|
7272 | if (!condition) {
|
7273 | var error;
|
7274 | if (format === undefined) {
|
7275 | error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
7276 | } else {
|
7277 | var args = [a, b, c, d, e, f];
|
7278 | var argIndex = 0;
|
7279 | error = new Error(format.replace(/%s/g, function () {
|
7280 | return args[argIndex++];
|
7281 | }));
|
7282 | error.name = 'Invariant Violation';
|
7283 | }
|
7284 |
|
7285 | error.framesToPop = 1;
|
7286 | throw error;
|
7287 | }
|
7288 | }
|
7289 |
|
7290 | module.exports = invariant;
|
7291 |
|
7292 | }),
|
7293 |
|
7294 | (function(module, exports, __webpack_require__) {
|
7295 |
|
7296 | "use strict";
|
7297 |
|
7298 |
|
7299 |
|
7300 |
|
7301 |
|
7302 |
|
7303 |
|
7304 |
|
7305 |
|
7306 | var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
7307 |
|
7308 | module.exports = ReactPropTypesSecret;
|
7309 |
|
7310 | }),
|
7311 |
|
7312 | (function(module, exports, __webpack_require__) {
|
7313 |
|
7314 | "use strict";
|
7315 |
|
7316 |
|
7317 | var utils = __webpack_require__(23);
|
7318 | var unique = utils.unique('vpaidIframe');
|
7319 | var VPAIDAdUnit = __webpack_require__(40);
|
7320 |
|
7321 | var defaultTemplate = '<!DOCTYPE html>' + '<html lang="en">' + '<head><meta charset="UTF-8"></head>' + '<body style="margin:0;padding:0"><div class="ad-element"></div>' + '<script type="text/javascript" src="{{iframeURL_JS}}"></script>' + '<script type="text/javascript">' + 'window.parent.postMessage(\'{"event": "ready", "id": "{{iframeID}}"}\', \'{{origin}}\');' + '</script>' + '</body>' + '</html>';
|
7322 |
|
7323 | var AD_STOPPED = 'AdStopped';
|
7324 |
|
7325 |
|
7326 |
|
7327 |
|
7328 |
|
7329 |
|
7330 |
|
7331 |
|
7332 |
|
7333 |
|
7334 |
|
7335 |
|
7336 |
|
7337 |
|
7338 |
|
7339 |
|
7340 |
|
7341 | function VPAIDHTML5Client(el, video, templateConfig, vpaidOptions) {
|
7342 | templateConfig = templateConfig || {};
|
7343 |
|
7344 | this._id = unique();
|
7345 | this._destroyed = false;
|
7346 |
|
7347 | this._frameContainer = utils.createElementInEl(el, 'div');
|
7348 | this._videoEl = video;
|
7349 | this._vpaidOptions = vpaidOptions || { timeout: 10000 };
|
7350 |
|
7351 | this._templateConfig = {
|
7352 | template: templateConfig.template || defaultTemplate,
|
7353 | extraOptions: templateConfig.extraOptions || {}
|
7354 | };
|
7355 | }
|
7356 |
|
7357 |
|
7358 |
|
7359 |
|
7360 |
|
7361 | VPAIDHTML5Client.prototype.destroy = function destroy() {
|
7362 | if (this._destroyed) {
|
7363 | return;
|
7364 | }
|
7365 | this._destroyed = true;
|
7366 | $unloadPreviousAdUnit.call(this);
|
7367 | };
|
7368 |
|
7369 |
|
7370 |
|
7371 |
|
7372 |
|
7373 |
|
7374 | VPAIDHTML5Client.prototype.isDestroyed = function isDestroyed() {
|
7375 | return this._destroyed;
|
7376 | };
|
7377 |
|
7378 |
|
7379 |
|
7380 |
|
7381 |
|
7382 |
|
7383 |
|
7384 | VPAIDHTML5Client.prototype.loadAdUnit = function loadAdUnit(adURL, callback) {
|
7385 | $throwIfDestroyed.call(this);
|
7386 | $unloadPreviousAdUnit.call(this);
|
7387 | var that = this;
|
7388 |
|
7389 | var frame = utils.createIframeWithContent(this._frameContainer, this._templateConfig.template, utils.extend({
|
7390 | iframeURL_JS: adURL,
|
7391 | iframeID: this.getID(),
|
7392 | origin: getOrigin()
|
7393 | }, this._templateConfig.extraOptions));
|
7394 |
|
7395 | this._frame = frame;
|
7396 |
|
7397 | this._onLoad = utils.callbackTimeout(this._vpaidOptions.timeout, onLoad.bind(this), onTimeout.bind(this));
|
7398 |
|
7399 | window.addEventListener('message', this._onLoad);
|
7400 |
|
7401 | function onLoad(e) {
|
7402 |
|
7403 |
|
7404 | if (e.origin !== getOrigin()) return;
|
7405 | var result = JSON.parse(e.data);
|
7406 |
|
7407 |
|
7408 | if (result.id !== that.getID()) return;
|
7409 |
|
7410 | var adUnit, error, createAd;
|
7411 | if (!that._frame.contentWindow) {
|
7412 |
|
7413 | error = 'the iframe is not anymore in the DOM tree';
|
7414 | } else {
|
7415 | createAd = that._frame.contentWindow.getVPAIDAd;
|
7416 | error = utils.validate(typeof createAd === 'function', 'the ad didn\'t return a function to create an ad');
|
7417 | }
|
7418 |
|
7419 | if (!error) {
|
7420 | var adEl = that._frame.contentWindow.document.querySelector('.ad-element');
|
7421 | adUnit = new VPAIDAdUnit(createAd(), adEl, that._videoEl, that._frame);
|
7422 | adUnit.subscribe(AD_STOPPED, $adDestroyed.bind(that));
|
7423 | error = utils.validate(adUnit.isValidVPAIDAd(), 'the add is not fully complaint with VPAID specification');
|
7424 | }
|
7425 |
|
7426 | that._adUnit = adUnit;
|
7427 | $destroyLoadListener.call(that);
|
7428 | callback(error, error ? null : adUnit);
|
7429 |
|
7430 |
|
7431 | return true;
|
7432 | }
|
7433 |
|
7434 | function onTimeout() {
|
7435 | callback('timeout', null);
|
7436 | }
|
7437 | };
|
7438 |
|
7439 |
|
7440 |
|
7441 |
|
7442 |
|
7443 | VPAIDHTML5Client.prototype.unloadAdUnit = function unloadAdUnit() {
|
7444 | $unloadPreviousAdUnit.call(this);
|
7445 | };
|
7446 |
|
7447 |
|
7448 |
|
7449 |
|
7450 |
|
7451 |
|
7452 | VPAIDHTML5Client.prototype.getID = function () {
|
7453 | return this._id;
|
7454 | };
|
7455 |
|
7456 |
|
7457 |
|
7458 |
|
7459 |
|
7460 |
|
7461 | function $removeEl(key) {
|
7462 | var el = this[key];
|
7463 | if (el) {
|
7464 | el.remove();
|
7465 | delete this[key];
|
7466 | }
|
7467 | }
|
7468 |
|
7469 | function $adDestroyed() {
|
7470 | $removeAdElements.call(this);
|
7471 | delete this._adUnit;
|
7472 | }
|
7473 |
|
7474 | function $unloadPreviousAdUnit() {
|
7475 | $removeAdElements.call(this);
|
7476 | $destroyAdUnit.call(this);
|
7477 | }
|
7478 |
|
7479 | function $removeAdElements() {
|
7480 | $removeEl.call(this, '_frame');
|
7481 | $destroyLoadListener.call(this);
|
7482 | }
|
7483 |
|
7484 |
|
7485 |
|
7486 |
|
7487 |
|
7488 | function $destroyLoadListener() {
|
7489 | if (this._onLoad) {
|
7490 | window.removeEventListener('message', this._onLoad);
|
7491 | utils.clearCallbackTimeout(this._onLoad);
|
7492 | delete this._onLoad;
|
7493 | }
|
7494 | }
|
7495 |
|
7496 | function $destroyAdUnit() {
|
7497 | if (this._adUnit) {
|
7498 | this._adUnit.stopAd();
|
7499 | delete this._adUnit;
|
7500 | }
|
7501 | }
|
7502 |
|
7503 |
|
7504 |
|
7505 |
|
7506 |
|
7507 | function $throwIfDestroyed() {
|
7508 | if (this._destroyed) {
|
7509 | throw new Error('VPAIDHTML5Client already destroyed!');
|
7510 | }
|
7511 | }
|
7512 |
|
7513 | function getOrigin() {
|
7514 | if (window.location.origin) {
|
7515 | return window.location.origin;
|
7516 | } else {
|
7517 | return window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
|
7518 | }
|
7519 | }
|
7520 |
|
7521 | module.exports = VPAIDHTML5Client;
|
7522 |
|
7523 | }),
|
7524 |
|
7525 | (function(module, exports, __webpack_require__) {
|
7526 |
|
7527 | "use strict";
|
7528 |
|
7529 |
|
7530 | var IVPAIDAdUnit = __webpack_require__(41);
|
7531 | var Subscriber = __webpack_require__(42);
|
7532 | var checkVPAIDInterface = IVPAIDAdUnit.checkVPAIDInterface;
|
7533 | var utils = __webpack_require__(23);
|
7534 | var METHODS = IVPAIDAdUnit.METHODS;
|
7535 | var ERROR = 'AdError';
|
7536 | var AD_CLICK = 'AdClickThru';
|
7537 | var FILTERED_EVENTS = IVPAIDAdUnit.EVENTS.filter(function (event) {
|
7538 | return event != AD_CLICK;
|
7539 | });
|
7540 |
|
7541 |
|
7542 |
|
7543 |
|
7544 |
|
7545 |
|
7546 |
|
7547 |
|
7548 |
|
7549 |
|
7550 |
|
7551 |
|
7552 |
|
7553 |
|
7554 |
|
7555 |
|
7556 | function VPAIDAdUnit(VPAIDCreative, el, video, iframe) {
|
7557 | this._isValid = checkVPAIDInterface(VPAIDCreative);
|
7558 | if (this._isValid) {
|
7559 | this._creative = VPAIDCreative;
|
7560 | this._el = el;
|
7561 | this._videoEl = video;
|
7562 | this._iframe = iframe;
|
7563 | this._subscribers = new Subscriber();
|
7564 | utils.setFullSizeStyle(el);
|
7565 | $addEventsSubscribers.call(this);
|
7566 | }
|
7567 | }
|
7568 |
|
7569 | VPAIDAdUnit.prototype = Object.create(IVPAIDAdUnit.prototype);
|
7570 |
|
7571 |
|
7572 |
|
7573 |
|
7574 |
|
7575 |
|
7576 | VPAIDAdUnit.prototype.isValidVPAIDAd = function isValidVPAIDAd() {
|
7577 | return this._isValid;
|
7578 | };
|
7579 |
|
7580 | IVPAIDAdUnit.METHODS.forEach(function (method) {
|
7581 |
|
7582 | var ignores = ['subscribe', 'unsubscribe', 'initAd'];
|
7583 |
|
7584 | if (ignores.indexOf(method) !== -1) return;
|
7585 |
|
7586 | VPAIDAdUnit.prototype[method] = function () {
|
7587 | var ariaty = IVPAIDAdUnit.prototype[method].length;
|
7588 |
|
7589 |
|
7590 | var args = Array.prototype.slice.call(arguments);
|
7591 | var callback = ariaty === args.length ? args.pop() : undefined;
|
7592 |
|
7593 | setTimeout(function () {
|
7594 | var result,
|
7595 | error = null;
|
7596 | try {
|
7597 | result = this._creative[method].apply(this._creative, args);
|
7598 | } catch (e) {
|
7599 | error = e;
|
7600 | }
|
7601 |
|
7602 | callOrTriggerEvent(callback, this._subscribers, error, result);
|
7603 | }.bind(this), 0);
|
7604 | };
|
7605 | });
|
7606 |
|
7607 |
|
7608 |
|
7609 |
|
7610 |
|
7611 |
|
7612 |
|
7613 |
|
7614 |
|
7615 |
|
7616 |
|
7617 |
|
7618 | VPAIDAdUnit.prototype.initAd = function initAd(width, height, viewMode, desiredBitrate, creativeData, environmentVars, callback) {
|
7619 | creativeData = creativeData || {};
|
7620 | environmentVars = utils.extend({
|
7621 | slot: this._el,
|
7622 | videoSlot: this._videoEl
|
7623 | }, environmentVars || {});
|
7624 |
|
7625 | setTimeout(function () {
|
7626 | var error;
|
7627 | try {
|
7628 | this._creative.initAd(width, height, viewMode, desiredBitrate, creativeData, environmentVars);
|
7629 | } catch (e) {
|
7630 | error = e;
|
7631 | }
|
7632 |
|
7633 | callOrTriggerEvent(callback, this._subscribers, error);
|
7634 | }.bind(this), 0);
|
7635 | };
|
7636 |
|
7637 |
|
7638 |
|
7639 |
|
7640 |
|
7641 |
|
7642 |
|
7643 |
|
7644 | VPAIDAdUnit.prototype.subscribe = function subscribe(event, handler, context) {
|
7645 | this._subscribers.subscribe(handler, event, context);
|
7646 | };
|
7647 |
|
7648 |
|
7649 |
|
7650 |
|
7651 |
|
7652 |
|
7653 |
|
7654 | VPAIDAdUnit.prototype.unsubscribe = function unsubscribe(event, handler) {
|
7655 | this._subscribers.unsubscribe(handler, event);
|
7656 | };
|
7657 |
|
7658 |
|
7659 | VPAIDAdUnit.prototype.on = VPAIDAdUnit.prototype.subscribe;
|
7660 | VPAIDAdUnit.prototype.off = VPAIDAdUnit.prototype.unsubscribe;
|
7661 |
|
7662 | IVPAIDAdUnit.GETTERS.forEach(function (getter) {
|
7663 | VPAIDAdUnit.prototype[getter] = function (callback) {
|
7664 | setTimeout(function () {
|
7665 |
|
7666 | var result,
|
7667 | error = null;
|
7668 | try {
|
7669 | result = this._creative[getter]();
|
7670 | } catch (e) {
|
7671 | error = e;
|
7672 | }
|
7673 |
|
7674 | callOrTriggerEvent(callback, this._subscribers, error, result);
|
7675 | }.bind(this), 0);
|
7676 | };
|
7677 | });
|
7678 |
|
7679 |
|
7680 |
|
7681 |
|
7682 |
|
7683 |
|
7684 |
|
7685 | VPAIDAdUnit.prototype.setAdVolume = function setAdVolume(volume, callback) {
|
7686 | setTimeout(function () {
|
7687 |
|
7688 | var result,
|
7689 | error = null;
|
7690 | try {
|
7691 | this._creative.setAdVolume(volume);
|
7692 | result = this._creative.getAdVolume();
|
7693 | } catch (e) {
|
7694 | error = e;
|
7695 | }
|
7696 |
|
7697 | if (!error) {
|
7698 | error = utils.validate(result === volume, 'failed to apply volume: ' + volume);
|
7699 | }
|
7700 | callOrTriggerEvent(callback, this._subscribers, error, result);
|
7701 | }.bind(this), 0);
|
7702 | };
|
7703 |
|
7704 | VPAIDAdUnit.prototype._destroy = function destroy() {
|
7705 | this.stopAd();
|
7706 | this._subscribers.unsubscribeAll();
|
7707 | };
|
7708 |
|
7709 | function $addEventsSubscribers() {
|
7710 |
|
7711 |
|
7712 |
|
7713 | FILTERED_EVENTS.forEach(function (event) {
|
7714 | this._creative.subscribe($trigger.bind(this, event), event);
|
7715 | }.bind(this));
|
7716 |
|
7717 |
|
7718 |
|
7719 | this._creative.subscribe($clickThruHook.bind(this), AD_CLICK);
|
7720 |
|
7721 |
|
7722 |
|
7723 | if (this._videoEl) {
|
7724 | var documentElement = this._iframe.contentDocument.documentElement;
|
7725 | var videoEl = this._videoEl;
|
7726 | documentElement.addEventListener('click', function (e) {
|
7727 | if (e.target === documentElement) {
|
7728 | videoEl.click();
|
7729 | }
|
7730 | });
|
7731 | }
|
7732 | }
|
7733 |
|
7734 | function $clickThruHook(url, id, playerHandles) {
|
7735 | this._subscribers.triggerSync(AD_CLICK, { url: url, id: id, playerHandles: playerHandles });
|
7736 | }
|
7737 |
|
7738 | function $trigger(event) {
|
7739 |
|
7740 |
|
7741 | this._subscribers.trigger(event, Array.prototype.slice(arguments, 1));
|
7742 | }
|
7743 |
|
7744 | function callOrTriggerEvent(callback, subscribers, error, result) {
|
7745 | if (callback) {
|
7746 | callback(error, result);
|
7747 | } else if (error) {
|
7748 | subscribers.trigger(ERROR, error);
|
7749 | }
|
7750 | }
|
7751 |
|
7752 | module.exports = VPAIDAdUnit;
|
7753 |
|
7754 | }),
|
7755 |
|
7756 | (function(module, exports, __webpack_require__) {
|
7757 |
|
7758 | "use strict";
|
7759 |
|
7760 |
|
7761 | var METHODS = ['handshakeVersion', 'initAd', 'startAd', 'stopAd', 'skipAd',
|
7762 | 'resizeAd', 'pauseAd', 'resumeAd', 'expandAd', 'collapseAd', 'subscribe', 'unsubscribe'];
|
7763 |
|
7764 | var EVENTS = ['AdLoaded', 'AdStarted', 'AdStopped', 'AdSkipped', 'AdSkippableStateChange',
|
7765 | 'AdSizeChange',
|
7766 | 'AdLinearChange', 'AdDurationChange',
|
7767 | 'AdExpandedChange', 'AdRemainingTimeChange',
|
7768 | 'AdVolumeChange', 'AdImpression', 'AdVideoStart', 'AdVideoFirstQuartile', 'AdVideoMidpoint', 'AdVideoThirdQuartile', 'AdVideoComplete', 'AdClickThru', 'AdInteraction',
|
7769 | 'AdUserAcceptInvitation', 'AdUserMinimize', 'AdUserClose', 'AdPaused', 'AdPlaying', 'AdLog', 'AdError'];
|
7770 |
|
7771 | var GETTERS = ['getAdLinear', 'getAdWidth',
|
7772 | 'getAdHeight',
|
7773 | 'getAdExpanded', 'getAdSkippableState',
|
7774 | 'getAdRemainingTime', 'getAdDuration',
|
7775 | 'getAdVolume', 'getAdCompanions',
|
7776 | 'getAdIcons'
|
7777 | ];
|
7778 |
|
7779 | var SETTERS = ['setAdVolume'];
|
7780 |
|
7781 |
|
7782 |
|
7783 |
|
7784 |
|
7785 |
|
7786 |
|
7787 |
|
7788 |
|
7789 |
|
7790 |
|
7791 |
|
7792 |
|
7793 |
|
7794 |
|
7795 |
|
7796 |
|
7797 | function IVPAIDAdUnit(creative, el, video) {}
|
7798 |
|
7799 |
|
7800 |
|
7801 |
|
7802 |
|
7803 |
|
7804 |
|
7805 | IVPAIDAdUnit.prototype.handshakeVersion = function (VPAIDVersion, callback) {};
|
7806 |
|
7807 |
|
7808 |
|
7809 |
|
7810 |
|
7811 |
|
7812 |
|
7813 |
|
7814 |
|
7815 |
|
7816 |
|
7817 |
|
7818 | IVPAIDAdUnit.prototype.initAd = function (width, height, viewMode, desiredBitrate, creativeData, environmentVars, callback) {};
|
7819 |
|
7820 |
|
7821 |
|
7822 |
|
7823 |
|
7824 |
|
7825 | IVPAIDAdUnit.prototype.startAd = function (callback) {};
|
7826 |
|
7827 |
|
7828 |
|
7829 |
|
7830 |
|
7831 |
|
7832 | IVPAIDAdUnit.prototype.stopAd = function (callback) {};
|
7833 |
|
7834 |
|
7835 |
|
7836 |
|
7837 |
|
7838 |
|
7839 | IVPAIDAdUnit.prototype.skipAd = function (callback) {};
|
7840 |
|
7841 |
|
7842 |
|
7843 |
|
7844 |
|
7845 |
|
7846 | IVPAIDAdUnit.prototype.resizeAd = function (width, height, viewMode, callback) {};
|
7847 |
|
7848 |
|
7849 |
|
7850 |
|
7851 |
|
7852 |
|
7853 | IVPAIDAdUnit.prototype.pauseAd = function (callback) {};
|
7854 |
|
7855 |
|
7856 |
|
7857 |
|
7858 |
|
7859 |
|
7860 | IVPAIDAdUnit.prototype.resumeAd = function (callback) {};
|
7861 |
|
7862 |
|
7863 |
|
7864 |
|
7865 |
|
7866 |
|
7867 | IVPAIDAdUnit.prototype.expandAd = function (callback) {};
|
7868 |
|
7869 |
|
7870 |
|
7871 |
|
7872 |
|
7873 |
|
7874 | IVPAIDAdUnit.prototype.collapseAd = function (callback) {};
|
7875 |
|
7876 |
|
7877 |
|
7878 |
|
7879 |
|
7880 |
|
7881 |
|
7882 |
|
7883 | IVPAIDAdUnit.prototype.subscribe = function (event, handler, context) {};
|
7884 |
|
7885 |
|
7886 |
|
7887 |
|
7888 |
|
7889 |
|
7890 |
|
7891 | IVPAIDAdUnit.prototype.unsubscribe = function (event, handler) {};
|
7892 |
|
7893 |
|
7894 |
|
7895 |
|
7896 |
|
7897 |
|
7898 | IVPAIDAdUnit.prototype.getAdLinear = function (callback) {};
|
7899 |
|
7900 |
|
7901 |
|
7902 |
|
7903 |
|
7904 |
|
7905 | IVPAIDAdUnit.prototype.getAdWidth = function (callback) {};
|
7906 |
|
7907 |
|
7908 |
|
7909 |
|
7910 |
|
7911 |
|
7912 | IVPAIDAdUnit.prototype.getAdHeight = function (callback) {};
|
7913 |
|
7914 |
|
7915 |
|
7916 |
|
7917 |
|
7918 |
|
7919 | IVPAIDAdUnit.prototype.getAdExpanded = function (callback) {};
|
7920 |
|
7921 |
|
7922 |
|
7923 |
|
7924 |
|
7925 |
|
7926 | IVPAIDAdUnit.prototype.getAdSkippableState = function (callback) {};
|
7927 |
|
7928 |
|
7929 |
|
7930 |
|
7931 |
|
7932 |
|
7933 | IVPAIDAdUnit.prototype.getAdRemainingTime = function (callback) {};
|
7934 |
|
7935 |
|
7936 |
|
7937 |
|
7938 |
|
7939 |
|
7940 | IVPAIDAdUnit.prototype.getAdDuration = function (callback) {};
|
7941 |
|
7942 |
|
7943 |
|
7944 |
|
7945 |
|
7946 |
|
7947 | IVPAIDAdUnit.prototype.getAdVolume = function (callback) {};
|
7948 |
|
7949 |
|
7950 |
|
7951 |
|
7952 |
|
7953 |
|
7954 | IVPAIDAdUnit.prototype.getAdCompanions = function (callback) {};
|
7955 |
|
7956 |
|
7957 |
|
7958 |
|
7959 |
|
7960 |
|
7961 | IVPAIDAdUnit.prototype.getAdIcons = function (callback) {};
|
7962 |
|
7963 |
|
7964 |
|
7965 |
|
7966 |
|
7967 |
|
7968 |
|
7969 | IVPAIDAdUnit.prototype.setAdVolume = function (volume, callback) {};
|
7970 |
|
7971 | addStaticToInterface(IVPAIDAdUnit, 'METHODS', METHODS);
|
7972 | addStaticToInterface(IVPAIDAdUnit, 'GETTERS', GETTERS);
|
7973 | addStaticToInterface(IVPAIDAdUnit, 'SETTERS', SETTERS);
|
7974 | addStaticToInterface(IVPAIDAdUnit, 'EVENTS', EVENTS);
|
7975 |
|
7976 | var VPAID1_METHODS = METHODS.filter(function (method) {
|
7977 | return ['skipAd'].indexOf(method) === -1;
|
7978 | });
|
7979 |
|
7980 | addStaticToInterface(IVPAIDAdUnit, 'checkVPAIDInterface', function checkVPAIDInterface(creative) {
|
7981 | var result = VPAID1_METHODS.every(function (key) {
|
7982 | return typeof creative[key] === 'function';
|
7983 | });
|
7984 | return result;
|
7985 | });
|
7986 |
|
7987 | module.exports = IVPAIDAdUnit;
|
7988 |
|
7989 | function addStaticToInterface(Interface, name, value) {
|
7990 | Object.defineProperty(Interface, name, {
|
7991 | writable: false,
|
7992 | configurable: false,
|
7993 | value: value
|
7994 | });
|
7995 | }
|
7996 |
|
7997 | }),
|
7998 |
|
7999 | (function(module, exports, __webpack_require__) {
|
8000 |
|
8001 | "use strict";
|
8002 |
|
8003 |
|
8004 | function Subscriber() {
|
8005 | this._subscribers = {};
|
8006 | }
|
8007 |
|
8008 | Subscriber.prototype.subscribe = function subscribe(handler, eventName, context) {
|
8009 | if (!this.isHandlerAttached(handler, eventName)) {
|
8010 | this.get(eventName).push({ handler: handler, context: context, eventName: eventName });
|
8011 | }
|
8012 | };
|
8013 |
|
8014 | Subscriber.prototype.unsubscribe = function unsubscribe(handler, eventName) {
|
8015 | this._subscribers[eventName] = this.get(eventName).filter(function (subscriber) {
|
8016 | return handler !== subscriber.handler;
|
8017 | });
|
8018 | };
|
8019 |
|
8020 | Subscriber.prototype.unsubscribeAll = function unsubscribeAll() {
|
8021 | this._subscribers = {};
|
8022 | };
|
8023 |
|
8024 | Subscriber.prototype.trigger = function (eventName, data) {
|
8025 | var that = this;
|
8026 | var subscribers = this.get(eventName).concat(this.get('*'));
|
8027 |
|
8028 | subscribers.forEach(function (subscriber) {
|
8029 | setTimeout(function () {
|
8030 | if (that.isHandlerAttached(subscriber.handler, subscriber.eventName)) {
|
8031 | subscriber.handler.call(subscriber.context, data);
|
8032 | }
|
8033 | }, 0);
|
8034 | });
|
8035 | };
|
8036 |
|
8037 | Subscriber.prototype.triggerSync = function (eventName, data) {
|
8038 | var subscribers = this.get(eventName).concat(this.get('*'));
|
8039 |
|
8040 | subscribers.forEach(function (subscriber) {
|
8041 | subscriber.handler.call(subscriber.context, data);
|
8042 | });
|
8043 | };
|
8044 |
|
8045 | Subscriber.prototype.get = function get(eventName) {
|
8046 | if (!this._subscribers[eventName]) {
|
8047 | this._subscribers[eventName] = [];
|
8048 | }
|
8049 | return this._subscribers[eventName];
|
8050 | };
|
8051 |
|
8052 | Subscriber.prototype.isHandlerAttached = function isHandlerAttached(handler, eventName) {
|
8053 | return this.get(eventName).some(function (subscriber) {
|
8054 | return handler === subscriber.handler;
|
8055 | });
|
8056 | };
|
8057 |
|
8058 | module.exports = Subscriber;
|
8059 |
|
8060 | }),
|
8061 |
|
8062 | (function(module, exports, __webpack_require__) {
|
8063 |
|
8064 | "use strict";
|
8065 |
|
8066 |
|
8067 | Object.defineProperty(exports, "__esModule", {
|
8068 | value: true
|
8069 | });
|
8070 | exports.VASTTracker = exports.VASTParser = exports.VASTClient = undefined;
|
8071 |
|
8072 | var _vast_parser = __webpack_require__(24);
|
8073 |
|
8074 | var _vast_client = __webpack_require__(60);
|
8075 |
|
8076 | var _vast_tracker = __webpack_require__(62);
|
8077 |
|
8078 | exports.VASTClient = _vast_client.VASTClient;
|
8079 | exports.VASTParser = _vast_parser.VASTParser;
|
8080 | exports.VASTTracker = _vast_tracker.VASTTracker;
|
8081 |
|
8082 | }),
|
8083 |
|
8084 | (function(module, exports, __webpack_require__) {
|
8085 |
|
8086 | "use strict";
|
8087 |
|
8088 |
|
8089 | Object.defineProperty(exports, "__esModule", {
|
8090 | value: true
|
8091 | });
|
8092 | exports.parseAd = parseAd;
|
8093 |
|
8094 | var _ad = __webpack_require__(45);
|
8095 |
|
8096 | var _ad_extension = __webpack_require__(46);
|
8097 |
|
8098 | var _ad_extension_child = __webpack_require__(47);
|
8099 |
|
8100 | var _creative_companion_parser = __webpack_require__(48);
|
8101 |
|
8102 | var _creative_linear_parser = __webpack_require__(50);
|
8103 |
|
8104 | var _creative_non_linear_parser = __webpack_require__(53);
|
8105 |
|
8106 | var _parser_utils = __webpack_require__(3);
|
8107 |
|
8108 |
|
8109 |
|
8110 |
|
8111 |
|
8112 |
|
8113 |
|
8114 |
|
8115 |
|
8116 |
|
8117 | function parseAd(adElement) {
|
8118 | var childNodes = adElement.childNodes;
|
8119 |
|
8120 | for (var adTypeElementKey in childNodes) {
|
8121 | var adTypeElement = childNodes[adTypeElementKey];
|
8122 |
|
8123 | if (['Wrapper', 'InLine'].indexOf(adTypeElement.nodeName) === -1) {
|
8124 | continue;
|
8125 | }
|
8126 |
|
8127 | _parser_utils.parserUtils.copyNodeAttribute('id', adElement, adTypeElement);
|
8128 | _parser_utils.parserUtils.copyNodeAttribute('sequence', adElement, adTypeElement);
|
8129 |
|
8130 | if (adTypeElement.nodeName === 'Wrapper') {
|
8131 | return parseWrapper(adTypeElement);
|
8132 | } else if (adTypeElement.nodeName === 'InLine') {
|
8133 | return parseInLine(adTypeElement);
|
8134 | }
|
8135 | }
|
8136 | }
|
8137 |
|
8138 |
|
8139 |
|
8140 |
|
8141 |
|
8142 |
|
8143 | function parseInLine(inLineElement) {
|
8144 | var childNodes = inLineElement.childNodes;
|
8145 | var ad = new _ad.Ad();
|
8146 | ad.id = inLineElement.getAttribute('id') || null;
|
8147 | ad.sequence = inLineElement.getAttribute('sequence') || null;
|
8148 |
|
8149 | for (var nodeKey in childNodes) {
|
8150 | var node = childNodes[nodeKey];
|
8151 |
|
8152 | switch (node.nodeName) {
|
8153 | case 'Error':
|
8154 | ad.errorURLTemplates.push(_parser_utils.parserUtils.parseNodeText(node));
|
8155 | break;
|
8156 |
|
8157 | case 'Impression':
|
8158 | ad.impressionURLTemplates.push(_parser_utils.parserUtils.parseNodeText(node));
|
8159 | break;
|
8160 |
|
8161 | case 'Creatives':
|
8162 | _parser_utils.parserUtils.childrenByName(node, 'Creative').forEach(function (creativeElement) {
|
8163 | var creativeAttributes = {
|
8164 | id: creativeElement.getAttribute('id') || null,
|
8165 | adId: parseCreativeAdIdAttribute(creativeElement),
|
8166 | sequence: creativeElement.getAttribute('sequence') || null,
|
8167 | apiFramework: creativeElement.getAttribute('apiFramework') || null
|
8168 | };
|
8169 |
|
8170 | for (var creativeTypeElementKey in creativeElement.childNodes) {
|
8171 | var creativeTypeElement = creativeElement.childNodes[creativeTypeElementKey];
|
8172 | var parsedCreative = void 0;
|
8173 |
|
8174 | switch (creativeTypeElement.nodeName) {
|
8175 | case 'Linear':
|
8176 | parsedCreative = (0, _creative_linear_parser.parseCreativeLinear)(creativeTypeElement, creativeAttributes);
|
8177 | if (parsedCreative) {
|
8178 | ad.creatives.push(parsedCreative);
|
8179 | }
|
8180 | break;
|
8181 | case 'NonLinearAds':
|
8182 | parsedCreative = (0, _creative_non_linear_parser.parseCreativeNonLinear)(creativeTypeElement, creativeAttributes);
|
8183 | if (parsedCreative) {
|
8184 | ad.creatives.push(parsedCreative);
|
8185 | }
|
8186 | break;
|
8187 | case 'CompanionAds':
|
8188 | parsedCreative = (0, _creative_companion_parser.parseCreativeCompanion)(creativeTypeElement, creativeAttributes);
|
8189 | if (parsedCreative) {
|
8190 | ad.creatives.push(parsedCreative);
|
8191 | }
|
8192 | break;
|
8193 | }
|
8194 | }
|
8195 | });
|
8196 | break;
|
8197 |
|
8198 | case 'Extensions':
|
8199 | parseExtensions(ad.extensions, _parser_utils.parserUtils.childrenByName(node, 'Extension'));
|
8200 | break;
|
8201 |
|
8202 | case 'AdSystem':
|
8203 | ad.system = {
|
8204 | value: _parser_utils.parserUtils.parseNodeText(node),
|
8205 | version: node.getAttribute('version') || null
|
8206 | };
|
8207 | break;
|
8208 |
|
8209 | case 'AdTitle':
|
8210 | ad.title = _parser_utils.parserUtils.parseNodeText(node);
|
8211 | break;
|
8212 |
|
8213 | case 'Description':
|
8214 | ad.description = _parser_utils.parserUtils.parseNodeText(node);
|
8215 | break;
|
8216 |
|
8217 | case 'Advertiser':
|
8218 | ad.advertiser = _parser_utils.parserUtils.parseNodeText(node);
|
8219 | break;
|
8220 |
|
8221 | case 'Pricing':
|
8222 | ad.pricing = {
|
8223 | value: _parser_utils.parserUtils.parseNodeText(node),
|
8224 | model: node.getAttribute('model') || null,
|
8225 | currency: node.getAttribute('currency') || null
|
8226 | };
|
8227 | break;
|
8228 |
|
8229 | case 'Survey':
|
8230 | ad.survey = _parser_utils.parserUtils.parseNodeText(node);
|
8231 | break;
|
8232 | }
|
8233 | }
|
8234 |
|
8235 | return ad;
|
8236 | }
|
8237 |
|
8238 |
|
8239 |
|
8240 |
|
8241 |
|
8242 |
|
8243 | function parseWrapper(wrapperElement) {
|
8244 | var ad = parseInLine(wrapperElement);
|
8245 | var wrapperURLElement = _parser_utils.parserUtils.childByName(wrapperElement, 'VASTAdTagURI');
|
8246 |
|
8247 | if (wrapperURLElement) {
|
8248 | ad.nextWrapperURL = _parser_utils.parserUtils.parseNodeText(wrapperURLElement);
|
8249 | } else {
|
8250 | wrapperURLElement = _parser_utils.parserUtils.childByName(wrapperElement, 'VASTAdTagURL');
|
8251 |
|
8252 | if (wrapperURLElement) {
|
8253 | ad.nextWrapperURL = _parser_utils.parserUtils.parseNodeText(_parser_utils.parserUtils.childByName(wrapperURLElement, 'URL'));
|
8254 | }
|
8255 | }
|
8256 |
|
8257 | ad.creatives.forEach(function (wrapperCreativeElement) {
|
8258 | if (['linear', 'nonlinear'].indexOf(wrapperCreativeElement.type) !== -1) {
|
8259 |
|
8260 | if (wrapperCreativeElement.trackingEvents) {
|
8261 | if (!ad.trackingEvents) {
|
8262 | ad.trackingEvents = {};
|
8263 | }
|
8264 | if (!ad.trackingEvents[wrapperCreativeElement.type]) {
|
8265 | ad.trackingEvents[wrapperCreativeElement.type] = {};
|
8266 | }
|
8267 |
|
8268 | var _loop = function _loop(eventName) {
|
8269 | var urls = wrapperCreativeElement.trackingEvents[eventName];
|
8270 | if (!Array.isArray(ad.trackingEvents[wrapperCreativeElement.type][eventName])) {
|
8271 | ad.trackingEvents[wrapperCreativeElement.type][eventName] = [];
|
8272 | }
|
8273 | urls.forEach(function (url) {
|
8274 | ad.trackingEvents[wrapperCreativeElement.type][eventName].push(url);
|
8275 | });
|
8276 | };
|
8277 |
|
8278 | for (var eventName in wrapperCreativeElement.trackingEvents) {
|
8279 | _loop(eventName);
|
8280 | }
|
8281 | }
|
8282 |
|
8283 | if (wrapperCreativeElement.videoClickTrackingURLTemplates) {
|
8284 | if (!Array.isArray(ad.videoClickTrackingURLTemplates)) {
|
8285 | ad.videoClickTrackingURLTemplates = [];
|
8286 | }
|
8287 | wrapperCreativeElement.videoClickTrackingURLTemplates.forEach(function (item) {
|
8288 | ad.videoClickTrackingURLTemplates.push(item);
|
8289 | });
|
8290 | }
|
8291 |
|
8292 | if (wrapperCreativeElement.videoClickThroughURLTemplate) {
|
8293 | ad.videoClickThroughURLTemplate = wrapperCreativeElement.videoClickThroughURLTemplate;
|
8294 | }
|
8295 |
|
8296 | if (wrapperCreativeElement.videoCustomClickURLTemplates) {
|
8297 | if (!Array.isArray(ad.videoCustomClickURLTemplates)) {
|
8298 | ad.videoCustomClickURLTemplates = [];
|
8299 | }
|
8300 | wrapperCreativeElement.videoCustomClickURLTemplates.forEach(function (item) {
|
8301 | ad.videoCustomClickURLTemplates.push(item);
|
8302 | });
|
8303 | }
|
8304 | }
|
8305 | });
|
8306 |
|
8307 | if (ad.nextWrapperURL) {
|
8308 | return ad;
|
8309 | }
|
8310 | }
|
8311 |
|
8312 |
|
8313 |
|
8314 |
|
8315 |
|
8316 |
|
8317 | function parseExtensions(collection, extensions) {
|
8318 | extensions.forEach(function (extNode) {
|
8319 | var ext = new _ad_extension.AdExtension();
|
8320 | var extNodeAttrs = extNode.attributes;
|
8321 | var childNodes = extNode.childNodes;
|
8322 |
|
8323 | if (extNode.attributes) {
|
8324 | for (var extNodeAttrKey in extNodeAttrs) {
|
8325 | var extNodeAttr = extNodeAttrs[extNodeAttrKey];
|
8326 |
|
8327 | if (extNodeAttr.nodeName && extNodeAttr.nodeValue) {
|
8328 | ext.attributes[extNodeAttr.nodeName] = extNodeAttr.nodeValue;
|
8329 | }
|
8330 | }
|
8331 | }
|
8332 |
|
8333 | for (var childNodeKey in childNodes) {
|
8334 | var childNode = childNodes[childNodeKey];
|
8335 | var txt = _parser_utils.parserUtils.parseNodeText(childNode);
|
8336 |
|
8337 |
|
8338 | if (childNode.nodeName !== '#comment' && txt !== '') {
|
8339 | var extChild = new _ad_extension_child.AdExtensionChild();
|
8340 | extChild.name = childNode.nodeName;
|
8341 | extChild.value = txt;
|
8342 |
|
8343 | if (childNode.attributes) {
|
8344 | var childNodeAttributes = childNode.attributes;
|
8345 |
|
8346 | for (var extChildNodeAttrKey in childNodeAttributes) {
|
8347 | var extChildNodeAttr = childNodeAttributes[extChildNodeAttrKey];
|
8348 |
|
8349 | extChild.attributes[extChildNodeAttr.nodeName] = extChildNodeAttr.nodeValue;
|
8350 | }
|
8351 | }
|
8352 |
|
8353 | ext.children.push(extChild);
|
8354 | }
|
8355 | }
|
8356 |
|
8357 | collection.push(ext);
|
8358 | });
|
8359 | }
|
8360 |
|
8361 |
|
8362 |
|
8363 |
|
8364 |
|
8365 |
|
8366 | function parseCreativeAdIdAttribute(creativeElement) {
|
8367 | return creativeElement.getAttribute('AdID') ||
|
8368 | creativeElement.getAttribute('adID') ||
|
8369 | creativeElement.getAttribute('adId') ||
|
8370 | null;
|
8371 | }
|
8372 |
|
8373 | }),
|
8374 |
|
8375 | (function(module, exports, __webpack_require__) {
|
8376 |
|
8377 | "use strict";
|
8378 |
|
8379 |
|
8380 | Object.defineProperty(exports, "__esModule", {
|
8381 | value: true
|
8382 | });
|
8383 |
|
8384 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
8385 |
|
8386 | var Ad = exports.Ad = function Ad() {
|
8387 | _classCallCheck(this, Ad);
|
8388 |
|
8389 | this.id = null;
|
8390 | this.sequence = null;
|
8391 | this.system = null;
|
8392 | this.title = null;
|
8393 | this.description = null;
|
8394 | this.advertiser = null;
|
8395 | this.pricing = null;
|
8396 | this.survey = null;
|
8397 | this.errorURLTemplates = [];
|
8398 | this.impressionURLTemplates = [];
|
8399 | this.creatives = [];
|
8400 | this.extensions = [];
|
8401 | };
|
8402 |
|
8403 | }),
|
8404 |
|
8405 | (function(module, exports, __webpack_require__) {
|
8406 |
|
8407 | "use strict";
|
8408 |
|
8409 |
|
8410 | Object.defineProperty(exports, "__esModule", {
|
8411 | value: true
|
8412 | });
|
8413 |
|
8414 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
8415 |
|
8416 | var AdExtension = exports.AdExtension = function AdExtension() {
|
8417 | _classCallCheck(this, AdExtension);
|
8418 |
|
8419 | this.attributes = {};
|
8420 | this.children = [];
|
8421 | };
|
8422 |
|
8423 | }),
|
8424 |
|
8425 | (function(module, exports, __webpack_require__) {
|
8426 |
|
8427 | "use strict";
|
8428 |
|
8429 |
|
8430 | Object.defineProperty(exports, "__esModule", {
|
8431 | value: true
|
8432 | });
|
8433 |
|
8434 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
8435 |
|
8436 | var AdExtensionChild = exports.AdExtensionChild = function AdExtensionChild() {
|
8437 | _classCallCheck(this, AdExtensionChild);
|
8438 |
|
8439 | this.name = null;
|
8440 | this.value = null;
|
8441 | this.attributes = {};
|
8442 | };
|
8443 |
|
8444 | }),
|
8445 |
|
8446 | (function(module, exports, __webpack_require__) {
|
8447 |
|
8448 | "use strict";
|
8449 |
|
8450 |
|
8451 | Object.defineProperty(exports, "__esModule", {
|
8452 | value: true
|
8453 | });
|
8454 | exports.parseCreativeCompanion = parseCreativeCompanion;
|
8455 |
|
8456 | var _companion_ad = __webpack_require__(25);
|
8457 |
|
8458 | var _creative_companion = __webpack_require__(49);
|
8459 |
|
8460 | var _parser_utils = __webpack_require__(3);
|
8461 |
|
8462 |
|
8463 |
|
8464 |
|
8465 |
|
8466 |
|
8467 |
|
8468 |
|
8469 |
|
8470 |
|
8471 |
|
8472 | function parseCreativeCompanion(creativeElement, creativeAttributes) {
|
8473 | var creative = new _creative_companion.CreativeCompanion(creativeAttributes);
|
8474 |
|
8475 | _parser_utils.parserUtils.childrenByName(creativeElement, 'Companion').forEach(function (companionResource) {
|
8476 | var companionAd = new _companion_ad.CompanionAd();
|
8477 | companionAd.id = companionResource.getAttribute('id') || null;
|
8478 | companionAd.width = companionResource.getAttribute('width');
|
8479 | companionAd.height = companionResource.getAttribute('height');
|
8480 | companionAd.companionClickTrackingURLTemplates = [];
|
8481 |
|
8482 | _parser_utils.parserUtils.childrenByName(companionResource, 'HTMLResource').forEach(function (htmlElement) {
|
8483 | companionAd.type = htmlElement.getAttribute('creativeType') || 'text/html';
|
8484 | companionAd.htmlResource = _parser_utils.parserUtils.parseNodeText(htmlElement);
|
8485 | });
|
8486 |
|
8487 | _parser_utils.parserUtils.childrenByName(companionResource, 'IFrameResource').forEach(function (iframeElement) {
|
8488 | companionAd.type = iframeElement.getAttribute('creativeType') || 0;
|
8489 | companionAd.iframeResource = _parser_utils.parserUtils.parseNodeText(iframeElement);
|
8490 | });
|
8491 |
|
8492 | _parser_utils.parserUtils.childrenByName(companionResource, 'StaticResource').forEach(function (staticElement) {
|
8493 | companionAd.type = staticElement.getAttribute('creativeType') || 0;
|
8494 |
|
8495 | _parser_utils.parserUtils.childrenByName(companionResource, 'AltText').forEach(function (child) {
|
8496 | companionAd.altText = _parser_utils.parserUtils.parseNodeText(child);
|
8497 | });
|
8498 |
|
8499 | companionAd.staticResource = _parser_utils.parserUtils.parseNodeText(staticElement);
|
8500 | });
|
8501 |
|
8502 | _parser_utils.parserUtils.childrenByName(companionResource, 'TrackingEvents').forEach(function (trackingEventsElement) {
|
8503 | _parser_utils.parserUtils.childrenByName(trackingEventsElement, 'Tracking').forEach(function (trackingElement) {
|
8504 | var eventName = trackingElement.getAttribute('event');
|
8505 | var trackingURLTemplate = _parser_utils.parserUtils.parseNodeText(trackingElement);
|
8506 | if (eventName && trackingURLTemplate) {
|
8507 | if (!Array.isArray(companionAd.trackingEvents[eventName])) {
|
8508 | companionAd.trackingEvents[eventName] = [];
|
8509 | }
|
8510 | companionAd.trackingEvents[eventName].push(trackingURLTemplate);
|
8511 | }
|
8512 | });
|
8513 | });
|
8514 |
|
8515 | _parser_utils.parserUtils.childrenByName(companionResource, 'CompanionClickTracking').forEach(function (clickTrackingElement) {
|
8516 | companionAd.companionClickTrackingURLTemplates.push(_parser_utils.parserUtils.parseNodeText(clickTrackingElement));
|
8517 | });
|
8518 |
|
8519 | companionAd.companionClickThroughURLTemplate = _parser_utils.parserUtils.parseNodeText(_parser_utils.parserUtils.childByName(companionResource, 'CompanionClickThrough'));
|
8520 | companionAd.companionClickTrackingURLTemplate = _parser_utils.parserUtils.parseNodeText(_parser_utils.parserUtils.childByName(companionResource, 'CompanionClickTracking'));
|
8521 | creative.variations.push(companionAd);
|
8522 | });
|
8523 |
|
8524 | return creative;
|
8525 | }
|
8526 |
|
8527 | }),
|
8528 |
|
8529 | (function(module, exports, __webpack_require__) {
|
8530 |
|
8531 | "use strict";
|
8532 |
|
8533 |
|
8534 | Object.defineProperty(exports, "__esModule", {
|
8535 | value: true
|
8536 | });
|
8537 | exports.CreativeCompanion = undefined;
|
8538 |
|
8539 | var _creative = __webpack_require__(11);
|
8540 |
|
8541 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
8542 |
|
8543 | 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; }
|
8544 |
|
8545 | 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; }
|
8546 |
|
8547 | var CreativeCompanion = exports.CreativeCompanion = function (_Creative) {
|
8548 | _inherits(CreativeCompanion, _Creative);
|
8549 |
|
8550 | function CreativeCompanion() {
|
8551 | var creativeAttributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
8552 |
|
8553 | _classCallCheck(this, CreativeCompanion);
|
8554 |
|
8555 | var _this = _possibleConstructorReturn(this, (CreativeCompanion.__proto__ || Object.getPrototypeOf(CreativeCompanion)).call(this, creativeAttributes));
|
8556 |
|
8557 | _this.type = 'companion';
|
8558 | _this.variations = [];
|
8559 | return _this;
|
8560 | }
|
8561 |
|
8562 | return CreativeCompanion;
|
8563 | }(_creative.Creative);
|
8564 |
|
8565 | }),
|
8566 |
|
8567 | (function(module, exports, __webpack_require__) {
|
8568 |
|
8569 | "use strict";
|
8570 |
|
8571 |
|
8572 | Object.defineProperty(exports, "__esModule", {
|
8573 | value: true
|
8574 | });
|
8575 | exports.parseCreativeLinear = parseCreativeLinear;
|
8576 |
|
8577 | var _creative_linear = __webpack_require__(26);
|
8578 |
|
8579 | var _icon = __webpack_require__(51);
|
8580 |
|
8581 | var _media_file = __webpack_require__(52);
|
8582 |
|
8583 | var _parser_utils = __webpack_require__(3);
|
8584 |
|
8585 |
|
8586 |
|
8587 |
|
8588 |
|
8589 |
|
8590 |
|
8591 |
|
8592 |
|
8593 |
|
8594 |
|
8595 | function parseCreativeLinear(creativeElement, creativeAttributes) {
|
8596 | var offset = void 0;
|
8597 | var creative = new _creative_linear.CreativeLinear(creativeAttributes);
|
8598 |
|
8599 | creative.duration = _parser_utils.parserUtils.parseDuration(_parser_utils.parserUtils.parseNodeText(_parser_utils.parserUtils.childByName(creativeElement, 'Duration')));
|
8600 | var skipOffset = creativeElement.getAttribute('skipoffset');
|
8601 |
|
8602 | if (typeof skipOffset === 'undefined' || skipOffset === null) {
|
8603 | creative.skipDelay = null;
|
8604 | } else if (skipOffset.charAt(skipOffset.length - 1) === '%' && creative.duration !== -1) {
|
8605 | var percent = parseInt(skipOffset, 10);
|
8606 | creative.skipDelay = creative.duration * (percent / 100);
|
8607 | } else {
|
8608 | creative.skipDelay = _parser_utils.parserUtils.parseDuration(skipOffset);
|
8609 | }
|
8610 |
|
8611 | var videoClicksElement = _parser_utils.parserUtils.childByName(creativeElement, 'VideoClicks');
|
8612 | if (videoClicksElement) {
|
8613 | creative.videoClickThroughURLTemplate = _parser_utils.parserUtils.parseNodeText(_parser_utils.parserUtils.childByName(videoClicksElement, 'ClickThrough'));
|
8614 |
|
8615 | _parser_utils.parserUtils.childrenByName(videoClicksElement, 'ClickTracking').forEach(function (clickTrackingElement) {
|
8616 | creative.videoClickTrackingURLTemplates.push(_parser_utils.parserUtils.parseNodeText(clickTrackingElement));
|
8617 | });
|
8618 |
|
8619 | _parser_utils.parserUtils.childrenByName(videoClicksElement, 'CustomClick').forEach(function (customClickElement) {
|
8620 | creative.videoCustomClickURLTemplates.push(_parser_utils.parserUtils.parseNodeText(customClickElement));
|
8621 | });
|
8622 | }
|
8623 |
|
8624 | var adParamsElement = _parser_utils.parserUtils.childByName(creativeElement, 'AdParameters');
|
8625 | if (adParamsElement) {
|
8626 | creative.adParameters = _parser_utils.parserUtils.parseNodeText(adParamsElement);
|
8627 | }
|
8628 |
|
8629 | _parser_utils.parserUtils.childrenByName(creativeElement, 'TrackingEvents').forEach(function (trackingEventsElement) {
|
8630 | _parser_utils.parserUtils.childrenByName(trackingEventsElement, 'Tracking').forEach(function (trackingElement) {
|
8631 | var eventName = trackingElement.getAttribute('event');
|
8632 | var trackingURLTemplate = _parser_utils.parserUtils.parseNodeText(trackingElement);
|
8633 | if (eventName && trackingURLTemplate) {
|
8634 | if (eventName === 'progress') {
|
8635 | offset = trackingElement.getAttribute('offset');
|
8636 | if (!offset) {
|
8637 | return;
|
8638 | }
|
8639 | if (offset.charAt(offset.length - 1) === '%') {
|
8640 | eventName = 'progress-' + offset;
|
8641 | } else {
|
8642 | eventName = 'progress-' + Math.round(_parser_utils.parserUtils.parseDuration(offset));
|
8643 | }
|
8644 | }
|
8645 |
|
8646 | if (!Array.isArray(creative.trackingEvents[eventName])) {
|
8647 | creative.trackingEvents[eventName] = [];
|
8648 | }
|
8649 | creative.trackingEvents[eventName].push(trackingURLTemplate);
|
8650 | }
|
8651 | });
|
8652 | });
|
8653 |
|
8654 | _parser_utils.parserUtils.childrenByName(creativeElement, 'MediaFiles').forEach(function (mediaFilesElement) {
|
8655 | _parser_utils.parserUtils.childrenByName(mediaFilesElement, 'MediaFile').forEach(function (mediaFileElement) {
|
8656 | var mediaFile = new _media_file.MediaFile();
|
8657 | mediaFile.id = mediaFileElement.getAttribute('id');
|
8658 | mediaFile.fileURL = _parser_utils.parserUtils.parseNodeText(mediaFileElement);
|
8659 | mediaFile.deliveryType = mediaFileElement.getAttribute('delivery');
|
8660 | mediaFile.codec = mediaFileElement.getAttribute('codec');
|
8661 | mediaFile.mimeType = mediaFileElement.getAttribute('type');
|
8662 | mediaFile.apiFramework = mediaFileElement.getAttribute('apiFramework');
|
8663 | mediaFile.bitrate = parseInt(mediaFileElement.getAttribute('bitrate') || 0);
|
8664 | mediaFile.minBitrate = parseInt(mediaFileElement.getAttribute('minBitrate') || 0);
|
8665 | mediaFile.maxBitrate = parseInt(mediaFileElement.getAttribute('maxBitrate') || 0);
|
8666 | mediaFile.width = parseInt(mediaFileElement.getAttribute('width') || 0);
|
8667 | mediaFile.height = parseInt(mediaFileElement.getAttribute('height') || 0);
|
8668 |
|
8669 | var scalable = mediaFileElement.getAttribute('scalable');
|
8670 | if (scalable && typeof scalable === 'string') {
|
8671 | scalable = scalable.toLowerCase();
|
8672 | if (scalable === 'true') {
|
8673 | mediaFile.scalable = true;
|
8674 | } else if (scalable === 'false') {
|
8675 | mediaFile.scalable = false;
|
8676 | }
|
8677 | }
|
8678 |
|
8679 | var maintainAspectRatio = mediaFileElement.getAttribute('maintainAspectRatio');
|
8680 | if (maintainAspectRatio && typeof maintainAspectRatio === 'string') {
|
8681 | maintainAspectRatio = maintainAspectRatio.toLowerCase();
|
8682 | if (maintainAspectRatio === 'true') {
|
8683 | mediaFile.maintainAspectRatio = true;
|
8684 | } else if (maintainAspectRatio === 'false') {
|
8685 | mediaFile.maintainAspectRatio = false;
|
8686 | }
|
8687 | }
|
8688 |
|
8689 | creative.mediaFiles.push(mediaFile);
|
8690 | });
|
8691 | });
|
8692 |
|
8693 | var iconsElement = _parser_utils.parserUtils.childByName(creativeElement, 'Icons');
|
8694 | if (iconsElement) {
|
8695 | _parser_utils.parserUtils.childrenByName(iconsElement, 'Icon').forEach(function (iconElement) {
|
8696 | var icon = new _icon.Icon();
|
8697 | icon.program = iconElement.getAttribute('program');
|
8698 | icon.height = parseInt(iconElement.getAttribute('height') || 0);
|
8699 | icon.width = parseInt(iconElement.getAttribute('width') || 0);
|
8700 | icon.xPosition = parseXPosition(iconElement.getAttribute('xPosition'));
|
8701 | icon.yPosition = parseYPosition(iconElement.getAttribute('yPosition'));
|
8702 | icon.apiFramework = iconElement.getAttribute('apiFramework');
|
8703 | icon.offset = _parser_utils.parserUtils.parseDuration(iconElement.getAttribute('offset'));
|
8704 | icon.duration = _parser_utils.parserUtils.parseDuration(iconElement.getAttribute('duration'));
|
8705 |
|
8706 | _parser_utils.parserUtils.childrenByName(iconElement, 'HTMLResource').forEach(function (htmlElement) {
|
8707 | icon.type = htmlElement.getAttribute('creativeType') || 'text/html';
|
8708 | icon.htmlResource = _parser_utils.parserUtils.parseNodeText(htmlElement);
|
8709 | });
|
8710 |
|
8711 | _parser_utils.parserUtils.childrenByName(iconElement, 'IFrameResource').forEach(function (iframeElement) {
|
8712 | icon.type = iframeElement.getAttribute('creativeType') || 0;
|
8713 | icon.iframeResource = _parser_utils.parserUtils.parseNodeText(iframeElement);
|
8714 | });
|
8715 |
|
8716 | _parser_utils.parserUtils.childrenByName(iconElement, 'StaticResource').forEach(function (staticElement) {
|
8717 | icon.type = staticElement.getAttribute('creativeType') || 0;
|
8718 | icon.staticResource = _parser_utils.parserUtils.parseNodeText(staticElement);
|
8719 | });
|
8720 |
|
8721 | var iconClicksElement = _parser_utils.parserUtils.childByName(iconElement, 'IconClicks');
|
8722 | if (iconClicksElement) {
|
8723 | icon.iconClickThroughURLTemplate = _parser_utils.parserUtils.parseNodeText(_parser_utils.parserUtils.childByName(iconClicksElement, 'IconClickThrough'));
|
8724 | _parser_utils.parserUtils.childrenByName(iconClicksElement, 'IconClickTracking').forEach(function (iconClickTrackingElement) {
|
8725 | icon.iconClickTrackingURLTemplates.push(_parser_utils.parserUtils.parseNodeText(iconClickTrackingElement));
|
8726 | });
|
8727 | }
|
8728 |
|
8729 | icon.iconViewTrackingURLTemplate = _parser_utils.parserUtils.parseNodeText(_parser_utils.parserUtils.childByName(iconElement, 'IconViewTracking'));
|
8730 |
|
8731 | creative.icons.push(icon);
|
8732 | });
|
8733 | }
|
8734 |
|
8735 | return creative;
|
8736 | }
|
8737 |
|
8738 |
|
8739 |
|
8740 |
|
8741 |
|
8742 |
|
8743 | function parseXPosition(xPosition) {
|
8744 | if (['left', 'right'].indexOf(xPosition) !== -1) {
|
8745 | return xPosition;
|
8746 | }
|
8747 |
|
8748 | return parseInt(xPosition || 0);
|
8749 | }
|
8750 |
|
8751 |
|
8752 |
|
8753 |
|
8754 |
|
8755 |
|
8756 | function parseYPosition(yPosition) {
|
8757 | if (['top', 'bottom'].indexOf(yPosition) !== -1) {
|
8758 | return yPosition;
|
8759 | }
|
8760 |
|
8761 | return parseInt(yPosition || 0);
|
8762 | }
|
8763 |
|
8764 | }),
|
8765 |
|
8766 | (function(module, exports, __webpack_require__) {
|
8767 |
|
8768 | "use strict";
|
8769 |
|
8770 |
|
8771 | Object.defineProperty(exports, "__esModule", {
|
8772 | value: true
|
8773 | });
|
8774 |
|
8775 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
8776 |
|
8777 | var Icon = exports.Icon = function Icon() {
|
8778 | _classCallCheck(this, Icon);
|
8779 |
|
8780 | this.program = null;
|
8781 | this.height = 0;
|
8782 | this.width = 0;
|
8783 | this.xPosition = 0;
|
8784 | this.yPosition = 0;
|
8785 | this.apiFramework = null;
|
8786 | this.offset = null;
|
8787 | this.duration = 0;
|
8788 | this.type = null;
|
8789 | this.staticResource = null;
|
8790 | this.htmlResource = null;
|
8791 | this.iframeResource = null;
|
8792 | this.iconClickThroughURLTemplate = null;
|
8793 | this.iconClickTrackingURLTemplates = [];
|
8794 | this.iconViewTrackingURLTemplate = null;
|
8795 | };
|
8796 |
|
8797 | }),
|
8798 |
|
8799 | (function(module, exports, __webpack_require__) {
|
8800 |
|
8801 | "use strict";
|
8802 |
|
8803 |
|
8804 | Object.defineProperty(exports, "__esModule", {
|
8805 | value: true
|
8806 | });
|
8807 |
|
8808 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
8809 |
|
8810 | var MediaFile = exports.MediaFile = function MediaFile() {
|
8811 | _classCallCheck(this, MediaFile);
|
8812 |
|
8813 | this.id = null;
|
8814 | this.fileURL = null;
|
8815 | this.deliveryType = 'progressive';
|
8816 | this.mimeType = null;
|
8817 | this.codec = null;
|
8818 | this.bitrate = 0;
|
8819 | this.minBitrate = 0;
|
8820 | this.maxBitrate = 0;
|
8821 | this.width = 0;
|
8822 | this.height = 0;
|
8823 | this.apiFramework = null;
|
8824 | this.scalable = null;
|
8825 | this.maintainAspectRatio = null;
|
8826 | };
|
8827 |
|
8828 | }),
|
8829 |
|
8830 | (function(module, exports, __webpack_require__) {
|
8831 |
|
8832 | "use strict";
|
8833 |
|
8834 |
|
8835 | Object.defineProperty(exports, "__esModule", {
|
8836 | value: true
|
8837 | });
|
8838 | exports.parseCreativeNonLinear = parseCreativeNonLinear;
|
8839 |
|
8840 | var _creative_non_linear = __webpack_require__(54);
|
8841 |
|
8842 | var _non_linear_ad = __webpack_require__(27);
|
8843 |
|
8844 | var _parser_utils = __webpack_require__(3);
|
8845 |
|
8846 |
|
8847 |
|
8848 |
|
8849 |
|
8850 |
|
8851 |
|
8852 |
|
8853 |
|
8854 |
|
8855 |
|
8856 | function parseCreativeNonLinear(creativeElement, creativeAttributes) {
|
8857 | var creative = new _creative_non_linear.CreativeNonLinear(creativeAttributes);
|
8858 |
|
8859 | _parser_utils.parserUtils.childrenByName(creativeElement, 'TrackingEvents').forEach(function (trackingEventsElement) {
|
8860 | var eventName = void 0,
|
8861 | trackingURLTemplate = void 0;
|
8862 | _parser_utils.parserUtils.childrenByName(trackingEventsElement, 'Tracking').forEach(function (trackingElement) {
|
8863 | eventName = trackingElement.getAttribute('event');
|
8864 | trackingURLTemplate = _parser_utils.parserUtils.parseNodeText(trackingElement);
|
8865 |
|
8866 | if (eventName && trackingURLTemplate) {
|
8867 | if (!Array.isArray(creative.trackingEvents[eventName])) {
|
8868 | creative.trackingEvents[eventName] = [];
|
8869 | }
|
8870 | creative.trackingEvents[eventName].push(trackingURLTemplate);
|
8871 | }
|
8872 | });
|
8873 | });
|
8874 |
|
8875 | _parser_utils.parserUtils.childrenByName(creativeElement, 'NonLinear').forEach(function (nonlinearResource) {
|
8876 | var nonlinearAd = new _non_linear_ad.NonLinearAd();
|
8877 | nonlinearAd.id = nonlinearResource.getAttribute('id') || null;
|
8878 | nonlinearAd.width = nonlinearResource.getAttribute('width');
|
8879 | nonlinearAd.height = nonlinearResource.getAttribute('height');
|
8880 | nonlinearAd.expandedWidth = nonlinearResource.getAttribute('expandedWidth');
|
8881 | nonlinearAd.expandedHeight = nonlinearResource.getAttribute('expandedHeight');
|
8882 | nonlinearAd.scalable = _parser_utils.parserUtils.parseBoolean(nonlinearResource.getAttribute('scalable'));
|
8883 | nonlinearAd.maintainAspectRatio = _parser_utils.parserUtils.parseBoolean(nonlinearResource.getAttribute('maintainAspectRatio'));
|
8884 | nonlinearAd.minSuggestedDuration = _parser_utils.parserUtils.parseDuration(nonlinearResource.getAttribute('minSuggestedDuration'));
|
8885 | nonlinearAd.apiFramework = nonlinearResource.getAttribute('apiFramework');
|
8886 |
|
8887 | _parser_utils.parserUtils.childrenByName(nonlinearResource, 'HTMLResource').forEach(function (htmlElement) {
|
8888 | nonlinearAd.type = htmlElement.getAttribute('creativeType') || 'text/html';
|
8889 | nonlinearAd.htmlResource = _parser_utils.parserUtils.parseNodeText(htmlElement);
|
8890 | });
|
8891 |
|
8892 | _parser_utils.parserUtils.childrenByName(nonlinearResource, 'IFrameResource').forEach(function (iframeElement) {
|
8893 | nonlinearAd.type = iframeElement.getAttribute('creativeType') || 0;
|
8894 | nonlinearAd.iframeResource = _parser_utils.parserUtils.parseNodeText(iframeElement);
|
8895 | });
|
8896 |
|
8897 | _parser_utils.parserUtils.childrenByName(nonlinearResource, 'StaticResource').forEach(function (staticElement) {
|
8898 | nonlinearAd.type = staticElement.getAttribute('creativeType') || 0;
|
8899 | nonlinearAd.staticResource = _parser_utils.parserUtils.parseNodeText(staticElement);
|
8900 | });
|
8901 |
|
8902 | var adParamsElement = _parser_utils.parserUtils.childByName(nonlinearResource, 'AdParameters');
|
8903 | if (adParamsElement) {
|
8904 | nonlinearAd.adParameters = _parser_utils.parserUtils.parseNodeText(adParamsElement);
|
8905 | }
|
8906 |
|
8907 | nonlinearAd.nonlinearClickThroughURLTemplate = _parser_utils.parserUtils.parseNodeText(_parser_utils.parserUtils.childByName(nonlinearResource, 'NonLinearClickThrough'));
|
8908 | _parser_utils.parserUtils.childrenByName(nonlinearResource, 'NonLinearClickTracking').forEach(function (clickTrackingElement) {
|
8909 | nonlinearAd.nonlinearClickTrackingURLTemplates.push(_parser_utils.parserUtils.parseNodeText(clickTrackingElement));
|
8910 | });
|
8911 |
|
8912 | creative.variations.push(nonlinearAd);
|
8913 | });
|
8914 |
|
8915 | return creative;
|
8916 | }
|
8917 |
|
8918 | }),
|
8919 |
|
8920 | (function(module, exports, __webpack_require__) {
|
8921 |
|
8922 | "use strict";
|
8923 |
|
8924 |
|
8925 | Object.defineProperty(exports, "__esModule", {
|
8926 | value: true
|
8927 | });
|
8928 | exports.CreativeNonLinear = undefined;
|
8929 |
|
8930 | var _creative = __webpack_require__(11);
|
8931 |
|
8932 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
8933 |
|
8934 | 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; }
|
8935 |
|
8936 | 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; }
|
8937 |
|
8938 | var CreativeNonLinear = exports.CreativeNonLinear = function (_Creative) {
|
8939 | _inherits(CreativeNonLinear, _Creative);
|
8940 |
|
8941 | function CreativeNonLinear() {
|
8942 | var creativeAttributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
8943 |
|
8944 | _classCallCheck(this, CreativeNonLinear);
|
8945 |
|
8946 | var _this = _possibleConstructorReturn(this, (CreativeNonLinear.__proto__ || Object.getPrototypeOf(CreativeNonLinear)).call(this, creativeAttributes));
|
8947 |
|
8948 | _this.type = 'nonlinear';
|
8949 | _this.variations = [];
|
8950 | return _this;
|
8951 | }
|
8952 |
|
8953 | return CreativeNonLinear;
|
8954 | }(_creative.Creative);
|
8955 |
|
8956 | }),
|
8957 |
|
8958 | (function(module, exports, __webpack_require__) {
|
8959 |
|
8960 | "use strict";
|
8961 |
|
8962 |
|
8963 | Object.defineProperty(exports, "__esModule", {
|
8964 | value: true
|
8965 | });
|
8966 | exports.urlHandler = undefined;
|
8967 |
|
8968 | var _flash_url_handler = __webpack_require__(56);
|
8969 |
|
8970 | var _mock_node_url_handler = __webpack_require__(57);
|
8971 |
|
8972 | var _xhr_url_handler = __webpack_require__(58);
|
8973 |
|
8974 | function get(url, options, cb) {
|
8975 |
|
8976 | if (!cb) {
|
8977 | if (typeof options === 'function') {
|
8978 | cb = options;
|
8979 | }
|
8980 | options = {};
|
8981 | }
|
8982 |
|
8983 | if (typeof window === 'undefined' || window === null) {
|
8984 | return _mock_node_url_handler.nodeURLHandler.get(url, options, cb);
|
8985 | } else if (_xhr_url_handler.XHRURLHandler.supported()) {
|
8986 | return _xhr_url_handler.XHRURLHandler.get(url, options, cb);
|
8987 | } else if (_flash_url_handler.flashURLHandler.supported()) {
|
8988 | return _flash_url_handler.flashURLHandler.get(url, options, cb);
|
8989 | }
|
8990 | return cb(new Error('Current context is not supported by any of the default URLHandlers. Please provide a custom URLHandler'));
|
8991 | }
|
8992 |
|
8993 | var urlHandler = exports.urlHandler = {
|
8994 | get: get
|
8995 | };
|
8996 |
|
8997 | /***/ }),
|
8998 | /* 56 */
|
8999 | /***/ (function(module, exports, __webpack_require__) {
|
9000 |
|
9001 | "use strict";
|
9002 |
|
9003 |
|
9004 | Object.defineProperty(exports, "__esModule", {
|
9005 | value: true
|
9006 | });
|
9007 | function xdr() {
|
9008 | var request = void 0;
|
9009 | if (window.XDomainRequest) {
|
9010 |
|
9011 | request = new XDomainRequest();
|
9012 | }
|
9013 | return request;
|
9014 | }
|
9015 |
|
9016 | function supported() {
|
9017 | return !!xdr();
|
9018 | }
|
9019 |
|
9020 | function get(url, options, cb) {
|
9021 | var xmlDocument = typeof window.ActiveXObject === 'function' ? new window.ActiveXObject('Microsoft.XMLDOM') : undefined;
|
9022 |
|
9023 | if (xmlDocument) {
|
9024 | xmlDocument.async = false;
|
9025 | } else {
|
9026 | return cb(new Error('FlashURLHandler: Microsoft.XMLDOM format not supported'));
|
9027 | }
|
9028 |
|
9029 | var request = xdr();
|
9030 | request.open('GET', url);
|
9031 | request.timeout = options.timeout || 0;
|
9032 | request.withCredentials = options.withCredentials || false;
|
9033 | request.send();
|
9034 | request.onprogress = function () {};
|
9035 |
|
9036 | request.onload = function () {
|
9037 | xmlDocument.loadXML(request.responseText);
|
9038 | cb(null, xmlDocument);
|
9039 | };
|
9040 | }
|
9041 |
|
9042 | var flashURLHandler = exports.flashURLHandler = {
|
9043 | get: get,
|
9044 | supported: supported
|
9045 | };
|
9046 |
|
9047 | /***/ }),
|
9048 | /* 57 */
|
9049 | /***/ (function(module, exports, __webpack_require__) {
|
9050 |
|
9051 | "use strict";
|
9052 |
|
9053 |
|
9054 | Object.defineProperty(exports, "__esModule", {
|
9055 | value: true
|
9056 | });
|
9057 |
|
9058 |
|
9059 |
|
9060 | function get(url, options, cb) {
|
9061 | cb(new Error('Please bundle the library for node to use the node urlHandler'));
|
9062 | }
|
9063 |
|
9064 | var nodeURLHandler = exports.nodeURLHandler = {
|
9065 | get: get
|
9066 | };
|
9067 |
|
9068 | /***/ }),
|
9069 | /* 58 */
|
9070 | /***/ (function(module, exports, __webpack_require__) {
|
9071 |
|
9072 | "use strict";
|
9073 |
|
9074 |
|
9075 | Object.defineProperty(exports, "__esModule", {
|
9076 | value: true
|
9077 | });
|
9078 | function xhr() {
|
9079 | try {
|
9080 | var request = new window.XMLHttpRequest();
|
9081 | if ('withCredentials' in request) {
|
9082 |
|
9083 | return request;
|
9084 | }
|
9085 | return null;
|
9086 | } catch (err) {
|
9087 | return null;
|
9088 | }
|
9089 | }
|
9090 |
|
9091 | function supported() {
|
9092 | return !!xhr();
|
9093 | }
|
9094 |
|
9095 | function get(url, options, cb) {
|
9096 | if (window.location.protocol === 'https:' && url.indexOf('http://') === 0) {
|
9097 | return cb(new Error('XHRURLHandler: Cannot go from HTTPS to HTTP.'));
|
9098 | }
|
9099 |
|
9100 | try {
|
9101 | var request = xhr();
|
9102 |
|
9103 | request.open('GET', url);
|
9104 | request.timeout = options.timeout || 0;
|
9105 | request.withCredentials = options.withCredentials || false;
|
9106 | request.overrideMimeType && request.overrideMimeType('text/xml');
|
9107 | request.onreadystatechange = function () {
|
9108 | if (request.readyState === 4) {
|
9109 | if (request.status === 200) {
|
9110 | cb(null, request.responseXML);
|
9111 | } else {
|
9112 | cb(new Error('XHRURLHandler: ' + request.statusText));
|
9113 | }
|
9114 | }
|
9115 | };
|
9116 | request.send();
|
9117 | } catch (error) {
|
9118 | cb(new Error('XHRURLHandler: Unexpected error'));
|
9119 | }
|
9120 | }
|
9121 |
|
9122 | var XHRURLHandler = exports.XHRURLHandler = {
|
9123 | get: get,
|
9124 | supported: supported
|
9125 | };
|
9126 |
|
9127 | /***/ }),
|
9128 | /* 59 */
|
9129 | /***/ (function(module, exports, __webpack_require__) {
|
9130 |
|
9131 | "use strict";
|
9132 |
|
9133 |
|
9134 | Object.defineProperty(exports, "__esModule", {
|
9135 | value: true
|
9136 | });
|
9137 |
|
9138 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
9139 |
|
9140 | var VASTResponse = exports.VASTResponse = function VASTResponse() {
|
9141 | _classCallCheck(this, VASTResponse);
|
9142 |
|
9143 | this.ads = [];
|
9144 | this.errorURLTemplates = [];
|
9145 | };
|
9146 |
|
9147 | }),
|
9148 |
|
9149 | (function(module, exports, __webpack_require__) {
|
9150 |
|
9151 | "use strict";
|
9152 |
|
9153 |
|
9154 | Object.defineProperty(exports, "__esModule", {
|
9155 | value: true
|
9156 | });
|
9157 | exports.VASTClient = undefined;
|
9158 |
|
9159 | 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; }; }();
|
9160 |
|
9161 | var _storage = __webpack_require__(61);
|
9162 |
|
9163 | var _vast_parser = __webpack_require__(24);
|
9164 |
|
9165 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
9166 |
|
9167 |
|
9168 |
|
9169 |
|
9170 |
|
9171 |
|
9172 |
|
9173 | var VASTClient = exports.VASTClient = function () {
|
9174 | |
9175 |
|
9176 |
|
9177 |
|
9178 |
|
9179 |
|
9180 |
|
9181 | function VASTClient(cappingFreeLunch, cappingMinimumTimeInterval, customStorage) {
|
9182 | _classCallCheck(this, VASTClient);
|
9183 |
|
9184 | this.cappingFreeLunch = cappingFreeLunch || 0;
|
9185 | this.cappingMinimumTimeInterval = cappingMinimumTimeInterval || 0;
|
9186 | this.defaultOptions = {
|
9187 | withCredentials: false,
|
9188 | timeout: 0
|
9189 | };
|
9190 | this.vastParser = new _vast_parser.VASTParser();
|
9191 | this.storage = customStorage || new _storage.Storage();
|
9192 |
|
9193 |
|
9194 | if (this.lastSuccessfulAd === undefined) {
|
9195 | this.lastSuccessfulAd = 0;
|
9196 | }
|
9197 |
|
9198 | if (this.totalCalls === undefined) {
|
9199 | this.totalCalls = 0;
|
9200 | }
|
9201 | if (this.totalCallsTimeout === undefined) {
|
9202 | this.totalCallsTimeout = 0;
|
9203 | }
|
9204 | }
|
9205 |
|
9206 | _createClass(VASTClient, [{
|
9207 | key: 'getParser',
|
9208 | value: function getParser() {
|
9209 | return this.vastParser;
|
9210 | }
|
9211 | }, {
|
9212 | key: 'hasRemainingAds',
|
9213 |
|
9214 |
|
9215 | |
9216 |
|
9217 |
|
9218 |
|
9219 | value: function hasRemainingAds() {
|
9220 | return this.vastParser.remainingAds.length > 0;
|
9221 | }
|
9222 |
|
9223 | |
9224 |
|
9225 |
|
9226 |
|
9227 |
|
9228 |
|
9229 | }, {
|
9230 | key: 'getNextAds',
|
9231 | value: function getNextAds(all) {
|
9232 | return this.vastParser.getRemainingAds(all);
|
9233 | }
|
9234 |
|
9235 | |
9236 |
|
9237 |
|
9238 |
|
9239 |
|
9240 |
|
9241 |
|
9242 |
|
9243 | }, {
|
9244 | key: 'get',
|
9245 | value: function get(url) {
|
9246 | var _this = this;
|
9247 |
|
9248 | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
9249 |
|
9250 | var now = Date.now();
|
9251 | options = Object.assign(this.defaultOptions, options);
|
9252 |
|
9253 |
|
9254 | if (!options.hasOwnProperty('resolveAll')) {
|
9255 | options.resolveAll = false;
|
9256 | }
|
9257 |
|
9258 |
|
9259 |
|
9260 |
|
9261 | if (this.totalCallsTimeout < now) {
|
9262 | this.totalCalls = 1;
|
9263 | this.totalCallsTimeout = now + 60 * 60 * 1000;
|
9264 | } else {
|
9265 | this.totalCalls++;
|
9266 | }
|
9267 |
|
9268 | return new Promise(function (resolve, reject) {
|
9269 | if (_this.cappingFreeLunch >= _this.totalCalls) {
|
9270 | return reject(new Error('VAST call canceled \u2013 FreeLunch capping not reached yet ' + _this.totalCalls + '/' + _this.cappingFreeLunch));
|
9271 | }
|
9272 |
|
9273 | var timeSinceLastCall = now - _this.lastSuccessfulAd;
|
9274 |
|
9275 |
|
9276 |
|
9277 | if (timeSinceLastCall < 0) {
|
9278 | _this.lastSuccessfulAd = 0;
|
9279 | } else if (timeSinceLastCall < _this.cappingMinimumTimeInterval) {
|
9280 | return reject(new Error('VAST call canceled \u2013 (' + _this.cappingMinimumTimeInterval + ')ms minimum interval reached'));
|
9281 | }
|
9282 |
|
9283 | _this.vastParser.getAndParseVAST(url, options).then(function (response) {
|
9284 | return resolve(response);
|
9285 | }).catch(function (err) {
|
9286 | return reject(err);
|
9287 | });
|
9288 | });
|
9289 | }
|
9290 | }, {
|
9291 | key: 'lastSuccessfulAd',
|
9292 | get: function get() {
|
9293 | return this.storage.getItem('vast-client-last-successful-ad');
|
9294 | },
|
9295 | set: function set(value) {
|
9296 | this.storage.setItem('vast-client-last-successful-ad', value);
|
9297 | }
|
9298 | }, {
|
9299 | key: 'totalCalls',
|
9300 | get: function get() {
|
9301 | return this.storage.getItem('vast-client-total-calls');
|
9302 | },
|
9303 | set: function set(value) {
|
9304 | this.storage.setItem('vast-client-total-calls', value);
|
9305 | }
|
9306 | }, {
|
9307 | key: 'totalCallsTimeout',
|
9308 | get: function get() {
|
9309 | return this.storage.getItem('vast-client-total-calls-timeout');
|
9310 | },
|
9311 | set: function set(value) {
|
9312 | this.storage.setItem('vast-client-total-calls-timeout', value);
|
9313 | }
|
9314 | }]);
|
9315 |
|
9316 | return VASTClient;
|
9317 | }();
|
9318 |
|
9319 | }),
|
9320 |
|
9321 | (function(module, exports, __webpack_require__) {
|
9322 |
|
9323 | "use strict";
|
9324 |
|
9325 |
|
9326 | Object.defineProperty(exports, "__esModule", {
|
9327 | value: true
|
9328 | });
|
9329 |
|
9330 | 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; }; }();
|
9331 |
|
9332 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
9333 |
|
9334 | var storage = null;
|
9335 |
|
9336 |
|
9337 |
|
9338 |
|
9339 |
|
9340 |
|
9341 | var DEFAULT_STORAGE = {
|
9342 | data: {},
|
9343 | length: 0,
|
9344 | getItem: function getItem(key) {
|
9345 | return this.data[key];
|
9346 | },
|
9347 | setItem: function setItem(key, value) {
|
9348 | this.data[key] = value;
|
9349 | this.length = Object.keys(this.data).length;
|
9350 | },
|
9351 | removeItem: function removeItem(key) {
|
9352 | delete this.data[key];
|
9353 | this.length = Object.keys(this.data).length;
|
9354 | },
|
9355 | clear: function clear() {
|
9356 | this.data = {};
|
9357 | this.length = 0;
|
9358 | }
|
9359 | };
|
9360 |
|
9361 |
|
9362 |
|
9363 |
|
9364 |
|
9365 |
|
9366 |
|
9367 |
|
9368 | var Storage = exports.Storage = function () {
|
9369 | |
9370 |
|
9371 |
|
9372 |
|
9373 | function Storage() {
|
9374 | _classCallCheck(this, Storage);
|
9375 |
|
9376 | this.storage = this.initStorage();
|
9377 | }
|
9378 |
|
9379 | |
9380 |
|
9381 |
|
9382 |
|
9383 |
|
9384 |
|
9385 | _createClass(Storage, [{
|
9386 | key: 'initStorage',
|
9387 | value: function initStorage() {
|
9388 | if (storage) {
|
9389 | return storage;
|
9390 | }
|
9391 |
|
9392 | try {
|
9393 | storage = typeof window !== 'undefined' && window !== null ? window.localStorage || window.sessionStorage : null;
|
9394 | } catch (storageError) {
|
9395 | storage = null;
|
9396 | }
|
9397 |
|
9398 | if (!storage || this.isStorageDisabled(storage)) {
|
9399 | storage = DEFAULT_STORAGE;
|
9400 | storage.clear();
|
9401 | }
|
9402 |
|
9403 | return storage;
|
9404 | }
|
9405 |
|
9406 | |
9407 |
|
9408 |
|
9409 |
|
9410 |
|
9411 |
|
9412 |
|
9413 |
|
9414 | }, {
|
9415 | key: 'isStorageDisabled',
|
9416 | value: function isStorageDisabled(testStorage) {
|
9417 | var testValue = '__VASTStorage__';
|
9418 |
|
9419 | try {
|
9420 | testStorage.setItem(testValue, testValue);
|
9421 | if (testStorage.getItem(testValue) !== testValue) {
|
9422 | testStorage.removeItem(testValue);
|
9423 | return true;
|
9424 | }
|
9425 | } catch (e) {
|
9426 | return true;
|
9427 | }
|
9428 |
|
9429 | testStorage.removeItem(testValue);
|
9430 | return false;
|
9431 | }
|
9432 |
|
9433 | |
9434 |
|
9435 |
|
9436 |
|
9437 |
|
9438 |
|
9439 | }, {
|
9440 | key: 'getItem',
|
9441 | value: function getItem(key) {
|
9442 | return this.storage.getItem(key);
|
9443 | }
|
9444 |
|
9445 | |
9446 |
|
9447 |
|
9448 |
|
9449 |
|
9450 |
|
9451 |
|
9452 | }, {
|
9453 | key: 'setItem',
|
9454 | value: function setItem(key, value) {
|
9455 | return this.storage.setItem(key, value);
|
9456 | }
|
9457 |
|
9458 | |
9459 |
|
9460 |
|
9461 |
|
9462 |
|
9463 |
|
9464 | }, {
|
9465 | key: 'removeItem',
|
9466 | value: function removeItem(key) {
|
9467 | return this.storage.removeItem(key);
|
9468 | }
|
9469 |
|
9470 | |
9471 |
|
9472 |
|
9473 |
|
9474 | }, {
|
9475 | key: 'clear',
|
9476 | value: function clear() {
|
9477 | return this.storage.clear();
|
9478 | }
|
9479 | }]);
|
9480 |
|
9481 | return Storage;
|
9482 | }();
|
9483 |
|
9484 | }),
|
9485 |
|
9486 | (function(module, exports, __webpack_require__) {
|
9487 |
|
9488 | "use strict";
|
9489 |
|
9490 |
|
9491 | Object.defineProperty(exports, "__esModule", {
|
9492 | value: true
|
9493 | });
|
9494 | exports.VASTTracker = undefined;
|
9495 |
|
9496 | 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; }; }();
|
9497 |
|
9498 | var _companion_ad = __webpack_require__(25);
|
9499 |
|
9500 | var _creative_linear = __webpack_require__(26);
|
9501 |
|
9502 | var _events = __webpack_require__(28);
|
9503 |
|
9504 | var _non_linear_ad = __webpack_require__(27);
|
9505 |
|
9506 | var _util = __webpack_require__(12);
|
9507 |
|
9508 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
9509 |
|
9510 | 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; }
|
9511 |
|
9512 | 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; }
|
9513 |
|
9514 |
|
9515 |
|
9516 |
|
9517 |
|
9518 |
|
9519 | var DEFAULT_SKIP_DELAY = -1;
|
9520 |
|
9521 |
|
9522 |
|
9523 |
|
9524 |
|
9525 |
|
9526 |
|
9527 |
|
9528 |
|
9529 | var VASTTracker = exports.VASTTracker = function (_EventEmitter) {
|
9530 | _inherits(VASTTracker, _EventEmitter);
|
9531 |
|
9532 | |
9533 |
|
9534 |
|
9535 |
|
9536 |
|
9537 |
|
9538 |
|
9539 |
|
9540 |
|
9541 | function VASTTracker(client, ad, creative) {
|
9542 | var variation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
9543 |
|
9544 | _classCallCheck(this, VASTTracker);
|
9545 |
|
9546 | var _this = _possibleConstructorReturn(this, (VASTTracker.__proto__ || Object.getPrototypeOf(VASTTracker)).call(this));
|
9547 |
|
9548 | _this.ad = ad;
|
9549 | _this.creative = creative;
|
9550 | _this.variation = variation;
|
9551 | _this.muted = false;
|
9552 | _this.impressed = false;
|
9553 | _this.skippable = false;
|
9554 | _this.trackingEvents = {};
|
9555 |
|
9556 | _this._alreadyTriggeredQuartiles = {};
|
9557 |
|
9558 |
|
9559 | _this.emitAlwaysEvents = ['creativeView', 'start', 'firstQuartile', 'midpoint', 'thirdQuartile', 'complete', 'resume', 'pause', 'rewind', 'skip', 'closeLinear', 'close'];
|
9560 |
|
9561 |
|
9562 | for (var eventName in _this.creative.trackingEvents) {
|
9563 | var events = _this.creative.trackingEvents[eventName];
|
9564 | _this.trackingEvents[eventName] = events.slice(0);
|
9565 | }
|
9566 |
|
9567 |
|
9568 |
|
9569 |
|
9570 | if (_this.creative instanceof _creative_linear.CreativeLinear) {
|
9571 | _this._initLinearTracking();
|
9572 | } else {
|
9573 | _this._initVariationTracking();
|
9574 | }
|
9575 |
|
9576 |
|
9577 |
|
9578 | if (client) {
|
9579 | _this.on('start', function () {
|
9580 | client.lastSuccessfulAd = Date.now();
|
9581 | });
|
9582 | }
|
9583 | return _this;
|
9584 | }
|
9585 |
|
9586 | |
9587 |
|
9588 |
|
9589 |
|
9590 |
|
9591 |
|
9592 |
|
9593 | _createClass(VASTTracker, [{
|
9594 | key: '_initLinearTracking',
|
9595 | value: function _initLinearTracking() {
|
9596 | this.linear = true;
|
9597 | this.skipDelay = this.creative.skipDelay;
|
9598 |
|
9599 | this.setDuration(this.creative.duration);
|
9600 |
|
9601 | this.clickThroughURLTemplate = this.creative.videoClickThroughURLTemplate;
|
9602 | this.clickTrackingURLTemplates = this.creative.videoClickTrackingURLTemplates;
|
9603 | }
|
9604 |
|
9605 | |
9606 |
|
9607 |
|
9608 |
|
9609 |
|
9610 |
|
9611 |
|
9612 | }, {
|
9613 | key: '_initVariationTracking',
|
9614 | value: function _initVariationTracking() {
|
9615 | this.linear = false;
|
9616 | this.skipDelay = DEFAULT_SKIP_DELAY;
|
9617 |
|
9618 |
|
9619 | if (!this.variation) {
|
9620 | return;
|
9621 | }
|
9622 |
|
9623 |
|
9624 | for (var eventName in this.variation.trackingEvents) {
|
9625 | var events = this.variation.trackingEvents[eventName];
|
9626 |
|
9627 |
|
9628 |
|
9629 | if (this.trackingEvents[eventName]) {
|
9630 | this.trackingEvents[eventName] = this.trackingEvents[eventName].concat(events.slice(0));
|
9631 | } else {
|
9632 | this.trackingEvents[eventName] = events.slice(0);
|
9633 | }
|
9634 | }
|
9635 |
|
9636 | if (this.variation instanceof _non_linear_ad.NonLinearAd) {
|
9637 | this.clickThroughURLTemplate = this.variation.nonlinearClickThroughURLTemplate;
|
9638 | this.clickTrackingURLTemplates = this.variation.nonlinearClickTrackingURLTemplates;
|
9639 | this.setDuration(this.variation.minSuggestedDuration);
|
9640 | } else if (this.variation instanceof _companion_ad.CompanionAd) {
|
9641 | this.clickThroughURLTemplate = this.variation.companionClickThroughURLTemplate;
|
9642 | this.clickTrackingURLTemplates = this.variation.companionClickTrackingURLTemplates;
|
9643 | }
|
9644 | }
|
9645 |
|
9646 | |
9647 |
|
9648 |
|
9649 |
|
9650 |
|
9651 |
|
9652 | }, {
|
9653 | key: 'setDuration',
|
9654 | value: function setDuration(duration) {
|
9655 | this.assetDuration = duration;
|
9656 |
|
9657 | this.quartiles = {
|
9658 | firstQuartile: Math.round(25 * this.assetDuration) / 100,
|
9659 | midpoint: Math.round(50 * this.assetDuration) / 100,
|
9660 | thirdQuartile: Math.round(75 * this.assetDuration) / 100
|
9661 | };
|
9662 | }
|
9663 |
|
9664 | |
9665 |
|
9666 |
|
9667 |
|
9668 |
|
9669 |
|
9670 |
|
9671 |
|
9672 |
|
9673 |
|
9674 |
|
9675 |
|
9676 |
|
9677 |
|
9678 |
|
9679 | }, {
|
9680 | key: 'setProgress',
|
9681 | value: function setProgress(progress) {
|
9682 | var _this2 = this;
|
9683 |
|
9684 | var skipDelay = this.skipDelay || DEFAULT_SKIP_DELAY;
|
9685 |
|
9686 | if (skipDelay !== -1 && !this.skippable) {
|
9687 | if (skipDelay > progress) {
|
9688 | this.emit('skip-countdown', skipDelay - progress);
|
9689 | } else {
|
9690 | this.skippable = true;
|
9691 | this.emit('skip-countdown', 0);
|
9692 | }
|
9693 | }
|
9694 |
|
9695 | if (this.assetDuration > 0) {
|
9696 | var events = [];
|
9697 |
|
9698 | if (progress > 0) {
|
9699 | var percent = Math.round(progress / this.assetDuration * 100);
|
9700 |
|
9701 | events.push('start');
|
9702 | events.push('progress-' + percent + '%');
|
9703 | events.push('progress-' + Math.round(progress));
|
9704 |
|
9705 | for (var quartile in this.quartiles) {
|
9706 | if (this.isQuartileReached(quartile, this.quartiles[quartile], progress)) {
|
9707 | events.push(quartile);
|
9708 | this._alreadyTriggeredQuartiles[quartile] = true;
|
9709 | }
|
9710 | }
|
9711 | }
|
9712 |
|
9713 | events.forEach(function (eventName) {
|
9714 | _this2.track(eventName, true);
|
9715 | });
|
9716 |
|
9717 | if (progress < this.progress) {
|
9718 | this.track('rewind');
|
9719 | }
|
9720 | }
|
9721 |
|
9722 | this.progress = progress;
|
9723 | }
|
9724 |
|
9725 | |
9726 |
|
9727 |
|
9728 |
|
9729 |
|
9730 |
|
9731 |
|
9732 |
|
9733 |
|
9734 |
|
9735 | }, {
|
9736 | key: 'isQuartileReached',
|
9737 | value: function isQuartileReached(quartile, time, progress) {
|
9738 | var quartileReached = false;
|
9739 |
|
9740 | if (time <= progress && !this._alreadyTriggeredQuartiles[quartile]) {
|
9741 | quartileReached = true;
|
9742 | }
|
9743 | return quartileReached;
|
9744 | }
|
9745 |
|
9746 | |
9747 |
|
9748 |
|
9749 |
|
9750 |
|
9751 |
|
9752 |
|
9753 |
|
9754 | }, {
|
9755 | key: 'setMuted',
|
9756 | value: function setMuted(muted) {
|
9757 | if (this.muted !== muted) {
|
9758 | this.track(muted ? 'mute' : 'unmute');
|
9759 | }
|
9760 | this.muted = muted;
|
9761 | }
|
9762 |
|
9763 | |
9764 |
|
9765 |
|
9766 |
|
9767 |
|
9768 |
|
9769 |
|
9770 |
|
9771 | }, {
|
9772 | key: 'setPaused',
|
9773 | value: function setPaused(paused) {
|
9774 | if (this.paused !== paused) {
|
9775 | this.track(paused ? 'pause' : 'resume');
|
9776 | }
|
9777 | this.paused = paused;
|
9778 | }
|
9779 |
|
9780 | |
9781 |
|
9782 |
|
9783 |
|
9784 |
|
9785 |
|
9786 |
|
9787 |
|
9788 | }, {
|
9789 | key: 'setFullscreen',
|
9790 | value: function setFullscreen(fullscreen) {
|
9791 | if (this.fullscreen !== fullscreen) {
|
9792 | this.track(fullscreen ? 'fullscreen' : 'exitFullscreen');
|
9793 | }
|
9794 | this.fullscreen = fullscreen;
|
9795 | }
|
9796 |
|
9797 | |
9798 |
|
9799 |
|
9800 |
|
9801 |
|
9802 |
|
9803 |
|
9804 |
|
9805 | }, {
|
9806 | key: 'setExpand',
|
9807 | value: function setExpand(expanded) {
|
9808 | if (this.expanded !== expanded) {
|
9809 | this.track(expanded ? 'expand' : 'collapse');
|
9810 | }
|
9811 | this.expanded = expanded;
|
9812 | }
|
9813 |
|
9814 | |
9815 |
|
9816 |
|
9817 |
|
9818 |
|
9819 |
|
9820 |
|
9821 |
|
9822 |
|
9823 | }, {
|
9824 | key: 'setSkipDelay',
|
9825 | value: function setSkipDelay(duration) {
|
9826 | if (typeof duration === 'number') {
|
9827 | this.skipDelay = duration;
|
9828 | }
|
9829 | }
|
9830 |
|
9831 | |
9832 |
|
9833 |
|
9834 |
|
9835 |
|
9836 |
|
9837 | }, {
|
9838 | key: 'trackImpression',
|
9839 | value: function trackImpression() {
|
9840 | if (!this.impressed) {
|
9841 | this.impressed = true;
|
9842 | this.trackURLs(this.ad.impressionURLTemplates);
|
9843 | this.track('creativeView');
|
9844 | }
|
9845 | }
|
9846 |
|
9847 | |
9848 |
|
9849 |
|
9850 |
|
9851 |
|
9852 |
|
9853 |
|
9854 |
|
9855 | }, {
|
9856 | key: 'errorWithCode',
|
9857 | value: function errorWithCode(errorCode) {
|
9858 | var isCustomCode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
9859 |
|
9860 | this.trackURLs(this.ad.errorURLTemplates, { ERRORCODE: errorCode }, { isCustomCode: isCustomCode });
|
9861 | }
|
9862 |
|
9863 | |
9864 |
|
9865 |
|
9866 |
|
9867 |
|
9868 |
|
9869 |
|
9870 | }, {
|
9871 | key: 'complete',
|
9872 | value: function complete() {
|
9873 | this.track('complete');
|
9874 | }
|
9875 |
|
9876 | |
9877 |
|
9878 |
|
9879 |
|
9880 |
|
9881 |
|
9882 |
|
9883 |
|
9884 | }, {
|
9885 | key: 'close',
|
9886 | value: function close() {
|
9887 | this.track(this.linear ? 'closeLinear' : 'close');
|
9888 | }
|
9889 |
|
9890 | |
9891 |
|
9892 |
|
9893 |
|
9894 |
|
9895 |
|
9896 | }, {
|
9897 | key: 'skip',
|
9898 | value: function skip() {
|
9899 | this.track('skip');
|
9900 | }
|
9901 |
|
9902 | |
9903 |
|
9904 |
|
9905 |
|
9906 |
|
9907 |
|
9908 |
|
9909 |
|
9910 |
|
9911 | }, {
|
9912 | key: 'click',
|
9913 | value: function click() {
|
9914 | var fallbackClickThroughURL = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
9915 |
|
9916 | if (this.clickTrackingURLTemplates && this.clickTrackingURLTemplates.length) {
|
9917 | this.trackURLs(this.clickTrackingURLTemplates);
|
9918 | }
|
9919 |
|
9920 |
|
9921 | var clickThroughURLTemplate = this.clickThroughURLTemplate || fallbackClickThroughURL;
|
9922 |
|
9923 | if (clickThroughURLTemplate) {
|
9924 | var variables = this.linear ? { CONTENTPLAYHEAD: this.progressFormatted() } : {};
|
9925 | var clickThroughURL = _util.util.resolveURLTemplates([clickThroughURLTemplate], variables)[0];
|
9926 |
|
9927 | this.emit('clickthrough', clickThroughURL);
|
9928 | }
|
9929 | }
|
9930 |
|
9931 | |
9932 |
|
9933 |
|
9934 |
|
9935 |
|
9936 |
|
9937 |
|
9938 | }, {
|
9939 | key: 'track',
|
9940 | value: function track(eventName) {
|
9941 | var once = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
9942 |
|
9943 |
|
9944 |
|
9945 | if (eventName === 'closeLinear' && !this.trackingEvents[eventName] && this.trackingEvents['close']) {
|
9946 | eventName = 'close';
|
9947 | }
|
9948 |
|
9949 | var trackingURLTemplates = this.trackingEvents[eventName];
|
9950 | var isAlwaysEmitEvent = this.emitAlwaysEvents.indexOf(eventName) > -1;
|
9951 |
|
9952 | if (trackingURLTemplates) {
|
9953 | this.emit(eventName, '');
|
9954 | this.trackURLs(trackingURLTemplates);
|
9955 | } else if (isAlwaysEmitEvent) {
|
9956 | this.emit(eventName, '');
|
9957 | }
|
9958 |
|
9959 | if (once) {
|
9960 | delete this.trackingEvents[eventName];
|
9961 | if (isAlwaysEmitEvent) {
|
9962 | this.emitAlwaysEvents.splice(this.emitAlwaysEvents.indexOf(eventName), 1);
|
9963 | }
|
9964 | }
|
9965 | }
|
9966 |
|
9967 | |
9968 |
|
9969 |
|
9970 |
|
9971 |
|
9972 |
|
9973 |
|
9974 |
|
9975 | }, {
|
9976 | key: 'trackURLs',
|
9977 | value: function trackURLs(URLTemplates) {
|
9978 | var variables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
9979 | var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
9980 |
|
9981 | if (this.linear) {
|
9982 | if (this.creative && this.creative.mediaFiles && this.creative.mediaFiles[0] && this.creative.mediaFiles[0].fileURL) {
|
9983 | variables['ASSETURI'] = this.creative.mediaFiles[0].fileURL;
|
9984 | }
|
9985 | variables['CONTENTPLAYHEAD'] = this.progressFormatted();
|
9986 | }
|
9987 |
|
9988 | _util.util.track(URLTemplates, variables, options);
|
9989 | }
|
9990 |
|
9991 | |
9992 |
|
9993 |
|
9994 |
|
9995 |
|
9996 |
|
9997 | }, {
|
9998 | key: 'progressFormatted',
|
9999 | value: function progressFormatted() {
|
10000 | var seconds = parseInt(this.progress);
|
10001 | var h = seconds / (60 * 60);
|
10002 | if (h.length < 2) {
|
10003 | h = '0' + h;
|
10004 | }
|
10005 | var m = seconds / 60 % 60;
|
10006 | if (m.length < 2) {
|
10007 | m = '0' + m;
|
10008 | }
|
10009 | var s = seconds % 60;
|
10010 | if (s.length < 2) {
|
10011 | s = '0' + m;
|
10012 | }
|
10013 | var ms = parseInt((this.progress - seconds) * 100);
|
10014 | return h + ':' + m + ':' + s + '.' + ms;
|
10015 | }
|
10016 | }]);
|
10017 |
|
10018 | return VASTTracker;
|
10019 | }(_events.EventEmitter);
|
10020 |
|
10021 | }),
|
10022 |
|
10023 | (function(module, exports, __webpack_require__) {
|
10024 |
|
10025 | "use strict";
|
10026 |
|
10027 |
|
10028 | Object.defineProperty(exports, "__esModule", {
|
10029 | value: true
|
10030 | });
|
10031 |
|
10032 | var _YouTube = __webpack_require__(5);
|
10033 |
|
10034 | var _SoundCloud = __webpack_require__(7);
|
10035 |
|
10036 | var _Vimeo = __webpack_require__(8);
|
10037 |
|
10038 | var _Facebook = __webpack_require__(13);
|
10039 |
|
10040 | var _Streamable = __webpack_require__(14);
|
10041 |
|
10042 | var _FaceMask = __webpack_require__(15);
|
10043 |
|
10044 | var _Wistia = __webpack_require__(16);
|
10045 |
|
10046 | var _Twitch = __webpack_require__(17);
|
10047 |
|
10048 | var _DailyMotion = __webpack_require__(9);
|
10049 |
|
10050 | var _UstreamLive = __webpack_require__(18);
|
10051 |
|
10052 | var _UstreamVideo = __webpack_require__(19);
|
10053 |
|
10054 | var _Iframe = __webpack_require__(20);
|
10055 |
|
10056 | var _Mixcloud = __webpack_require__(21);
|
10057 |
|
10058 | var _FilePlayer = __webpack_require__(10);
|
10059 |
|
10060 | var _VAST = __webpack_require__(22);
|
10061 |
|
10062 | var _JWPlayer = __webpack_require__(29);
|
10063 |
|
10064 | var _PhenixPlayer = __webpack_require__(30);
|
10065 |
|
10066 | exports['default'] = [_PhenixPlayer.PhenixPlayer, _YouTube.YouTube, _SoundCloud.SoundCloud, _Vimeo.Vimeo, _Facebook.Facebook, _Streamable.Streamable, _FaceMask.FaceMask, _Wistia.Wistia, _Twitch.Twitch, _DailyMotion.DailyMotion, _Mixcloud.Mixcloud, _UstreamLive.UstreamLive, _UstreamVideo.UstreamVideo, _JWPlayer.JWPlayer, _VAST.VAST, _FilePlayer.FilePlayer, _Iframe.Iframe];
|
10067 |
|
10068 | }),
|
10069 |
|
10070 | (function(module, exports, __webpack_require__) {
|
10071 |
|
10072 | "use strict";
|
10073 |
|
10074 |
|
10075 | Object.defineProperty(exports, "__esModule", {
|
10076 | value: true
|
10077 | });
|
10078 |
|
10079 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
10080 |
|
10081 | 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; }; }();
|
10082 |
|
10083 | var _react = __webpack_require__(0);
|
10084 |
|
10085 | var _react2 = _interopRequireDefault(_react);
|
10086 |
|
10087 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
10088 |
|
10089 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
10090 |
|
10091 | 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; }
|
10092 |
|
10093 | 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; }
|
10094 |
|
10095 | var ICON_SIZE = '64px';
|
10096 |
|
10097 | var Preview = function (_Component) {
|
10098 | _inherits(Preview, _Component);
|
10099 |
|
10100 | function Preview() {
|
10101 | var _ref;
|
10102 |
|
10103 | var _temp, _this, _ret;
|
10104 |
|
10105 | _classCallCheck(this, Preview);
|
10106 |
|
10107 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
10108 | args[_key] = arguments[_key];
|
10109 | }
|
10110 |
|
10111 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Preview.__proto__ || Object.getPrototypeOf(Preview)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
|
10112 | image: null
|
10113 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
10114 | }
|
10115 |
|
10116 | _createClass(Preview, [{
|
10117 | key: 'componentDidMount',
|
10118 | value: function componentDidMount() {
|
10119 | this.fetchImage(this.props);
|
10120 | }
|
10121 | }, {
|
10122 | key: 'componentWillReceiveProps',
|
10123 | value: function componentWillReceiveProps(nextProps) {
|
10124 | if (this.props.url !== nextProps.url) {
|
10125 | this.fetchImage(nextProps);
|
10126 | }
|
10127 | }
|
10128 | }, {
|
10129 | key: 'fetchImage',
|
10130 | value: function fetchImage(_ref2) {
|
10131 | var _this2 = this;
|
10132 |
|
10133 | var url = _ref2.url,
|
10134 | light = _ref2.light;
|
10135 |
|
10136 | if (typeof light === 'string') {
|
10137 | this.setState({ image: light });
|
10138 | return;
|
10139 | }
|
10140 | this.setState({ image: null });
|
10141 | return window.fetch('https://noembed.com/embed?url=' + url).then(function (response) {
|
10142 | return response.json();
|
10143 | }).then(function (data) {
|
10144 | if (data.thumbnail_url) {
|
10145 | var image = data.thumbnail_url.replace('height=100', 'height=480');
|
10146 | _this2.setState({ image: image });
|
10147 | }
|
10148 | });
|
10149 | }
|
10150 | }, {
|
10151 | key: 'render',
|
10152 | value: function render() {
|
10153 | var onClick = this.props.onClick;
|
10154 | var image = this.state.image;
|
10155 |
|
10156 | var flexCenter = {
|
10157 | display: 'flex',
|
10158 | alignItems: 'center',
|
10159 | justifyContent: 'center'
|
10160 | };
|
10161 | var styles = {
|
10162 | preview: _extends({
|
10163 | width: '100%',
|
10164 | height: '100%',
|
10165 | backgroundImage: image ? 'url(' + image + ')' : undefined,
|
10166 | backgroundSize: 'cover',
|
10167 | backgroundPosition: 'center',
|
10168 | cursor: 'pointer'
|
10169 | }, flexCenter),
|
10170 | shadow: _extends({
|
10171 | background: 'radial-gradient(rgb(0, 0, 0, 0.3), rgba(0, 0, 0, 0) 60%)',
|
10172 | borderRadius: ICON_SIZE,
|
10173 | width: ICON_SIZE,
|
10174 | height: ICON_SIZE
|
10175 | }, flexCenter),
|
10176 | playIcon: {
|
10177 | borderStyle: 'solid',
|
10178 | borderWidth: '16px 0 16px 26px',
|
10179 | borderColor: 'transparent transparent transparent white',
|
10180 | marginLeft: '7px'
|
10181 | }
|
10182 | };
|
10183 | return _react2['default'].createElement(
|
10184 | 'div',
|
10185 | { style: styles.preview, className: 'react-player__preview', onClick: onClick },
|
10186 | _react2['default'].createElement(
|
10187 | 'div',
|
10188 | { style: styles.shadow, className: 'react-player__shadow' },
|
10189 | _react2['default'].createElement('div', { style: styles.playIcon, className: 'react-player__play-icon' })
|
10190 | )
|
10191 | );
|
10192 | }
|
10193 | }]);
|
10194 |
|
10195 | return Preview;
|
10196 | }(_react.Component);
|
10197 |
|
10198 | exports['default'] = Preview;
|
10199 |
|
10200 | }),
|
10201 |
|
10202 | (function(module, exports, __webpack_require__) {
|
10203 |
|
10204 | "use strict";
|
10205 |
|
10206 |
|
10207 | Object.defineProperty(exports, "__esModule", {
|
10208 | value: true
|
10209 | });
|
10210 | exports['default'] = renderPreloadPlayers;
|
10211 |
|
10212 | var _react = __webpack_require__(0);
|
10213 |
|
10214 | var _react2 = _interopRequireDefault(_react);
|
10215 |
|
10216 | var _Player = __webpack_require__(6);
|
10217 |
|
10218 | var _Player2 = _interopRequireDefault(_Player);
|
10219 |
|
10220 | var _YouTube = __webpack_require__(5);
|
10221 |
|
10222 | var _SoundCloud = __webpack_require__(7);
|
10223 |
|
10224 | var _Vimeo = __webpack_require__(8);
|
10225 |
|
10226 | var _DailyMotion = __webpack_require__(9);
|
10227 |
|
10228 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
10229 |
|
10230 | var PRELOAD_PLAYERS = [{
|
10231 | Player: _YouTube.YouTube,
|
10232 | configKey: 'youtube',
|
10233 | url: 'https://www.youtube.com/watch?v=GlCmAC4MHek'
|
10234 | }, {
|
10235 | Player: _SoundCloud.SoundCloud,
|
10236 | configKey: 'soundcloud',
|
10237 | url: 'https://soundcloud.com/seucheu/john-cage-433-8-bit-version'
|
10238 | }, {
|
10239 | Player: _Vimeo.Vimeo,
|
10240 | configKey: 'vimeo',
|
10241 | url: 'https://vimeo.com/300970506'
|
10242 | }, {
|
10243 | Player: _DailyMotion.DailyMotion,
|
10244 | configKey: 'dailymotion',
|
10245 | url: 'http://www.dailymotion.com/video/xqdpyk'
|
10246 | }];
|
10247 |
|
10248 | function renderPreloadPlayers(url, controls, config) {
|
10249 | var players = [];
|
10250 |
|
10251 | var _iteratorNormalCompletion = true;
|
10252 | var _didIteratorError = false;
|
10253 | var _iteratorError = undefined;
|
10254 |
|
10255 | try {
|
10256 | for (var _iterator = PRELOAD_PLAYERS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
10257 | var player = _step.value;
|
10258 |
|
10259 | if (!player.Player.canPlay(url) && config[player.configKey].preload) {
|
10260 | players.push(_react2['default'].createElement(_Player2['default'], {
|
10261 | key: player.Player.displayName,
|
10262 | activePlayer: player.Player,
|
10263 | url: player.url,
|
10264 | controls: controls,
|
10265 | playing: true,
|
10266 | muted: true,
|
10267 | style: { display: 'none' }
|
10268 | }));
|
10269 | }
|
10270 | }
|
10271 | } catch (err) {
|
10272 | _didIteratorError = true;
|
10273 | _iteratorError = err;
|
10274 | } finally {
|
10275 | try {
|
10276 | if (!_iteratorNormalCompletion && _iterator['return']) {
|
10277 | _iterator['return']();
|
10278 | }
|
10279 | } finally {
|
10280 | if (_didIteratorError) {
|
10281 | throw _iteratorError;
|
10282 | }
|
10283 | }
|
10284 | }
|
10285 |
|
10286 | return players;
|
10287 | }
|
10288 |
|
10289 | })
|
10290 | ])["default"];
|
10291 |
|
\ | No newline at end of file |