cloudinary-video-player 1.5.6 → 1.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -22
- package/dist/cld-video-player.js +4 -4
- package/dist/cld-video-player.light.js +4 -4
- package/dist/cld-video-player.light.min.js +1 -1
- package/dist/cld-video-player.min.js +1 -1
- package/package.json +1 -1
- package/src/extended-events.js +3 -0
- package/src/video-player.js +4 -1
|
@@ -732,7 +732,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n
|
|
|
732
732
|
/***/ (function(module, exports, __webpack_require__) {
|
|
733
733
|
|
|
734
734
|
"use strict";
|
|
735
|
-
eval("\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = exports.normalizeEventsParam = void 0;\n\nvar _video = _interopRequireDefault(__webpack_require__(/*! video.js */ \"../node_modules/video.js/dist/alt/video.core.js-exposed\"));\n\nvar _events = _interopRequireDefault(__webpack_require__(/*! events */ \"../node_modules/events/events.js\"));\n\nvar _assign = __webpack_require__(/*! utils/assign */ \"./utils/assign.js\");\n\nvar _typeInference = __webpack_require__(/*! utils/type-inference */ \"./utils/type-inference.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nvar EVENT_DEFAULTS = {\n percentsplayed: {\n percents: [25, 50, 75, 100]\n }\n};\nvar DEFAULT_EVENTS = ['percentsplayed', 'pausenoseek', 'seek', 'mute', 'unmute', 'qualitychanged'];\nvar DEFAULT_OPTIONS = {\n events: DEFAULT_EVENTS\n}; // Emits the following additional events:\n// percentsplayed, timeplayed, pausenoseek, seek, mute, unmute\n\nvar ExtendedEvents = /*#__PURE__*/function (_EventEmitter) {\n _inherits(ExtendedEvents, _EventEmitter);\n\n var _super = _createSuper(ExtendedEvents);\n\n function ExtendedEvents(player) {\n var _this;\n\n var initOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n _classCallCheck(this, ExtendedEvents);\n\n _this = _super.call(this);\n _this.player = player;\n\n var options = _video.default.mergeOptions(DEFAULT_OPTIONS, initOptions);\n\n var _muteData = {\n lastState: undefined\n };\n var _seekStart = 0;\n var _seekEnd = 0;\n var _seeking = false;\n var _percentsTracked = [];\n var _timesTracked = [];\n var _currentSource = null;\n var _ended = false;\n\n var volumechange = function volumechange(event) {\n if (_this.player.muted() && _muteData.lastState !== 'muted') {\n _muteData.lastState = 'muted';\n\n _this.emit('mute', event);\n } else if (!_this.player.muted() && _muteData.lastState !== 'unmuted') {\n _muteData.lastState = 'unmuted';\n\n _this.emit('unmute', event);\n }\n };\n\n var timeupdate = function timeupdate(event) {\n var currentTime = _this.player.currentTime();\n\n var duration = _this.player.duration();\n\n var _emit = function _emit(type, data) {\n data.originalType = 'timeupdate';\n\n _this.emit(type, event, data);\n };\n\n if (_this.events.percentsplayed) {\n _this.events.percentsplayed.percents.forEach(function (percent) {\n if (playedAtPercentage(currentTime, duration, percent) && _percentsTracked.indexOf(percent) === -1) {\n _percentsTracked.push(percent);\n\n _emit('percentsplayed', {\n percent: percent\n });\n }\n });\n }\n\n if (_this.events.timeplayed) {\n var timeplayed = _this.events.timeplayed;\n var times = timeplayed.interval ? [Math.floor(currentTime / timeplayed.interval) * timeplayed.interval] : timeplayed.times;\n times.forEach(function (time) {\n if (playedAtTime(currentTime, time) && _timesTracked.indexOf(time) === -1) {\n _timesTracked.push(time);\n\n _emit('timeplayed', {\n time: time\n });\n }\n });\n }\n\n if (_this.events.seek) {\n _seekStart = _seekEnd;\n _seekEnd = currentTime;\n\n if (Math.abs(_seekStart - _seekEnd) > 1) {\n _seeking = true;\n\n _emit('seek', {\n seekStart: _seekStart,\n seekEnd: _seekEnd\n });\n }\n }\n };\n\n var pause = function pause(event) {\n var currentTime = Math.round(_this.player.currentTime());\n var duration = Math.round(_this.player.duration());\n\n if (currentTime !== duration && !_seeking) {\n _this.emit('pausenoseek', event);\n }\n };\n\n var play = function play() {\n _seeking = false;\n };\n\n var replay = function replay() {\n if (_ended) {\n _this.player.trigger('replay');\n\n _ended = false;\n }\n };\n\n var loadedmetadata = function loadedmetadata() {\n if (_this.player.currentSource().src !== _currentSource) {\n resetPerVideoState();\n _currentSource = _this.player.currentSource().src;\n }\n };\n\n var adaptiveEvents = function adaptiveEvents(event) {\n var ee = _assertThisInitialized(_this);\n\n var tracks = _this.player.textTracks();\n\n var segmentMetadataTrack = null;\n\n for (var i = 0; i < tracks.length; i++) {\n if (tracks[i].label === 'segment-metadata') {\n segmentMetadataTrack = tracks[i];\n }\n }\n\n var previousResolution = null;\n\n if (segmentMetadataTrack) {\n segmentMetadataTrack.on('cuechange', function () {\n var activeCue = segmentMetadataTrack.activeCues[0];\n\n if (activeCue) {\n var currentRes = activeCue.value.resolution;\n\n if (previousResolution !== currentRes) {\n var data = {\n from: previousResolution,\n to: currentRes\n };\n ee.emit('qualitychanged', event, data);\n }\n\n previousResolution = currentRes;\n }\n });\n }\n };\n\n var resetState = function resetState() {\n _muteData = {\n lastState: undefined\n };\n _seekStart = _seekEnd = 0;\n _seeking = false;\n resetPerVideoState();\n };\n\n var resetPerVideoState = function resetPerVideoState() {\n _percentsTracked = [];\n _timesTracked = [];\n };\n\n var ended = function ended() {\n _ended = true;\n };\n\n _this.events = normalizeEventsParam(options.events, EVENT_DEFAULTS);\n resetState();\n\n _this.player.on('play', replay.bind(_assertThisInitialized(_this)));\n\n _this.player.on('ended', ended.bind(_assertThisInitialized(_this)));\n\n if (_this.events.percentsplayed || _this.events.timeplayed || _this.events.seek || _this.events.totaltimeplayed) {\n _this.player.on('timeupdate', timeupdate.bind(_assertThisInitialized(_this)));\n }\n\n if (_this.events.mute || _this.events.unmute) {\n _this.player.on('volumechange', volumechange.bind(_assertThisInitialized(_this)));\n }\n\n if (_this.events.pausenoseek) {\n _this.player.on('pause', pause.bind(_assertThisInitialized(_this)));\n\n _this.player.on('play', play.bind(_assertThisInitialized(_this)));\n }\n\n _this.player.on('loadedmetadata', loadedmetadata.bind(_assertThisInitialized(_this)));\n\n _this.player.on('loadeddata', adaptiveEvents.bind(_assertThisInitialized(_this)));\n\n return _this;\n }\n\n return ExtendedEvents;\n}(_events.default);\n\nvar normalizeEventsParam = function normalizeEventsParam(events, defaults) {\n var normalized = events;\n\n if (events.constructor.name === 'Array') {\n normalized = events.reduce(function (agg, item) {\n var eventDefaults = defaults[item] || {};\n\n if ((0, _typeInference.isPlainObject)(item)) {\n agg[item.type] = (0, _assign.assign)({}, eventDefaults, item);\n } else {\n agg[item] = eventDefaults;\n }\n\n return agg;\n }, {});\n }\n\n return normalized;\n};\n\nexports.normalizeEventsParam = normalizeEventsParam;\n\nvar playedAtPercentage = function playedAtPercentage(currentTime, duration, percentageCheckpoint) {\n var graceRangeSeconds = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0.5;\n var checkPoint = duration * percentageCheckpoint / 100;\n return playedAtTime(currentTime, checkPoint, graceRangeSeconds);\n};\n\nvar playedAtTime = function playedAtTime(currentTime, checkpoint) {\n var graceRangeSeconds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.5;\n return currentTime <= checkpoint + graceRangeSeconds && currentTime >= checkpoint - graceRangeSeconds;\n};\n\nvar _default = ExtendedEvents;\nexports.default = _default;\n\n//# sourceURL=webpack://cloudinaryVideoPlayer/./extended-events.js?");
|
|
735
|
+
eval("\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = exports.normalizeEventsParam = void 0;\n\nvar _video = _interopRequireDefault(__webpack_require__(/*! video.js */ \"../node_modules/video.js/dist/alt/video.core.js-exposed\"));\n\nvar _events = _interopRequireDefault(__webpack_require__(/*! events */ \"../node_modules/events/events.js\"));\n\nvar _assign = __webpack_require__(/*! utils/assign */ \"./utils/assign.js\");\n\nvar _typeInference = __webpack_require__(/*! utils/type-inference */ \"./utils/type-inference.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nvar EVENT_DEFAULTS = {\n percentsplayed: {\n percents: [25, 50, 75, 100]\n }\n};\nvar DEFAULT_EVENTS = ['percentsplayed', 'pausenoseek', 'seek', 'mute', 'unmute', 'qualitychanged'];\nvar DEFAULT_OPTIONS = {\n events: DEFAULT_EVENTS\n}; // Emits the following additional events:\n// percentsplayed, timeplayed, pausenoseek, seek, mute, unmute\n\nvar ExtendedEvents = /*#__PURE__*/function (_EventEmitter) {\n _inherits(ExtendedEvents, _EventEmitter);\n\n var _super = _createSuper(ExtendedEvents);\n\n function ExtendedEvents(player) {\n var _this;\n\n var initOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n _classCallCheck(this, ExtendedEvents);\n\n _this = _super.call(this);\n _this.player = player;\n\n var options = _video.default.mergeOptions(DEFAULT_OPTIONS, initOptions);\n\n var _muteData = {\n lastState: undefined\n };\n var _seekStart = 0;\n var _seekEnd = 0;\n var _seeking = false;\n var _percentsTracked = [];\n var _timesTracked = [];\n var _currentSource = null;\n var _ended = false;\n\n var volumechange = function volumechange(event) {\n if (_this.player.muted() && _muteData.lastState !== 'muted') {\n _muteData.lastState = 'muted';\n\n _this.emit('mute', event);\n } else if (!_this.player.muted() && _muteData.lastState !== 'unmuted') {\n _muteData.lastState = 'unmuted';\n\n _this.emit('unmute', event);\n }\n };\n\n var timeupdate = function timeupdate(event) {\n var currentTime = _this.player.currentTime();\n\n var duration = _this.player.duration();\n\n var _emit = function _emit(type, data) {\n data.originalType = 'timeupdate';\n\n _this.emit(type, event, data);\n };\n\n if (_this.events.percentsplayed) {\n _this.events.percentsplayed.percents.forEach(function (percent) {\n if (playedAtPercentage(currentTime, duration, percent) && _percentsTracked.indexOf(percent) === -1) {\n _percentsTracked.push(percent);\n\n _emit('percentsplayed', {\n percent: percent\n });\n }\n });\n }\n\n if (_this.events.timeplayed) {\n var timeplayed = _this.events.timeplayed;\n var times = timeplayed.interval ? [Math.floor(currentTime / timeplayed.interval) * timeplayed.interval] : timeplayed.times;\n times.forEach(function (time) {\n if (playedAtTime(currentTime, time) && _timesTracked.indexOf(time) === -1) {\n _timesTracked.push(time);\n\n _emit('timeplayed', {\n time: time\n });\n }\n });\n }\n\n if (_this.events.seek) {\n _seekStart = _seekEnd;\n _seekEnd = currentTime;\n\n if (Math.abs(_seekStart - _seekEnd) > 1) {\n _seeking = true; // should empty _timesTracked array on seek, needed for 'timeplayed' event\n\n resetPerVideoState();\n\n _emit('seek', {\n seekStart: _seekStart,\n seekEnd: _seekEnd\n });\n }\n }\n };\n\n var pause = function pause(event) {\n var currentTime = Math.round(_this.player.currentTime());\n var duration = Math.round(_this.player.duration());\n\n if (currentTime !== duration && !_seeking) {\n _this.emit('pausenoseek', event);\n }\n };\n\n var play = function play() {\n _seeking = false;\n };\n\n var replay = function replay() {\n if (_ended) {\n _this.player.trigger('replay');\n\n _ended = false;\n }\n };\n\n var loadedmetadata = function loadedmetadata() {\n if (_this.player.currentSource().src !== _currentSource) {\n resetPerVideoState();\n _currentSource = _this.player.currentSource().src;\n }\n };\n\n var adaptiveEvents = function adaptiveEvents(event) {\n var ee = _assertThisInitialized(_this);\n\n var tracks = _this.player.textTracks();\n\n var segmentMetadataTrack = null;\n\n for (var i = 0; i < tracks.length; i++) {\n if (tracks[i].label === 'segment-metadata') {\n segmentMetadataTrack = tracks[i];\n }\n }\n\n var previousResolution = null;\n\n if (segmentMetadataTrack) {\n segmentMetadataTrack.on('cuechange', function () {\n var activeCue = segmentMetadataTrack.activeCues[0];\n\n if (activeCue) {\n var currentRes = activeCue.value.resolution;\n\n if (previousResolution !== currentRes) {\n var data = {\n from: previousResolution,\n to: currentRes\n };\n ee.emit('qualitychanged', event, data);\n }\n\n previousResolution = currentRes;\n }\n });\n }\n };\n\n var resetState = function resetState() {\n _muteData = {\n lastState: undefined\n };\n _seekStart = _seekEnd = 0;\n _seeking = false;\n resetPerVideoState();\n };\n\n var resetPerVideoState = function resetPerVideoState() {\n _percentsTracked = [];\n _timesTracked = [];\n };\n\n var ended = function ended() {\n _ended = true;\n };\n\n _this.events = normalizeEventsParam(options.events, EVENT_DEFAULTS);\n resetState();\n\n _this.player.on('play', replay.bind(_assertThisInitialized(_this)));\n\n _this.player.on('ended', ended.bind(_assertThisInitialized(_this)));\n\n if (_this.events.percentsplayed || _this.events.timeplayed || _this.events.seek || _this.events.totaltimeplayed) {\n _this.player.on('timeupdate', timeupdate.bind(_assertThisInitialized(_this)));\n }\n\n if (_this.events.mute || _this.events.unmute) {\n _this.player.on('volumechange', volumechange.bind(_assertThisInitialized(_this)));\n }\n\n if (_this.events.pausenoseek) {\n _this.player.on('pause', pause.bind(_assertThisInitialized(_this)));\n\n _this.player.on('play', play.bind(_assertThisInitialized(_this)));\n }\n\n _this.player.on('loadedmetadata', loadedmetadata.bind(_assertThisInitialized(_this)));\n\n _this.player.on('loadeddata', adaptiveEvents.bind(_assertThisInitialized(_this)));\n\n return _this;\n }\n\n return ExtendedEvents;\n}(_events.default);\n\nvar normalizeEventsParam = function normalizeEventsParam(events, defaults) {\n var normalized = events;\n\n if (events.constructor.name === 'Array') {\n normalized = events.reduce(function (agg, item) {\n var eventDefaults = defaults[item] || {};\n\n if ((0, _typeInference.isPlainObject)(item)) {\n agg[item.type] = (0, _assign.assign)({}, eventDefaults, item);\n } else {\n agg[item] = eventDefaults;\n }\n\n return agg;\n }, {});\n }\n\n return normalized;\n};\n\nexports.normalizeEventsParam = normalizeEventsParam;\n\nvar playedAtPercentage = function playedAtPercentage(currentTime, duration, percentageCheckpoint) {\n var graceRangeSeconds = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0.5;\n var checkPoint = duration * percentageCheckpoint / 100;\n return playedAtTime(currentTime, checkPoint, graceRangeSeconds);\n};\n\nvar playedAtTime = function playedAtTime(currentTime, checkpoint) {\n var graceRangeSeconds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.5;\n return currentTime <= checkpoint + graceRangeSeconds && currentTime >= checkpoint - graceRangeSeconds;\n};\n\nvar _default = ExtendedEvents;\nexports.default = _default;\n\n//# sourceURL=webpack://cloudinaryVideoPlayer/./extended-events.js?");
|
|
736
736
|
|
|
737
737
|
/***/ }),
|
|
738
738
|
|
|
@@ -828,7 +828,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n
|
|
|
828
828
|
/***/ (function(module, exports, __webpack_require__) {
|
|
829
829
|
|
|
830
830
|
"use strict";
|
|
831
|
-
eval("\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = _default;\nexports.CONSTRUCTOR_PARAMS = void 0;\n\nvar _cloudinaryCore = _interopRequireDefault(__webpack_require__(/*! cloudinary-core */ \"cloudinary-core\"));\n\nvar _video = _interopRequireDefault(__webpack_require__(/*! video.js */ \"../node_modules/video.js/dist/alt/video.core.js-exposed\"));\n\nvar _mixin2 = __webpack_require__(/*! utils/mixin */ \"./utils/mixin.js\");\n\nvar _applyWithProps = __webpack_require__(/*! utils/apply-with-props */ \"./utils/apply-with-props.js\");\n\nvar _slicing = __webpack_require__(/*! utils/slicing */ \"./utils/slicing.js\");\n\nvar _cloudinary = __webpack_require__(/*! utils/cloudinary */ \"./utils/cloudinary.js\");\n\nvar _assign = __webpack_require__(/*! utils/assign */ \"./utils/assign.js\");\n\nvar _common = __webpack_require__(/*! ./common */ \"./plugins/cloudinary/common.js\");\n\nvar _playlistable = _interopRequireDefault(__webpack_require__(/*! mixins/playlistable */ \"./mixins/playlistable.js\"));\n\nvar _videoSource = _interopRequireDefault(__webpack_require__(/*! ./models/video-source/video-source */ \"./plugins/cloudinary/models/video-source/video-source.js\"));\n\nvar _eventHandlerRegistry = _interopRequireDefault(__webpack_require__(/*! ./event-handler-registry */ \"./plugins/cloudinary/event-handler-registry.js\"));\n\nvar _audioSource = _interopRequireDefault(__webpack_require__(/*! ./models/audio-source/audio-source */ \"./plugins/cloudinary/models/audio-source/audio-source.js\"));\n\nvar _typeInference = __webpack_require__(/*! ../../utils/type-inference */ \"./utils/type-inference.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nvar DEFAULT_PARAMS = {\n transformation: {},\n sourceTypes: [],\n sourceTransformation: [],\n posterOptions: {}\n};\nvar CONSTRUCTOR_PARAMS = ['cloudinaryConfig', 'transformation', 'sourceTypes', 'sourceTransformation', 'posterOptions', 'autoShowRecommendations'];\nexports.CONSTRUCTOR_PARAMS = CONSTRUCTOR_PARAMS;\n\nvar CloudinaryContext = /*#__PURE__*/function (_mixin) {\n _inherits(CloudinaryContext, _mixin);\n\n var _super = _createSuper(CloudinaryContext);\n\n function CloudinaryContext(player) {\n var _this;\n\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n _classCallCheck(this, CloudinaryContext);\n\n _this = _super.call(this, player, options);\n _this.player = player;\n options = (0, _assign.assign)({}, DEFAULT_PARAMS, options);\n var _source = null;\n var _sources = null;\n var _lastSource = null;\n var _lastPlaylist = null;\n var _posterOptions = null;\n var _cloudinaryConfig = null;\n var _transformation = null;\n var _sourceTypes = null;\n var _sourceTransformation = null;\n var _chainTarget = options.chainTarget;\n var _playerEvents = null;\n var _recommendations = null;\n var _autoShowRecommendations = false;\n\n _this.source = function (source) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n options = (0, _assign.assign)({}, options);\n\n if (!source) {\n return _source;\n }\n\n var src = null;\n\n if (source instanceof _videoSource.default) {\n src = source;\n } else {\n var _normalizeOptions = (0, _common.normalizeOptions)(source, options),\n publicId = _normalizeOptions.publicId,\n _options = _normalizeOptions.options;\n\n src = _this.buildSource(publicId, _options);\n }\n\n if (src.recommendations()) {\n var recommendations = src.recommendations();\n var itemBuilder = null;\n var disableAutoShow = false;\n\n if (options.recommendationOptions) {\n var _sliceAndUnsetPropert = (0, _slicing.sliceAndUnsetProperties)(options.recommendationOptions, 'disableAutoShow', 'itemBuilder');\n\n disableAutoShow = _sliceAndUnsetPropert.disableAutoShow;\n itemBuilder = _sliceAndUnsetPropert.itemBuilder;\n }\n\n setRecommendations(recommendations, {\n disableAutoShow: disableAutoShow,\n itemBuilder: itemBuilder\n });\n } else {\n unsetRecommendations();\n }\n\n _source = src;\n\n if (!options.skipRefresh) {\n refresh();\n }\n\n _this.player.trigger('cldsourcechanged', {\n source: src\n });\n\n return _chainTarget;\n };\n\n _this.buildSource = function (publicId) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var builtSrc = null;\n\n var _normalizeOptions2 = (0, _common.normalizeOptions)(publicId, options);\n\n publicId = _normalizeOptions2.publicId;\n options = _normalizeOptions2.options;\n options.cloudinaryConfig = (0, _common.mergeCloudinaryConfig)(_this.cloudinaryConfig(), options.cloudinaryConfig || {});\n options.transformation = (0, _common.mergeTransformation)(_this.transformation(), options.transformation || {});\n options.sourceTransformation = options.sourceTransformation || _this.sourceTransformation();\n options.sourceTypes = options.sourceTypes || _this.sourceTypes();\n options.poster = options.poster || posterOptionsForCurrent();\n options.queryParams = options.usageReport ? {\n _s: \"vp-\".concat(\"1.5.6\")\n } : {};\n\n if (options.sourceTypes.indexOf('audio') > -1) {\n builtSrc = new _audioSource.default(publicId, options);\n } else {\n builtSrc = new _videoSource.default(publicId, options);\n }\n\n return builtSrc;\n };\n\n _this.posterOptions = function (options) {\n if (!options) {\n return _posterOptions;\n }\n\n _posterOptions = options;\n return _chainTarget;\n };\n\n _this.cloudinaryConfig = function (config) {\n if (!config) {\n return _cloudinaryConfig;\n }\n\n _cloudinaryConfig = (0, _cloudinary.getCloudinaryInstanceOf)(_cloudinaryCore.default.Cloudinary, config);\n return _chainTarget;\n };\n\n _this.transformation = function (trans) {\n if (!trans) {\n return _transformation;\n }\n\n _transformation = (0, _cloudinary.getCloudinaryInstanceOf)(_cloudinaryCore.default.Transformation, trans);\n return _chainTarget;\n };\n\n _this.sourceTypes = function (types) {\n if (!types) {\n return _sourceTypes;\n }\n\n _sourceTypes = types;\n return _chainTarget;\n };\n\n _this.getCurrentSources = function () {\n return _sources;\n };\n\n _this.sourceTransformation = function (trans) {\n if (!trans) {\n return _sourceTransformation;\n }\n\n _sourceTransformation = trans;\n return _chainTarget;\n };\n\n _this.on = function () {\n var _playerEvents2;\n\n return (_playerEvents2 = _playerEvents).on.apply(_playerEvents2, arguments);\n };\n\n _this.one = function () {\n var _playerEvents3;\n\n return (_playerEvents3 = _playerEvents).one.apply(_playerEvents3, arguments);\n };\n\n _this.off = function () {\n var _playerEvents4;\n\n return (_playerEvents4 = _playerEvents).off.apply(_playerEvents4, arguments);\n };\n\n _this.autoShowRecommendations = function (autoShow) {\n if (autoShow === undefined) {\n return _autoShowRecommendations;\n }\n\n _autoShowRecommendations = autoShow;\n return _chainTarget;\n };\n\n _this.dispose = function () {\n if (_this.playlist()) {\n _this.disposePlaylist();\n }\n\n unsetRecommendations();\n _source = undefined;\n\n _playerEvents.removeAllListeners();\n };\n\n var setRecommendations = function setRecommendations(recommendations, _ref) {\n var _ref$disableAutoShow = _ref.disableAutoShow,\n disableAutoShow = _ref$disableAutoShow === void 0 ? false : _ref$disableAutoShow,\n _ref$itemBuilder = _ref.itemBuilder,\n itemBuilder = _ref$itemBuilder === void 0 ? null : _ref$itemBuilder;\n unsetRecommendations();\n\n if (!Array.isArray(recommendations) && typeof recommendations !== 'function' && !recommendations.then) {\n throw new Error('\"recommendations\" must be either an array or a function');\n }\n\n _recommendations = {};\n\n itemBuilder = itemBuilder || function (source) {\n return {\n source: source instanceof _videoSource.default ? source : _this.buildSource(source),\n action: function action() {\n return _this.source(source);\n }\n };\n };\n\n _recommendations.sourceChangedHandler = function () {\n var trigger = function trigger(sources) {\n if (typeof sources !== 'undefined' && sources.length > 0) {\n var items = sources.map(function (_source) {\n return itemBuilder(_source);\n });\n\n _this.player.trigger('recommendationschanged', {\n items: items\n });\n } else {\n _this.player.trigger('recommendationsnoshow');\n }\n\n _recommendations.sources = sources;\n };\n\n if ((0, _typeInference.isFunction)(recommendations)) {\n trigger(recommendations());\n } else if (recommendations.then) {\n recommendations.then(trigger);\n } else {\n trigger(recommendations);\n }\n };\n\n _this.one('cldsourcechanged', _recommendations.sourceChangedHandler);\n\n _recommendations.endedHandler = function () {\n if (!disableAutoShow && _this.autoShowRecommendations()) {\n _this.player.trigger('recommendationsshow');\n }\n };\n\n _this.on('ended', _recommendations.endedHandler);\n };\n\n var unsetRecommendations = function unsetRecommendations() {\n if (_recommendations) {\n _this.off('cldsourcechanged', _recommendations.sourceChangedHandler);\n\n _this.off('ended', _recommendations.endedHandler);\n\n delete _recommendations.endedHandler;\n delete _recommendations.sourceChangedHandler;\n }\n\n _recommendations = null;\n };\n\n var refresh = function refresh() {\n var src = _this.source();\n\n if (src.poster()) {\n _this.player.poster(src.poster().url());\n }\n\n _sources = src.generateSources().reduce(function (srcs, src) {\n if (src.isAdaptive) {\n var codec = src.type.split('; ')[1] || null;\n\n if (codec && 'MediaSource' in window) {\n var parts = src.type.split('; ');\n var typeStr = \"video/mp4; \".concat(parts[1] || '');\n var canPlay = testCanPlayTypeAndTypeSupported(typeStr);\n\n if (_video.default.browser.IS_ANY_SAFARI) {\n // work around safari saying it cant play h265\n src.type = \"\".concat(parts[0], \"; \").concat((0, _common.codecShorthandTrans)('h264'));\n }\n\n if (canPlay) {\n srcs.push(src);\n }\n } else {\n srcs.push(src);\n }\n } else {\n srcs.push(src);\n }\n\n return srcs;\n }, []);\n\n _this.player.src(_sources);\n\n _lastSource = src;\n _lastPlaylist = _this.playlist();\n };\n\n var testCanPlayTypeAndTypeSupported = function testCanPlayTypeAndTypeSupported(codec) {\n var v = document.createElement('video');\n return v.canPlayType(codec) || 'MediaSource' in window && MediaSource.isTypeSupported(codec);\n };\n\n var posterOptionsForCurrent = function posterOptionsForCurrent() {\n var opts = (0, _assign.assign)({}, _this.posterOptions());\n\n if (opts.transformation) {\n if ((opts.transformation.width || opts.transformation.height) && !opts.transformation.crop) {\n opts.transformation.crop = 'scale';\n }\n }\n\n opts.transformation = (0, _cloudinary.getCloudinaryInstanceOf)(_cloudinaryCore.default.Transformation, opts.transformation || {}); // Set poster dimensions to player actual size.\n // (unless they were explicitly set via `posterOptions`)\n\n var playerEl = _this.player.el();\n\n if (playerEl && playerEl.clientWidth && playerEl.clientHeight && !(0, _cloudinary.isKeyInTransformation)(opts.transformation, 'width') && !(0, _cloudinary.isKeyInTransformation)(opts.transformation, 'height')) {\n var roundUp100 = function roundUp100(val) {\n return 100 * Math.ceil(val / 100);\n };\n\n opts.transformation.width(roundUp100(playerEl.clientWidth)).height(roundUp100(playerEl.clientHeight)).crop('limit');\n }\n\n return opts;\n }; // Handle external (non-cloudinary plugin) source changes (e.g. by ad plugins)\n\n\n var syncState = function syncState(_, data) {\n var src = data.to; // When source is cloudinary's\n\n if (_lastSource && _lastSource.contains(src)) {\n // If plugin state doesn't have an active VideoSource\n if (!_this.source()) {\n // We might have been running a playlist, reset playlist's state.\n if (_lastPlaylist) {\n _this.playlist(_lastPlaylist);\n } // Rebuild last source state without calling vjs's 'src' and 'poster'\n\n\n _this.source(_lastSource, {\n skipRefresh: true\n });\n }\n } else {\n // Used by cloudinary-only components\n _this.player.trigger('cldsourcechanged', {}); // When source isn't cloudinary's - reset the plugin's state.\n\n\n _this.dispose();\n }\n };\n\n _playerEvents = new _eventHandlerRegistry.default(_this.player);\n\n var constructorParams = _slicing.sliceAndUnsetProperties.apply(void 0, [options].concat(CONSTRUCTOR_PARAMS));\n\n (0, _applyWithProps.applyWithProps)(_assertThisInitialized(_this), constructorParams);\n\n _this.on('sourcechanged', syncState);\n\n return _this;\n }\n\n _createClass(CloudinaryContext, [{\n key: \"currentSourceType\",\n value: function currentSourceType() {\n return this.source().getType();\n }\n }, {\n key: \"currentPublicId\",\n value: function currentPublicId() {\n return this.source() && this.source().publicId();\n }\n }, {\n key: \"currentPoster\",\n value: function currentPoster() {\n return this.source() && this.source().poster();\n }\n }]);\n\n return CloudinaryContext;\n}((0, _mixin2.mixin)(_playlistable.default));\n\nfunction _default() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n options.chainTarget = options.chainTarget || this;\n this.cloudinary = new CloudinaryContext(this, options);\n}\n\n//# sourceURL=webpack://cloudinaryVideoPlayer/./plugins/cloudinary/index.js?");
|
|
831
|
+
eval("\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = _default;\nexports.CONSTRUCTOR_PARAMS = void 0;\n\nvar _cloudinaryCore = _interopRequireDefault(__webpack_require__(/*! cloudinary-core */ \"cloudinary-core\"));\n\nvar _video = _interopRequireDefault(__webpack_require__(/*! video.js */ \"../node_modules/video.js/dist/alt/video.core.js-exposed\"));\n\nvar _mixin2 = __webpack_require__(/*! utils/mixin */ \"./utils/mixin.js\");\n\nvar _applyWithProps = __webpack_require__(/*! utils/apply-with-props */ \"./utils/apply-with-props.js\");\n\nvar _slicing = __webpack_require__(/*! utils/slicing */ \"./utils/slicing.js\");\n\nvar _cloudinary = __webpack_require__(/*! utils/cloudinary */ \"./utils/cloudinary.js\");\n\nvar _assign = __webpack_require__(/*! utils/assign */ \"./utils/assign.js\");\n\nvar _common = __webpack_require__(/*! ./common */ \"./plugins/cloudinary/common.js\");\n\nvar _playlistable = _interopRequireDefault(__webpack_require__(/*! mixins/playlistable */ \"./mixins/playlistable.js\"));\n\nvar _videoSource = _interopRequireDefault(__webpack_require__(/*! ./models/video-source/video-source */ \"./plugins/cloudinary/models/video-source/video-source.js\"));\n\nvar _eventHandlerRegistry = _interopRequireDefault(__webpack_require__(/*! ./event-handler-registry */ \"./plugins/cloudinary/event-handler-registry.js\"));\n\nvar _audioSource = _interopRequireDefault(__webpack_require__(/*! ./models/audio-source/audio-source */ \"./plugins/cloudinary/models/audio-source/audio-source.js\"));\n\nvar _typeInference = __webpack_require__(/*! ../../utils/type-inference */ \"./utils/type-inference.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nvar DEFAULT_PARAMS = {\n transformation: {},\n sourceTypes: [],\n sourceTransformation: [],\n posterOptions: {}\n};\nvar CONSTRUCTOR_PARAMS = ['cloudinaryConfig', 'transformation', 'sourceTypes', 'sourceTransformation', 'posterOptions', 'autoShowRecommendations'];\nexports.CONSTRUCTOR_PARAMS = CONSTRUCTOR_PARAMS;\n\nvar CloudinaryContext = /*#__PURE__*/function (_mixin) {\n _inherits(CloudinaryContext, _mixin);\n\n var _super = _createSuper(CloudinaryContext);\n\n function CloudinaryContext(player) {\n var _this;\n\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n _classCallCheck(this, CloudinaryContext);\n\n _this = _super.call(this, player, options);\n _this.player = player;\n options = (0, _assign.assign)({}, DEFAULT_PARAMS, options);\n var _source = null;\n var _sources = null;\n var _lastSource = null;\n var _lastPlaylist = null;\n var _posterOptions = null;\n var _cloudinaryConfig = null;\n var _transformation = null;\n var _sourceTypes = null;\n var _sourceTransformation = null;\n var _chainTarget = options.chainTarget;\n var _playerEvents = null;\n var _recommendations = null;\n var _autoShowRecommendations = false;\n\n _this.source = function (source) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n options = (0, _assign.assign)({}, options);\n\n if (!source) {\n return _source;\n }\n\n var src = null;\n\n if (source instanceof _videoSource.default) {\n src = source;\n } else {\n var _normalizeOptions = (0, _common.normalizeOptions)(source, options),\n publicId = _normalizeOptions.publicId,\n _options = _normalizeOptions.options;\n\n src = _this.buildSource(publicId, _options);\n }\n\n if (src.recommendations()) {\n var recommendations = src.recommendations();\n var itemBuilder = null;\n var disableAutoShow = false;\n\n if (options.recommendationOptions) {\n var _sliceAndUnsetPropert = (0, _slicing.sliceAndUnsetProperties)(options.recommendationOptions, 'disableAutoShow', 'itemBuilder');\n\n disableAutoShow = _sliceAndUnsetPropert.disableAutoShow;\n itemBuilder = _sliceAndUnsetPropert.itemBuilder;\n }\n\n setRecommendations(recommendations, {\n disableAutoShow: disableAutoShow,\n itemBuilder: itemBuilder\n });\n } else {\n unsetRecommendations();\n }\n\n _source = src;\n\n if (!options.skipRefresh) {\n refresh();\n }\n\n _this.player.trigger('cldsourcechanged', {\n source: src\n });\n\n return _chainTarget;\n };\n\n _this.buildSource = function (publicId) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var builtSrc = null;\n\n var _normalizeOptions2 = (0, _common.normalizeOptions)(publicId, options);\n\n publicId = _normalizeOptions2.publicId;\n options = _normalizeOptions2.options;\n options.cloudinaryConfig = (0, _common.mergeCloudinaryConfig)(_this.cloudinaryConfig(), options.cloudinaryConfig || {});\n options.transformation = (0, _common.mergeTransformation)(_this.transformation(), options.transformation || {});\n options.sourceTransformation = options.sourceTransformation || _this.sourceTransformation();\n options.sourceTypes = options.sourceTypes || _this.sourceTypes();\n options.poster = options.poster || posterOptionsForCurrent();\n options.queryParams = options.usageReport ? {\n _s: \"vp-\".concat(\"1.5.7\")\n } : {};\n\n if (options.sourceTypes.indexOf('audio') > -1) {\n builtSrc = new _audioSource.default(publicId, options);\n } else {\n builtSrc = new _videoSource.default(publicId, options);\n }\n\n return builtSrc;\n };\n\n _this.posterOptions = function (options) {\n if (!options) {\n return _posterOptions;\n }\n\n _posterOptions = options;\n return _chainTarget;\n };\n\n _this.cloudinaryConfig = function (config) {\n if (!config) {\n return _cloudinaryConfig;\n }\n\n _cloudinaryConfig = (0, _cloudinary.getCloudinaryInstanceOf)(_cloudinaryCore.default.Cloudinary, config);\n return _chainTarget;\n };\n\n _this.transformation = function (trans) {\n if (!trans) {\n return _transformation;\n }\n\n _transformation = (0, _cloudinary.getCloudinaryInstanceOf)(_cloudinaryCore.default.Transformation, trans);\n return _chainTarget;\n };\n\n _this.sourceTypes = function (types) {\n if (!types) {\n return _sourceTypes;\n }\n\n _sourceTypes = types;\n return _chainTarget;\n };\n\n _this.getCurrentSources = function () {\n return _sources;\n };\n\n _this.sourceTransformation = function (trans) {\n if (!trans) {\n return _sourceTransformation;\n }\n\n _sourceTransformation = trans;\n return _chainTarget;\n };\n\n _this.on = function () {\n var _playerEvents2;\n\n return (_playerEvents2 = _playerEvents).on.apply(_playerEvents2, arguments);\n };\n\n _this.one = function () {\n var _playerEvents3;\n\n return (_playerEvents3 = _playerEvents).one.apply(_playerEvents3, arguments);\n };\n\n _this.off = function () {\n var _playerEvents4;\n\n return (_playerEvents4 = _playerEvents).off.apply(_playerEvents4, arguments);\n };\n\n _this.autoShowRecommendations = function (autoShow) {\n if (autoShow === undefined) {\n return _autoShowRecommendations;\n }\n\n _autoShowRecommendations = autoShow;\n return _chainTarget;\n };\n\n _this.dispose = function () {\n if (_this.playlist()) {\n _this.disposePlaylist();\n }\n\n unsetRecommendations();\n _source = undefined;\n\n _playerEvents.removeAllListeners();\n };\n\n var setRecommendations = function setRecommendations(recommendations, _ref) {\n var _ref$disableAutoShow = _ref.disableAutoShow,\n disableAutoShow = _ref$disableAutoShow === void 0 ? false : _ref$disableAutoShow,\n _ref$itemBuilder = _ref.itemBuilder,\n itemBuilder = _ref$itemBuilder === void 0 ? null : _ref$itemBuilder;\n unsetRecommendations();\n\n if (!Array.isArray(recommendations) && typeof recommendations !== 'function' && !recommendations.then) {\n throw new Error('\"recommendations\" must be either an array or a function');\n }\n\n _recommendations = {};\n\n itemBuilder = itemBuilder || function (source) {\n return {\n source: source instanceof _videoSource.default ? source : _this.buildSource(source),\n action: function action() {\n return _this.source(source);\n }\n };\n };\n\n _recommendations.sourceChangedHandler = function () {\n var trigger = function trigger(sources) {\n if (typeof sources !== 'undefined' && sources.length > 0) {\n var items = sources.map(function (_source) {\n return itemBuilder(_source);\n });\n\n _this.player.trigger('recommendationschanged', {\n items: items\n });\n } else {\n _this.player.trigger('recommendationsnoshow');\n }\n\n _recommendations.sources = sources;\n };\n\n if ((0, _typeInference.isFunction)(recommendations)) {\n trigger(recommendations());\n } else if (recommendations.then) {\n recommendations.then(trigger);\n } else {\n trigger(recommendations);\n }\n };\n\n _this.one('cldsourcechanged', _recommendations.sourceChangedHandler);\n\n _recommendations.endedHandler = function () {\n if (!disableAutoShow && _this.autoShowRecommendations()) {\n _this.player.trigger('recommendationsshow');\n }\n };\n\n _this.on('ended', _recommendations.endedHandler);\n };\n\n var unsetRecommendations = function unsetRecommendations() {\n if (_recommendations) {\n _this.off('cldsourcechanged', _recommendations.sourceChangedHandler);\n\n _this.off('ended', _recommendations.endedHandler);\n\n delete _recommendations.endedHandler;\n delete _recommendations.sourceChangedHandler;\n }\n\n _recommendations = null;\n };\n\n var refresh = function refresh() {\n var src = _this.source();\n\n if (src.poster()) {\n _this.player.poster(src.poster().url());\n }\n\n _sources = src.generateSources().reduce(function (srcs, src) {\n if (src.isAdaptive) {\n var codec = src.type.split('; ')[1] || null;\n\n if (codec && 'MediaSource' in window) {\n var parts = src.type.split('; ');\n var typeStr = \"video/mp4; \".concat(parts[1] || '');\n var canPlay = testCanPlayTypeAndTypeSupported(typeStr);\n\n if (_video.default.browser.IS_ANY_SAFARI) {\n // work around safari saying it cant play h265\n src.type = \"\".concat(parts[0], \"; \").concat((0, _common.codecShorthandTrans)('h264'));\n }\n\n if (canPlay) {\n srcs.push(src);\n }\n } else {\n srcs.push(src);\n }\n } else {\n srcs.push(src);\n }\n\n return srcs;\n }, []);\n\n _this.player.src(_sources);\n\n _lastSource = src;\n _lastPlaylist = _this.playlist();\n };\n\n var testCanPlayTypeAndTypeSupported = function testCanPlayTypeAndTypeSupported(codec) {\n var v = document.createElement('video');\n return v.canPlayType(codec) || 'MediaSource' in window && MediaSource.isTypeSupported(codec);\n };\n\n var posterOptionsForCurrent = function posterOptionsForCurrent() {\n var opts = (0, _assign.assign)({}, _this.posterOptions());\n\n if (opts.transformation) {\n if ((opts.transformation.width || opts.transformation.height) && !opts.transformation.crop) {\n opts.transformation.crop = 'scale';\n }\n }\n\n opts.transformation = (0, _cloudinary.getCloudinaryInstanceOf)(_cloudinaryCore.default.Transformation, opts.transformation || {}); // Set poster dimensions to player actual size.\n // (unless they were explicitly set via `posterOptions`)\n\n var playerEl = _this.player.el();\n\n if (playerEl && playerEl.clientWidth && playerEl.clientHeight && !(0, _cloudinary.isKeyInTransformation)(opts.transformation, 'width') && !(0, _cloudinary.isKeyInTransformation)(opts.transformation, 'height')) {\n var roundUp100 = function roundUp100(val) {\n return 100 * Math.ceil(val / 100);\n };\n\n opts.transformation.width(roundUp100(playerEl.clientWidth)).height(roundUp100(playerEl.clientHeight)).crop('limit');\n }\n\n return opts;\n }; // Handle external (non-cloudinary plugin) source changes (e.g. by ad plugins)\n\n\n var syncState = function syncState(_, data) {\n var src = data.to; // When source is cloudinary's\n\n if (_lastSource && _lastSource.contains(src)) {\n // If plugin state doesn't have an active VideoSource\n if (!_this.source()) {\n // We might have been running a playlist, reset playlist's state.\n if (_lastPlaylist) {\n _this.playlist(_lastPlaylist);\n } // Rebuild last source state without calling vjs's 'src' and 'poster'\n\n\n _this.source(_lastSource, {\n skipRefresh: true\n });\n }\n } else {\n // Used by cloudinary-only components\n _this.player.trigger('cldsourcechanged', {}); // When source isn't cloudinary's - reset the plugin's state.\n\n\n _this.dispose();\n }\n };\n\n _playerEvents = new _eventHandlerRegistry.default(_this.player);\n\n var constructorParams = _slicing.sliceAndUnsetProperties.apply(void 0, [options].concat(CONSTRUCTOR_PARAMS));\n\n (0, _applyWithProps.applyWithProps)(_assertThisInitialized(_this), constructorParams);\n\n _this.on('sourcechanged', syncState);\n\n return _this;\n }\n\n _createClass(CloudinaryContext, [{\n key: \"currentSourceType\",\n value: function currentSourceType() {\n return this.source().getType();\n }\n }, {\n key: \"currentPublicId\",\n value: function currentPublicId() {\n return this.source() && this.source().publicId();\n }\n }, {\n key: \"currentPoster\",\n value: function currentPoster() {\n return this.source() && this.source().poster();\n }\n }]);\n\n return CloudinaryContext;\n}((0, _mixin2.mixin)(_playlistable.default));\n\nfunction _default() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n options.chainTarget = options.chainTarget || this;\n this.cloudinary = new CloudinaryContext(this, options);\n}\n\n//# sourceURL=webpack://cloudinaryVideoPlayer/./plugins/cloudinary/index.js?");
|
|
832
832
|
|
|
833
833
|
/***/ }),
|
|
834
834
|
|
|
@@ -972,7 +972,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extr
|
|
|
972
972
|
/***/ (function(module, exports, __webpack_require__) {
|
|
973
973
|
|
|
974
974
|
"use strict";
|
|
975
|
-
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar contextMenuContent = function contextMenuContent(player) {\n var isLooping = player.loop();\n var isPaused = player.paused();\n var isMuted = player.muted();\n var isFullscreen = player.isFullscreen();\n var aboutMenuItem = {\n label: '<span class=\"player-version\">Cloudinary Player v' + \"1.5.
|
|
975
|
+
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar contextMenuContent = function contextMenuContent(player) {\n var isLooping = player.loop();\n var isPaused = player.paused();\n var isMuted = player.muted();\n var isFullscreen = player.isFullscreen();\n var aboutMenuItem = {\n label: '<span class=\"player-version\">Cloudinary Player v' + \"1.5.7\" + '</span>'\n };\n\n if (!player.controls()) {\n return [aboutMenuItem];\n }\n\n return [{\n label: isLooping ? 'Unloop' : 'Loop',\n listener: function listener() {\n player.loop(!isLooping);\n }\n }, {\n label: isPaused ? 'Play' : 'Pause',\n listener: function listener() {\n if (isPaused) {\n player.play();\n } else {\n player.pause();\n }\n }\n }, {\n label: isMuted ? 'Unmute' : 'Mute',\n listener: function listener() {\n player.muted(!isMuted);\n }\n }, {\n label: isFullscreen ? 'Exit Fullscreen' : 'Fullscreen',\n listener: function listener() {\n if (isFullscreen) {\n player.exitFullscreen();\n } else {\n player.requestFullscreen();\n }\n }\n }, aboutMenuItem];\n};\n\nvar _default = contextMenuContent;\nexports.default = _default;\n\n//# sourceURL=webpack://cloudinaryVideoPlayer/./plugins/context-menu/contextMenuContent.js?");
|
|
976
976
|
|
|
977
977
|
/***/ }),
|
|
978
978
|
|
|
@@ -1368,7 +1368,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n
|
|
|
1368
1368
|
/***/ (function(module, exports, __webpack_require__) {
|
|
1369
1369
|
|
|
1370
1370
|
"use strict";
|
|
1371
|
-
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _video = _interopRequireDefault(__webpack_require__(/*! video.js */ \"../node_modules/video.js/dist/alt/video.core.js-exposed\"));\n\n__webpack_require__(/*! ./components */ \"./components/index.js\");\n\nvar _plugins = _interopRequireDefault(__webpack_require__(/*! ./plugins */ \"./plugins/index.js\"));\n\nvar _utils = _interopRequireDefault(__webpack_require__(/*! ./utils */ \"./utils/index.js\"));\n\nvar _defaults = _interopRequireDefault(__webpack_require__(/*! ./config/defaults */ \"./config/defaults.js\"));\n\nvar _eventable = _interopRequireDefault(__webpack_require__(/*! ./mixins/eventable */ \"./mixins/eventable.js\"));\n\nvar _extendedEvents = _interopRequireDefault(__webpack_require__(/*! ./extended-events */ \"./extended-events.js\"));\n\nvar _playlistWidget = _interopRequireDefault(__webpack_require__(/*! ./components/playlist/playlist-widget */ \"./components/playlist/playlist-widget.js\"));\n\nvar _videoSource = _interopRequireDefault(__webpack_require__(/*! ./plugins/cloudinary/models/video-source/video-source */ \"./plugins/cloudinary/models/video-source/video-source.js\"));\n\nvar _typeInference = __webpack_require__(/*! ./utils/type-inference */ \"./utils/type-inference.js\");\n\nvar _videoPlayer = __webpack_require__(/*! ./video-player.utils */ \"./video-player.utils.js\");\n\nvar _videoPlayer2 = __webpack_require__(/*! ./video-player.const */ \"./video-player.const.js\");\n\nvar _validatorsFunctions = __webpack_require__(/*! ./validators/validators-functions */ \"./validators/validators-functions.js\");\n\nvar _validators = __webpack_require__(/*! ./validators/validators */ \"./validators/validators.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n// Register all plugins\nObject.keys(_plugins.default).forEach(function (key) {\n _video.default.registerPlugin(key, _plugins.default[key]);\n});\n(0, _videoPlayer.overrideDefaultVideojsComponents)();\nvar _allowUsageReport = true;\n\nvar VideoPlayer = /*#__PURE__*/function (_Utils$mixin) {\n _inherits(VideoPlayer, _Utils$mixin);\n\n var _super = _createSuper(VideoPlayer);\n\n function VideoPlayer(elem, initOptions, ready) {\n var _this;\n\n _classCallCheck(this, VideoPlayer);\n\n _this = _super.call(this);\n _this._playlistWidget = null;\n _this.nbCalls = 0;\n _this._firstPlayed = false;\n _this.videoElement = (0, _videoPlayer.getResolveVideoElement)(elem);\n _this.options = (0, _videoPlayer.extractOptions)(_this.videoElement, initOptions);\n _this._videojsOptions = _this.options.videojsOptions; // Make sure to add 'video-js' class before creating videojs instance\n\n _this.videoElement.classList.add('video-js'); // Handle WebFont loading\n\n\n _utils.default.fontFace(_this.videoElement, _this.playerOptions); // Handle play button options\n\n\n _utils.default.playButton(_this.videoElement, _this._videojsOptions); // Dash plugin - available in full (not light) build only\n\n\n if (_plugins.default.dashPlugin) {\n _plugins.default.dashPlugin();\n }\n\n _this.videojs = (0, _video.default)(_this.videoElement, _this._videojsOptions);\n _this._isPlayerConfigValid = (0, _validatorsFunctions.isValidConfig)(_this.options, _validators.playerValidators);\n\n if (!_this._isPlayerConfigValid) {\n _this.videojs.error('invalid player configuration');\n\n return _possibleConstructorReturn(_this);\n }\n\n if (_this._videojsOptions.muted) {\n _this.videojs.volume(0.4);\n }\n\n if (_this.playerOptions.fluid) {\n _this.fluid(_this.playerOptions.fluid);\n }\n /* global google */\n\n\n var loaded = {\n contribAdsLoaded: (0, _typeInference.isFunction)(_this.videojs.ads),\n imaAdsLoaded: (typeof google === \"undefined\" ? \"undefined\" : _typeof(google)) === 'object' && _typeof(google.ima) === 'object'\n }; // #if (!process.env.WEBPACK_BUILD_LIGHT)\n // this.interactionArea = interactionAreaService(this, this.playerOptions, this._videojsOptions);\n // #endif\n\n _this._setCssClasses();\n\n _this._initPlugins(loaded);\n\n _this._initPlaylistWidget();\n\n _this._initJumpButtons();\n\n _this._setVideoJsListeners(ready);\n\n return _this;\n }\n\n _createClass(VideoPlayer, [{\n key: \"_setVideoJsListeners\",\n value: function _setVideoJsListeners(ready) {\n var _this2 = this;\n\n this.videojs.on('error', function () {\n var error = _this2.videojs.error();\n\n if (error) {\n var type = _this2._isPlayerConfigValid && _this2.videojs.cloudinary.currentSourceType();\n\n if (error.code === 4 && (type === 'VideoSource' || type === 'AudioSource')) {\n _this2.videojs.error(null);\n\n _utils.default.handleCldError(_this2, _this2.playerOptions);\n } else {\n _this2.videojs.clearTimeout(_this2.reTryId);\n }\n }\n });\n this.videojs.on('play', function () {\n _this2.videojs.clearTimeout(_this2.reTryId);\n });\n this.videojs.on('canplaythrough', function () {\n _this2.videojs.clearTimeout(_this2.reTryId);\n });\n this.videojs.ready(function () {\n _this2._onReady();\n\n if (ready) {\n ready(_this2);\n } // #if (!process.env.WEBPACK_BUILD_LIGHT)\n // this.interactionArea.init();\n // #endif\n\n });\n\n if (this.adsEnabled && Object.keys(this.playerOptions.ads).length > 0 && _typeof(this.videojs.ima) === 'object') {\n if (this.playerOptions.ads.adsInPlaylist === 'first-video') {\n this.videojs.one('sourcechanged', function () {\n _this2.videojs.ima.playAd();\n });\n } else {\n this.videojs.on('sourcechanged', function () {\n _this2.videojs.ima.playAd();\n });\n }\n }\n }\n }, {\n key: \"_initPlugins\",\n value: function _initPlugins(loaded) {\n // #if (!process.env.WEBPACK_BUILD_LIGHT)\n // this.adsEnabled = this._initIma(loaded);\n // #endif\n this._initAutoplay();\n\n this._initContextMenu();\n\n this._initPerSrcBehaviors();\n\n this._initCloudinary();\n\n this._initAnalytics();\n\n this._initFloatingPlayer();\n\n this._initColors();\n\n this._initTextTracks();\n\n this._initSeekThumbs();\n }\n }, {\n key: \"_isFullScreen\",\n value: function _isFullScreen() {\n return this.videojs.player().isFullscreen();\n }\n }, {\n key: \"_initIma\",\n value: function _initIma(loaded) {\n if (!loaded.contribAdsLoaded || !loaded.imaAdsLoaded) {\n if (this.playerOptions.ads) {\n if (!loaded.contribAdsLoaded) {\n console.log('contribAds is not loaded');\n }\n\n if (!loaded.imaAdsLoaded) {\n console.log('imaSdk is not loaded');\n }\n }\n\n return false;\n }\n\n if (!this.playerOptions.ads) {\n this.playerOptions.ads = {};\n }\n\n var opts = this.playerOptions.ads;\n\n if (Object.keys(opts).length === 0) {\n return false;\n }\n\n this.videojs.ima({\n id: this.el().id,\n adTagUrl: opts.adTagUrl,\n disableFlashAds: true,\n prerollTimeout: opts.prerollTimeout || 5000,\n postrollTimeout: opts.postrollTimeout || 5000,\n showCountdown: opts.showCountdown !== false,\n adLabel: opts.adLabel || 'Advertisement',\n locale: opts.locale || 'en',\n autoPlayAdBreaks: opts.autoPlayAdBreaks !== false,\n debug: true\n });\n return true;\n }\n }, {\n key: \"setTextTracks\",\n value: function setTextTracks(conf) {\n // remove current text tracks\n var currentTracks = this.videojs.remoteTextTracks();\n\n if (currentTracks) {\n for (var i = currentTracks.tracks_.length - 1; i >= 0; i--) {\n this.videojs.removeRemoteTextTrack(currentTracks.tracks_[i]);\n }\n }\n\n if (conf) {\n var tracks = Object.keys(conf);\n var allTracks = [];\n\n for (var _i = 0, _tracks = tracks; _i < _tracks.length; _i++) {\n var track = _tracks[_i];\n\n if (Array.isArray(conf[track])) {\n var trks = conf[track];\n\n for (var _i2 = 0; _i2 < trks.length; _i2++) {\n allTracks.push(VideoPlayer.buildTextTrackObj(track, trks[_i2]));\n }\n } else {\n allTracks.push(VideoPlayer.buildTextTrackObj(track, conf[track]));\n }\n }\n\n _utils.default.filterAndAddTextTracks(allTracks, this.videojs);\n }\n }\n }, {\n key: \"_initSeekThumbs\",\n value: function _initSeekThumbs() {\n var _this3 = this;\n\n if (this.playerOptions.seekThumbnails) {\n this.videojs.on('cldsourcechanged', function (e, _ref) {\n var source = _ref.source;\n\n // Bail if...\n if (source.getType() === 'AudioSource' || // it's an audio player\n _this3.videojs && _this3.videojs.activePlugins_ && _this3.videojs.activePlugins_.vr // It's a VR (i.e. 360) video\n ) {\n return;\n }\n\n var cloudinaryConfig = source.cloudinaryConfig();\n var publicId = source.publicId();\n var transformations = source.transformation().toOptions();\n\n if (transformations && transformations.streaming_profile) {\n delete transformations.streaming_profile;\n }\n\n transformations.flags = transformations.flags || [];\n transformations.flags.push('sprite'); // build VTT url\n\n var vttSrc = cloudinaryConfig.video_url(publicId + '.vtt', {\n transformation: transformations\n }); // vttThumbnails must be called differently on init and on source update.\n\n if ((0, _typeInference.isFunction)(_this3.videojs.vttThumbnails)) {\n _this3.videojs.vttThumbnails({\n src: vttSrc\n });\n } else {\n _this3.videojs.vttThumbnails.src(vttSrc);\n }\n });\n }\n }\n }, {\n key: \"_initColors\",\n value: function _initColors() {\n this.videojs.colors(this.playerOptions.colors ? {\n 'colors': this.playerOptions.colors\n } : {});\n } // #if (!process.env.WEBPACK_BUILD_LIGHT)\n // _initQualitySelector() {\n // if (this._videojsOptions.controlBar && this.playerOptions.qualitySelector !== false) {\n // if (videojs.browser.IE_VERSION === null) {\n // this.videojs.httpSourceSelector({ default: 'auto' });\n // }\n // \n // this.videojs.on('loadedmetadata', () => {\n // qualitySelector.init(this.videojs);\n // });\n // \n // // Show only if more then one option available\n // this.videojs.on('loadeddata', () => {\n // qualitySelector.setVisibility(this.videojs);\n // });\n // }\n // }\n // #endif\n\n }, {\n key: \"_initTextTracks\",\n value: function _initTextTracks() {\n var _this4 = this;\n\n this.videojs.on('refreshTextTracks', function (e, tracks) {\n _this4.setTextTracks(tracks);\n });\n }\n }, {\n key: \"_initPerSrcBehaviors\",\n value: function _initPerSrcBehaviors() {\n if (this.videojs.perSourceBehaviors) {\n this.videojs.perSourceBehaviors();\n }\n }\n }, {\n key: \"_initJumpButtons\",\n value: function _initJumpButtons() {\n if (!this.playerOptions.showJumpControls && this.videojs.controlBar) {\n this.videojs.controlBar.removeChild('JumpForwardButton');\n this.videojs.controlBar.removeChild('JumpBackButton');\n }\n }\n }, {\n key: \"_initCloudinary\",\n value: function _initCloudinary() {\n var opts = this.playerOptions.cloudinary;\n opts.chainTarget = this;\n\n if (opts.secure !== false) {\n this.playerOptions.cloudinary.cloudinaryConfig.config('secure', true);\n }\n\n this.videojs.cloudinary(this.playerOptions.cloudinary);\n }\n }, {\n key: \"_initAnalytics\",\n value: function _initAnalytics() {\n var analyticsOpts = this.playerOptions.analytics;\n\n if (!window.ga && analyticsOpts) {\n console.error('Google Analytics script is missing');\n return;\n }\n\n if (analyticsOpts) {\n var opts = _typeof(analyticsOpts) === 'object' ? analyticsOpts : {};\n this.videojs.analytics(opts);\n }\n }\n }, {\n key: \"reTryVideo\",\n value: function reTryVideo(maxNumberOfCalls, timeout) {\n var _this5 = this;\n\n if (!this.isVideoReady()) {\n if (this.nbCalls < maxNumberOfCalls) {\n this.nbCalls++;\n this.reTryId = this.videojs.setTimeout(function () {\n return _this5.reTryVideo(maxNumberOfCalls, timeout);\n }, timeout);\n } else {\n var e = new Error('Video is not ready please try later');\n this.videojs.trigger('error', e);\n }\n }\n }\n }, {\n key: \"isVideoReady\",\n value: function isVideoReady() {\n var s = this.videojs.readyState();\n\n if (s >= (/iPad|iPhone|iPod/.test(navigator.userAgent) ? 1 : 4)) {\n this.nbCalls = 0;\n return true;\n }\n\n return false;\n }\n }, {\n key: \"_initPlaylistWidget\",\n value: function _initPlaylistWidget() {\n var _this6 = this;\n\n this.videojs.on('playlistcreated', function () {\n if (_this6._playlistWidget) {\n _this6._playlistWidget.dispose();\n }\n\n var plwOptions = _this6.playerOptions.playlistWidget;\n\n if ((0, _typeInference.isPlainObject)(plwOptions)) {\n if (_this6.playerOptions.fluid) {\n plwOptions.fluid = true;\n }\n\n if (_this6.playerOptions.cloudinary.fontFace) {\n plwOptions.fontFace = _this6.playerOptions.cloudinary.fontFace;\n }\n\n _this6._playlistWidget = new _playlistWidget.default(_this6.videojs, plwOptions);\n }\n });\n }\n }, {\n key: \"playlistWidget\",\n value: function playlistWidget(options) {\n if (!options && !this._playlistWidget) {\n return false;\n }\n\n if (!options && this._playlistWidget) {\n return this._playlistWidget;\n }\n\n if ((0, _typeInference.isPlainObject)(options)) {\n this._playlistWidget.options(options);\n }\n\n return this._playlistWidget;\n }\n }, {\n key: \"_initAutoplay\",\n value: function _initAutoplay() {\n var autoplayMode = this.playerOptions.autoplayMode;\n\n if (autoplayMode === 'on-scroll') {\n this.videojs.autoplayOnScroll();\n }\n }\n }, {\n key: \"_initContextMenu\",\n value: function _initContextMenu() {\n if (!this.playerOptions.hideContextMenu) {\n this.videojs.contextMenu(_defaults.default.contextMenu);\n }\n }\n }, {\n key: \"_initFloatingPlayer\",\n value: function _initFloatingPlayer() {\n if (this.playerOptions.floatingWhenNotVisible !== _videoPlayer2.FLOATING_TO.NONE) {\n this.videojs.floatingPlayer({\n 'floatTo': this.playerOptions.floatingWhenNotVisible\n });\n }\n }\n }, {\n key: \"_setCssClasses\",\n value: function _setCssClasses() {\n this.videojs.addClass(_utils.default.CLASS_PREFIX);\n this.videojs.addClass(_utils.default.playerClassPrefix(this.videojs));\n\n _utils.default.setSkinClassPrefix(this.videojs, _utils.default.skinClassPrefix(this.videojs));\n\n if (_video.default.browser.IE_VERSION === 11) {\n this.videojs.addClass('cld-ie11');\n }\n }\n }, {\n key: \"_onReady\",\n value: function _onReady() {\n this._setExtendedEvents(); // Load first video (mainly to support video tag 'source' and 'public-id' attributes)\n\n\n var source = this.playerOptions.source || this.playerOptions.publicId;\n\n if (source) {\n this.source(source, this.playerOptions);\n }\n }\n }, {\n key: \"_setExtendedEvents\",\n value: function _setExtendedEvents() {\n var _this7 = this;\n\n var events = [];\n\n if (this.playerOptions.playedEventPercents) {\n events.push({\n type: 'percentsplayed',\n percents: this.playerOptions.playedEventPercents\n });\n }\n\n if (this.playerOptions.playedEventTimes) {\n events.push({\n type: 'timeplayed',\n times: this.playerOptions.playedEventTimes\n });\n }\n\n events.push.apply(events, ['seek', 'mute', 'unmute', 'qualitychanged']);\n var extendedEvents = new _extendedEvents.default(this.videojs, {\n events: events\n });\n Object.keys(extendedEvents.events).forEach(function (_event) {\n var handler = function handler(event, data) {\n _this7.videojs.trigger({\n type: _event,\n eventData: data\n });\n };\n\n extendedEvents.on(_event, handler);\n });\n }\n }, {\n key: \"cloudinaryConfig\",\n value: function cloudinaryConfig(config) {\n return this.videojs.cloudinary.cloudinaryConfig(config);\n }\n }, {\n key: \"playerOptions\",\n get: function get() {\n return this.options.playerOptions;\n }\n }, {\n key: \"currentPublicId\",\n value: function currentPublicId() {\n return this.videojs.cloudinary.currentPublicId();\n }\n }, {\n key: \"currentSourceUrl\",\n value: function currentSourceUrl() {\n return this.videojs.currentSource().src;\n }\n }, {\n key: \"currentPoster\",\n value: function currentPoster() {\n return this.videojs.cloudinary.currentPoster();\n }\n }, {\n key: \"source\",\n value: function source(publicId) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!this._isPlayerConfigValid) {\n return;\n }\n\n var isSourceConfigValid = (0, _validatorsFunctions.isValidConfig)(options, _validators.sourceValidators);\n\n if (!isSourceConfigValid) {\n this.videojs.error('invalid source configuration');\n return;\n }\n\n if (publicId instanceof _videoSource.default) {\n return this.videojs.cloudinary.source(publicId, options);\n } // Interactive plugin - available in full (not light) build only\n\n\n if (this.videojs.interactive) {\n this.videojs.interactive(this.videojs, options);\n }\n\n if (VideoPlayer.allowUsageReport()) {\n options.usageReport = true;\n }\n\n this.setTextTracks(options.textTracks); // #if (!process.env.WEBPACK_BUILD_LIGHT)\n // this._initQualitySelector();\n // #endif\n\n clearTimeout(this.reTryId);\n this.nbCalls = 0;\n var maxTries = this.videojs.options_.maxTries || 3;\n var videoReadyTimeout = this.videojs.options_.videoTimeout || 55000;\n this.reTryVideo(maxTries, videoReadyTimeout);\n return this.videojs.cloudinary.source(publicId, options);\n }\n }, {\n key: \"posterOptions\",\n value: function posterOptions(options) {\n return this.videojs.cloudinary.posterOptions(options);\n }\n }, {\n key: \"skin\",\n value: function skin(name) {\n if (name !== undefined && (0, _typeInference.isString)(name)) {\n _utils.default.setSkinClassPrefix(this.videojs, name);\n\n var playlistWidget = this.playlistWidget();\n\n if (this.playlistWidget()) {\n playlistWidget.setSkin();\n }\n }\n\n return _utils.default.skinClassPrefix(this.videojs);\n }\n }, {\n key: \"playlist\",\n value: function playlist(sources) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n return this.videojs.cloudinary.playlist(sources, options);\n }\n }, {\n key: \"playlistByTag\",\n value: function playlistByTag(tag) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n return this.videojs.cloudinary.playlistByTag(tag, options);\n }\n }, {\n key: \"sourcesByTag\",\n value: function sourcesByTag(tag) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n return this.videojs.cloudinary.sourcesByTag(tag, options);\n }\n }, {\n key: \"fluid\",\n value: function fluid(bool) {\n if (bool === undefined) {\n return this.videojs.fluid();\n }\n\n if (bool) {\n this.videojs.addClass(_videoPlayer2.FLUID_CLASS_NAME);\n } else {\n this.videojs.removeClass(_videoPlayer2.FLUID_CLASS_NAME);\n }\n\n this.videojs.fluid(bool);\n this.videojs.trigger('fluid', bool);\n return this;\n }\n }, {\n key: \"play\",\n value: function play() {\n this.playWasCalled = true;\n this.videojs.play();\n return this;\n }\n }, {\n key: \"stop\",\n value: function stop() {\n this.pause();\n this.currentTime(0);\n return this;\n }\n }, {\n key: \"playPrevious\",\n value: function playPrevious() {\n this.playlist().playPrevious();\n return this;\n }\n }, {\n key: \"playNext\",\n value: function playNext() {\n this.playlist().playNext();\n return this;\n }\n }, {\n key: \"transformation\",\n value: function transformation(trans) {\n return this.videojs.cloudinary.transformation(trans);\n }\n }, {\n key: \"sourceTypes\",\n value: function sourceTypes(types) {\n return this.videojs.cloudinary.sourceTypes(types);\n }\n }, {\n key: \"sourceTransformation\",\n value: function sourceTransformation(trans) {\n return this.videojs.cloudinary.sourceTransformation(trans);\n }\n }, {\n key: \"autoShowRecommendations\",\n value: function autoShowRecommendations(autoShow) {\n return this.videojs.cloudinary.autoShowRecommendations(autoShow);\n }\n }, {\n key: \"duration\",\n value: function duration() {\n return this.videojs.duration();\n }\n }, {\n key: \"height\",\n value: function height(dimension) {\n if (!dimension) {\n return this.videojs.height();\n }\n\n this.videojs.height(dimension);\n return this;\n }\n }, {\n key: \"width\",\n value: function width(dimension) {\n if (!dimension) {\n return this.videojs.width();\n }\n\n this.videojs.width(dimension);\n return this;\n }\n }, {\n key: \"volume\",\n value: function volume(_volume) {\n if (!_volume) {\n return this.videojs.volume();\n }\n\n this.videojs.volume(_volume);\n return this;\n }\n }, {\n key: \"mute\",\n value: function mute() {\n if (!this.isMuted()) {\n this.videojs.muted(true);\n }\n\n return this;\n }\n }, {\n key: \"unmute\",\n value: function unmute() {\n if (this.isMuted()) {\n this.videojs.muted(false);\n }\n\n return this;\n }\n }, {\n key: \"isMuted\",\n value: function isMuted() {\n return this.videojs.muted();\n }\n }, {\n key: \"pause\",\n value: function pause() {\n this.videojs.pause();\n return this;\n }\n }, {\n key: \"currentTime\",\n value: function currentTime(offsetSeconds) {\n if (!offsetSeconds && offsetSeconds !== 0) {\n return this.videojs.currentTime();\n }\n\n this.videojs.currentTime(offsetSeconds);\n return this;\n }\n }, {\n key: \"maximize\",\n value: function maximize() {\n if (!this.isMaximized()) {\n this.videojs.requestFullscreen();\n }\n\n return this;\n }\n }, {\n key: \"exitMaximize\",\n value: function exitMaximize() {\n if (this.isMaximized()) {\n this.videojs.exitFullscreen();\n }\n\n return this;\n }\n }, {\n key: \"isMaximized\",\n value: function isMaximized() {\n return this.videojs.isFullscreen();\n }\n }, {\n key: \"dispose\",\n value: function dispose() {\n this.videojs.dispose();\n }\n }, {\n key: \"controls\",\n value: function controls(bool) {\n if (bool === undefined) {\n return this.videojs.controls();\n }\n\n this.videojs.controls(bool);\n return this;\n }\n }, {\n key: \"ima\",\n value: function ima() {\n return {\n playAd: this.videojs.ima.playAd\n };\n }\n }, {\n key: \"loop\",\n value: function loop(bool) {\n if (bool === undefined) {\n return this.videojs.loop();\n }\n\n this.videojs.loop(bool);\n return this;\n }\n }, {\n key: \"el\",\n value: function el() {\n return this.videojs.el();\n }\n }], [{\n key: \"all\",\n value: function all(selector) {\n var nodeList = document.querySelectorAll(selector);\n var players = [];\n\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n for (var i = 0; i < nodeList.length; i++) {\n players.push(_construct(VideoPlayer, [nodeList[i]].concat(args)));\n }\n\n return players;\n }\n }, {\n key: \"allowUsageReport\",\n value: function allowUsageReport(bool) {\n if (bool === undefined) {\n return _allowUsageReport;\n }\n\n _allowUsageReport = !!bool;\n return _allowUsageReport;\n }\n }, {\n key: \"buildTextTrackObj\",\n value: function buildTextTrackObj(type, conf) {\n return {\n kind: type,\n label: conf.label,\n srclang: conf.language,\n default: !!conf.default,\n src: conf.url\n };\n }\n }]);\n\n return VideoPlayer;\n}(_utils.default.mixin(_eventable.default));\n\nvar _default = VideoPlayer;\nexports.default = _default;\n\n//# sourceURL=webpack://cloudinaryVideoPlayer/./video-player.js?");
|
|
1371
|
+
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _video = _interopRequireDefault(__webpack_require__(/*! video.js */ \"../node_modules/video.js/dist/alt/video.core.js-exposed\"));\n\n__webpack_require__(/*! ./components */ \"./components/index.js\");\n\nvar _plugins = _interopRequireDefault(__webpack_require__(/*! ./plugins */ \"./plugins/index.js\"));\n\nvar _utils = _interopRequireDefault(__webpack_require__(/*! ./utils */ \"./utils/index.js\"));\n\nvar _defaults = _interopRequireDefault(__webpack_require__(/*! ./config/defaults */ \"./config/defaults.js\"));\n\nvar _eventable = _interopRequireDefault(__webpack_require__(/*! ./mixins/eventable */ \"./mixins/eventable.js\"));\n\nvar _extendedEvents = _interopRequireDefault(__webpack_require__(/*! ./extended-events */ \"./extended-events.js\"));\n\nvar _playlistWidget = _interopRequireDefault(__webpack_require__(/*! ./components/playlist/playlist-widget */ \"./components/playlist/playlist-widget.js\"));\n\nvar _videoSource = _interopRequireDefault(__webpack_require__(/*! ./plugins/cloudinary/models/video-source/video-source */ \"./plugins/cloudinary/models/video-source/video-source.js\"));\n\nvar _typeInference = __webpack_require__(/*! ./utils/type-inference */ \"./utils/type-inference.js\");\n\nvar _videoPlayer = __webpack_require__(/*! ./video-player.utils */ \"./video-player.utils.js\");\n\nvar _videoPlayer2 = __webpack_require__(/*! ./video-player.const */ \"./video-player.const.js\");\n\nvar _validatorsFunctions = __webpack_require__(/*! ./validators/validators-functions */ \"./validators/validators-functions.js\");\n\nvar _validators = __webpack_require__(/*! ./validators/validators */ \"./validators/validators.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n// Register all plugins\nObject.keys(_plugins.default).forEach(function (key) {\n _video.default.registerPlugin(key, _plugins.default[key]);\n});\n(0, _videoPlayer.overrideDefaultVideojsComponents)();\nvar _allowUsageReport = true;\n\nvar VideoPlayer = /*#__PURE__*/function (_Utils$mixin) {\n _inherits(VideoPlayer, _Utils$mixin);\n\n var _super = _createSuper(VideoPlayer);\n\n function VideoPlayer(elem, initOptions, ready) {\n var _this;\n\n _classCallCheck(this, VideoPlayer);\n\n _this = _super.call(this);\n _this._playlistWidget = null;\n _this.nbCalls = 0;\n _this._firstPlayed = false;\n _this.videoElement = (0, _videoPlayer.getResolveVideoElement)(elem);\n _this.options = (0, _videoPlayer.extractOptions)(_this.videoElement, initOptions);\n _this._videojsOptions = _this.options.videojsOptions; // Make sure to add 'video-js' class before creating videojs instance\n\n _this.videoElement.classList.add('video-js'); // Handle WebFont loading\n\n\n _utils.default.fontFace(_this.videoElement, _this.playerOptions); // Handle play button options\n\n\n _utils.default.playButton(_this.videoElement, _this._videojsOptions); // Dash plugin - available in full (not light) build only\n\n\n if (_plugins.default.dashPlugin) {\n _plugins.default.dashPlugin();\n }\n\n _this.videojs = (0, _video.default)(_this.videoElement, _this._videojsOptions); // to do, should be change by isValidConfig\n\n _this._isPlayerConfigValid = true;\n (0, _validatorsFunctions.isValidConfig)(_this.options, _validators.playerValidators);\n\n if (!_this._isPlayerConfigValid) {\n _this.videojs.error('invalid player configuration');\n\n return _possibleConstructorReturn(_this);\n }\n\n if (_this._videojsOptions.muted) {\n _this.videojs.volume(0.4);\n }\n\n if (_this.playerOptions.fluid) {\n _this.fluid(_this.playerOptions.fluid);\n }\n /* global google */\n\n\n var loaded = {\n contribAdsLoaded: (0, _typeInference.isFunction)(_this.videojs.ads),\n imaAdsLoaded: (typeof google === \"undefined\" ? \"undefined\" : _typeof(google)) === 'object' && _typeof(google.ima) === 'object'\n }; // #if (!process.env.WEBPACK_BUILD_LIGHT)\n // this.interactionArea = interactionAreaService(this, this.playerOptions, this._videojsOptions);\n // #endif\n\n _this._setCssClasses();\n\n _this._initPlugins(loaded);\n\n _this._initPlaylistWidget();\n\n _this._initJumpButtons();\n\n _this._setVideoJsListeners(ready);\n\n return _this;\n }\n\n _createClass(VideoPlayer, [{\n key: \"_setVideoJsListeners\",\n value: function _setVideoJsListeners(ready) {\n var _this2 = this;\n\n this.videojs.on('error', function () {\n var error = _this2.videojs.error();\n\n if (error) {\n var type = _this2._isPlayerConfigValid && _this2.videojs.cloudinary.currentSourceType();\n\n if (error.code === 4 && (type === 'VideoSource' || type === 'AudioSource')) {\n _this2.videojs.error(null);\n\n _utils.default.handleCldError(_this2, _this2.playerOptions);\n } else {\n _this2.videojs.clearTimeout(_this2.reTryId);\n }\n }\n });\n this.videojs.on('play', function () {\n _this2.videojs.clearTimeout(_this2.reTryId);\n });\n this.videojs.on('canplaythrough', function () {\n _this2.videojs.clearTimeout(_this2.reTryId);\n });\n this.videojs.ready(function () {\n _this2._onReady();\n\n if (ready) {\n ready(_this2);\n } // #if (!process.env.WEBPACK_BUILD_LIGHT)\n // this.interactionArea.init();\n // #endif\n\n });\n\n if (this.adsEnabled && Object.keys(this.playerOptions.ads).length > 0 && _typeof(this.videojs.ima) === 'object') {\n if (this.playerOptions.ads.adsInPlaylist === 'first-video') {\n this.videojs.one('sourcechanged', function () {\n _this2.videojs.ima.playAd();\n });\n } else {\n this.videojs.on('sourcechanged', function () {\n _this2.videojs.ima.playAd();\n });\n }\n }\n }\n }, {\n key: \"_initPlugins\",\n value: function _initPlugins(loaded) {\n // #if (!process.env.WEBPACK_BUILD_LIGHT)\n // this.adsEnabled = this._initIma(loaded);\n // #endif\n this._initAutoplay();\n\n this._initContextMenu();\n\n this._initPerSrcBehaviors();\n\n this._initCloudinary();\n\n this._initAnalytics();\n\n this._initFloatingPlayer();\n\n this._initColors();\n\n this._initTextTracks();\n\n this._initSeekThumbs();\n }\n }, {\n key: \"_isFullScreen\",\n value: function _isFullScreen() {\n return this.videojs.player().isFullscreen();\n }\n }, {\n key: \"_initIma\",\n value: function _initIma(loaded) {\n if (!loaded.contribAdsLoaded || !loaded.imaAdsLoaded) {\n if (this.playerOptions.ads) {\n if (!loaded.contribAdsLoaded) {\n console.log('contribAds is not loaded');\n }\n\n if (!loaded.imaAdsLoaded) {\n console.log('imaSdk is not loaded');\n }\n }\n\n return false;\n }\n\n if (!this.playerOptions.ads) {\n this.playerOptions.ads = {};\n }\n\n var opts = this.playerOptions.ads;\n\n if (Object.keys(opts).length === 0) {\n return false;\n }\n\n this.videojs.ima({\n id: this.el().id,\n adTagUrl: opts.adTagUrl,\n disableFlashAds: true,\n prerollTimeout: opts.prerollTimeout || 5000,\n postrollTimeout: opts.postrollTimeout || 5000,\n showCountdown: opts.showCountdown !== false,\n adLabel: opts.adLabel || 'Advertisement',\n locale: opts.locale || 'en',\n autoPlayAdBreaks: opts.autoPlayAdBreaks !== false,\n debug: true\n });\n return true;\n }\n }, {\n key: \"setTextTracks\",\n value: function setTextTracks(conf) {\n // remove current text tracks\n var currentTracks = this.videojs.remoteTextTracks();\n\n if (currentTracks) {\n for (var i = currentTracks.tracks_.length - 1; i >= 0; i--) {\n this.videojs.removeRemoteTextTrack(currentTracks.tracks_[i]);\n }\n }\n\n if (conf) {\n var tracks = Object.keys(conf);\n var allTracks = [];\n\n for (var _i = 0, _tracks = tracks; _i < _tracks.length; _i++) {\n var track = _tracks[_i];\n\n if (Array.isArray(conf[track])) {\n var trks = conf[track];\n\n for (var _i2 = 0; _i2 < trks.length; _i2++) {\n allTracks.push(VideoPlayer.buildTextTrackObj(track, trks[_i2]));\n }\n } else {\n allTracks.push(VideoPlayer.buildTextTrackObj(track, conf[track]));\n }\n }\n\n _utils.default.filterAndAddTextTracks(allTracks, this.videojs);\n }\n }\n }, {\n key: \"_initSeekThumbs\",\n value: function _initSeekThumbs() {\n var _this3 = this;\n\n if (this.playerOptions.seekThumbnails) {\n this.videojs.on('cldsourcechanged', function (e, _ref) {\n var source = _ref.source;\n\n // Bail if...\n if (source.getType() === 'AudioSource' || // it's an audio player\n _this3.videojs && _this3.videojs.activePlugins_ && _this3.videojs.activePlugins_.vr // It's a VR (i.e. 360) video\n ) {\n return;\n }\n\n var cloudinaryConfig = source.cloudinaryConfig();\n var publicId = source.publicId();\n var transformations = source.transformation().toOptions();\n\n if (transformations && transformations.streaming_profile) {\n delete transformations.streaming_profile;\n }\n\n transformations.flags = transformations.flags || [];\n transformations.flags.push('sprite'); // build VTT url\n\n var vttSrc = cloudinaryConfig.video_url(publicId + '.vtt', {\n transformation: transformations\n }); // vttThumbnails must be called differently on init and on source update.\n\n if ((0, _typeInference.isFunction)(_this3.videojs.vttThumbnails)) {\n _this3.videojs.vttThumbnails({\n src: vttSrc\n });\n } else {\n _this3.videojs.vttThumbnails.src(vttSrc);\n }\n });\n }\n }\n }, {\n key: \"_initColors\",\n value: function _initColors() {\n this.videojs.colors(this.playerOptions.colors ? {\n 'colors': this.playerOptions.colors\n } : {});\n } // #if (!process.env.WEBPACK_BUILD_LIGHT)\n // _initQualitySelector() {\n // if (this._videojsOptions.controlBar && this.playerOptions.qualitySelector !== false) {\n // if (videojs.browser.IE_VERSION === null) {\n // this.videojs.httpSourceSelector({ default: 'auto' });\n // }\n // \n // this.videojs.on('loadedmetadata', () => {\n // qualitySelector.init(this.videojs);\n // });\n // \n // // Show only if more then one option available\n // this.videojs.on('loadeddata', () => {\n // qualitySelector.setVisibility(this.videojs);\n // });\n // }\n // }\n // #endif\n\n }, {\n key: \"_initTextTracks\",\n value: function _initTextTracks() {\n var _this4 = this;\n\n this.videojs.on('refreshTextTracks', function (e, tracks) {\n _this4.setTextTracks(tracks);\n });\n }\n }, {\n key: \"_initPerSrcBehaviors\",\n value: function _initPerSrcBehaviors() {\n if (this.videojs.perSourceBehaviors) {\n this.videojs.perSourceBehaviors();\n }\n }\n }, {\n key: \"_initJumpButtons\",\n value: function _initJumpButtons() {\n if (!this.playerOptions.showJumpControls && this.videojs.controlBar) {\n this.videojs.controlBar.removeChild('JumpForwardButton');\n this.videojs.controlBar.removeChild('JumpBackButton');\n }\n }\n }, {\n key: \"_initCloudinary\",\n value: function _initCloudinary() {\n var opts = this.playerOptions.cloudinary;\n opts.chainTarget = this;\n\n if (opts.secure !== false) {\n this.playerOptions.cloudinary.cloudinaryConfig.config('secure', true);\n }\n\n this.videojs.cloudinary(this.playerOptions.cloudinary);\n }\n }, {\n key: \"_initAnalytics\",\n value: function _initAnalytics() {\n var analyticsOpts = this.playerOptions.analytics;\n\n if (!window.ga && analyticsOpts) {\n console.error('Google Analytics script is missing');\n return;\n }\n\n if (analyticsOpts) {\n var opts = _typeof(analyticsOpts) === 'object' ? analyticsOpts : {};\n this.videojs.analytics(opts);\n }\n }\n }, {\n key: \"reTryVideo\",\n value: function reTryVideo(maxNumberOfCalls, timeout) {\n var _this5 = this;\n\n if (!this.isVideoReady()) {\n if (this.nbCalls < maxNumberOfCalls) {\n this.nbCalls++;\n this.reTryId = this.videojs.setTimeout(function () {\n return _this5.reTryVideo(maxNumberOfCalls, timeout);\n }, timeout);\n } else {\n var e = new Error('Video is not ready please try later');\n this.videojs.trigger('error', e);\n }\n }\n }\n }, {\n key: \"isVideoReady\",\n value: function isVideoReady() {\n var s = this.videojs.readyState();\n\n if (s >= (/iPad|iPhone|iPod/.test(navigator.userAgent) ? 1 : 4)) {\n this.nbCalls = 0;\n return true;\n }\n\n return false;\n }\n }, {\n key: \"_initPlaylistWidget\",\n value: function _initPlaylistWidget() {\n var _this6 = this;\n\n this.videojs.on('playlistcreated', function () {\n if (_this6._playlistWidget) {\n _this6._playlistWidget.dispose();\n }\n\n var plwOptions = _this6.playerOptions.playlistWidget;\n\n if ((0, _typeInference.isPlainObject)(plwOptions)) {\n if (_this6.playerOptions.fluid) {\n plwOptions.fluid = true;\n }\n\n if (_this6.playerOptions.cloudinary.fontFace) {\n plwOptions.fontFace = _this6.playerOptions.cloudinary.fontFace;\n }\n\n _this6._playlistWidget = new _playlistWidget.default(_this6.videojs, plwOptions);\n }\n });\n }\n }, {\n key: \"playlistWidget\",\n value: function playlistWidget(options) {\n if (!options && !this._playlistWidget) {\n return false;\n }\n\n if (!options && this._playlistWidget) {\n return this._playlistWidget;\n }\n\n if ((0, _typeInference.isPlainObject)(options)) {\n this._playlistWidget.options(options);\n }\n\n return this._playlistWidget;\n }\n }, {\n key: \"_initAutoplay\",\n value: function _initAutoplay() {\n var autoplayMode = this.playerOptions.autoplayMode;\n\n if (autoplayMode === 'on-scroll') {\n this.videojs.autoplayOnScroll();\n }\n }\n }, {\n key: \"_initContextMenu\",\n value: function _initContextMenu() {\n if (!this.playerOptions.hideContextMenu) {\n this.videojs.contextMenu(_defaults.default.contextMenu);\n }\n }\n }, {\n key: \"_initFloatingPlayer\",\n value: function _initFloatingPlayer() {\n if (this.playerOptions.floatingWhenNotVisible !== _videoPlayer2.FLOATING_TO.NONE) {\n this.videojs.floatingPlayer({\n 'floatTo': this.playerOptions.floatingWhenNotVisible\n });\n }\n }\n }, {\n key: \"_setCssClasses\",\n value: function _setCssClasses() {\n this.videojs.addClass(_utils.default.CLASS_PREFIX);\n this.videojs.addClass(_utils.default.playerClassPrefix(this.videojs));\n\n _utils.default.setSkinClassPrefix(this.videojs, _utils.default.skinClassPrefix(this.videojs));\n\n if (_video.default.browser.IE_VERSION === 11) {\n this.videojs.addClass('cld-ie11');\n }\n }\n }, {\n key: \"_onReady\",\n value: function _onReady() {\n this._setExtendedEvents(); // Load first video (mainly to support video tag 'source' and 'public-id' attributes)\n\n\n var source = this.playerOptions.source || this.playerOptions.publicId;\n\n if (source) {\n this.source(source, this.playerOptions);\n }\n }\n }, {\n key: \"_setExtendedEvents\",\n value: function _setExtendedEvents() {\n var _this7 = this;\n\n var events = [];\n\n if (this.playerOptions.playedEventPercents) {\n events.push({\n type: 'percentsplayed',\n percents: this.playerOptions.playedEventPercents\n });\n }\n\n if (this.playerOptions.playedEventTimes) {\n events.push({\n type: 'timeplayed',\n times: this.playerOptions.playedEventTimes\n });\n }\n\n events.push.apply(events, ['seek', 'mute', 'unmute', 'qualitychanged']);\n var extendedEvents = new _extendedEvents.default(this.videojs, {\n events: events\n });\n Object.keys(extendedEvents.events).forEach(function (_event) {\n var handler = function handler(event, data) {\n _this7.videojs.trigger({\n type: _event,\n eventData: data\n });\n };\n\n extendedEvents.on(_event, handler);\n });\n }\n }, {\n key: \"cloudinaryConfig\",\n value: function cloudinaryConfig(config) {\n return this.videojs.cloudinary.cloudinaryConfig(config);\n }\n }, {\n key: \"playerOptions\",\n get: function get() {\n return this.options.playerOptions;\n }\n }, {\n key: \"currentPublicId\",\n value: function currentPublicId() {\n return this.videojs.cloudinary.currentPublicId();\n }\n }, {\n key: \"currentSourceUrl\",\n value: function currentSourceUrl() {\n return this.videojs.currentSource().src;\n }\n }, {\n key: \"currentPoster\",\n value: function currentPoster() {\n return this.videojs.cloudinary.currentPoster();\n }\n }, {\n key: \"source\",\n value: function source(publicId) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!this._isPlayerConfigValid) {\n return;\n }\n\n var isSourceConfigValid = (0, _validatorsFunctions.isValidConfig)(options, _validators.sourceValidators);\n\n if (!isSourceConfigValid) {\n this.videojs.error('invalid source configuration');\n return;\n }\n\n if (publicId instanceof _videoSource.default) {\n return this.videojs.cloudinary.source(publicId, options);\n } // Interactive plugin - available in full (not light) build only\n\n\n if (this.videojs.interactive) {\n this.videojs.interactive(this.videojs, options);\n }\n\n if (VideoPlayer.allowUsageReport()) {\n options.usageReport = true;\n }\n\n this.setTextTracks(options.textTracks); // #if (!process.env.WEBPACK_BUILD_LIGHT)\n // this._initQualitySelector();\n // #endif\n\n clearTimeout(this.reTryId);\n this.nbCalls = 0;\n var maxTries = this.videojs.options_.maxTries || 3;\n var videoReadyTimeout = this.videojs.options_.videoTimeout || 55000;\n this.reTryVideo(maxTries, videoReadyTimeout);\n return this.videojs.cloudinary.source(publicId, options);\n }\n }, {\n key: \"posterOptions\",\n value: function posterOptions(options) {\n return this.videojs.cloudinary.posterOptions(options);\n }\n }, {\n key: \"skin\",\n value: function skin(name) {\n if (name !== undefined && (0, _typeInference.isString)(name)) {\n _utils.default.setSkinClassPrefix(this.videojs, name);\n\n var playlistWidget = this.playlistWidget();\n\n if (this.playlistWidget()) {\n playlistWidget.setSkin();\n }\n }\n\n return _utils.default.skinClassPrefix(this.videojs);\n }\n }, {\n key: \"playlist\",\n value: function playlist(sources) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n return this.videojs.cloudinary.playlist(sources, options);\n }\n }, {\n key: \"playlistByTag\",\n value: function playlistByTag(tag) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n return this.videojs.cloudinary.playlistByTag(tag, options);\n }\n }, {\n key: \"sourcesByTag\",\n value: function sourcesByTag(tag) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n return this.videojs.cloudinary.sourcesByTag(tag, options);\n }\n }, {\n key: \"fluid\",\n value: function fluid(bool) {\n if (bool === undefined) {\n return this.videojs.fluid();\n }\n\n if (bool) {\n this.videojs.addClass(_videoPlayer2.FLUID_CLASS_NAME);\n } else {\n this.videojs.removeClass(_videoPlayer2.FLUID_CLASS_NAME);\n }\n\n this.videojs.fluid(bool);\n this.videojs.trigger('fluid', bool);\n return this;\n }\n }, {\n key: \"play\",\n value: function play() {\n this.playWasCalled = true;\n this.videojs.play();\n return this;\n }\n }, {\n key: \"stop\",\n value: function stop() {\n this.pause();\n this.currentTime(0);\n return this;\n }\n }, {\n key: \"playPrevious\",\n value: function playPrevious() {\n this.playlist().playPrevious();\n return this;\n }\n }, {\n key: \"playNext\",\n value: function playNext() {\n this.playlist().playNext();\n return this;\n }\n }, {\n key: \"transformation\",\n value: function transformation(trans) {\n return this.videojs.cloudinary.transformation(trans);\n }\n }, {\n key: \"sourceTypes\",\n value: function sourceTypes(types) {\n return this.videojs.cloudinary.sourceTypes(types);\n }\n }, {\n key: \"sourceTransformation\",\n value: function sourceTransformation(trans) {\n return this.videojs.cloudinary.sourceTransformation(trans);\n }\n }, {\n key: \"autoShowRecommendations\",\n value: function autoShowRecommendations(autoShow) {\n return this.videojs.cloudinary.autoShowRecommendations(autoShow);\n }\n }, {\n key: \"duration\",\n value: function duration() {\n return this.videojs.duration();\n }\n }, {\n key: \"height\",\n value: function height(dimension) {\n if (!dimension) {\n return this.videojs.height();\n }\n\n this.videojs.height(dimension);\n return this;\n }\n }, {\n key: \"width\",\n value: function width(dimension) {\n if (!dimension) {\n return this.videojs.width();\n }\n\n this.videojs.width(dimension);\n return this;\n }\n }, {\n key: \"volume\",\n value: function volume(_volume) {\n if (!_volume) {\n return this.videojs.volume();\n }\n\n this.videojs.volume(_volume);\n return this;\n }\n }, {\n key: \"mute\",\n value: function mute() {\n if (!this.isMuted()) {\n this.videojs.muted(true);\n }\n\n return this;\n }\n }, {\n key: \"unmute\",\n value: function unmute() {\n if (this.isMuted()) {\n this.videojs.muted(false);\n }\n\n return this;\n }\n }, {\n key: \"isMuted\",\n value: function isMuted() {\n return this.videojs.muted();\n }\n }, {\n key: \"pause\",\n value: function pause() {\n this.videojs.pause();\n return this;\n }\n }, {\n key: \"currentTime\",\n value: function currentTime(offsetSeconds) {\n if (!offsetSeconds && offsetSeconds !== 0) {\n return this.videojs.currentTime();\n }\n\n this.videojs.currentTime(offsetSeconds);\n return this;\n }\n }, {\n key: \"maximize\",\n value: function maximize() {\n if (!this.isMaximized()) {\n this.videojs.requestFullscreen();\n }\n\n return this;\n }\n }, {\n key: \"exitMaximize\",\n value: function exitMaximize() {\n if (this.isMaximized()) {\n this.videojs.exitFullscreen();\n }\n\n return this;\n }\n }, {\n key: \"isMaximized\",\n value: function isMaximized() {\n return this.videojs.isFullscreen();\n }\n }, {\n key: \"dispose\",\n value: function dispose() {\n this.videojs.dispose();\n }\n }, {\n key: \"controls\",\n value: function controls(bool) {\n if (bool === undefined) {\n return this.videojs.controls();\n }\n\n this.videojs.controls(bool);\n return this;\n }\n }, {\n key: \"ima\",\n value: function ima() {\n return {\n playAd: this.videojs.ima.playAd\n };\n }\n }, {\n key: \"loop\",\n value: function loop(bool) {\n if (bool === undefined) {\n return this.videojs.loop();\n }\n\n this.videojs.loop(bool);\n return this;\n }\n }, {\n key: \"el\",\n value: function el() {\n return this.videojs.el();\n }\n }], [{\n key: \"all\",\n value: function all(selector) {\n var nodeList = document.querySelectorAll(selector);\n var players = [];\n\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n for (var i = 0; i < nodeList.length; i++) {\n players.push(_construct(VideoPlayer, [nodeList[i]].concat(args)));\n }\n\n return players;\n }\n }, {\n key: \"allowUsageReport\",\n value: function allowUsageReport(bool) {\n if (bool === undefined) {\n return _allowUsageReport;\n }\n\n _allowUsageReport = !!bool;\n return _allowUsageReport;\n }\n }, {\n key: \"buildTextTrackObj\",\n value: function buildTextTrackObj(type, conf) {\n return {\n kind: type,\n label: conf.label,\n srclang: conf.language,\n default: !!conf.default,\n src: conf.url\n };\n }\n }]);\n\n return VideoPlayer;\n}(_utils.default.mixin(_eventable.default));\n\nvar _default = VideoPlayer;\nexports.default = _default;\n\n//# sourceURL=webpack://cloudinaryVideoPlayer/./video-player.js?");
|
|
1372
1372
|
|
|
1373
1373
|
/***/ }),
|
|
1374
1374
|
|