videojs-wavesurfer
Advanced tools
Comparing version 2.10.0 to 2.11.0
videojs-wavesurfer changelog | ||
============================ | ||
2.11.0 - 2019/10/11 | ||
------------------- | ||
- Fix loading peaks data from JSON files (#90) | ||
- Add `style` and `sass` entries to `package.json` | ||
- Specify non-minified videojs-wavesurfer in `main` entry of `package.json` | ||
2.10.0 - 2019/09/30 | ||
------------------- | ||
- New `abort` event; triggeredd when wavesurfer.js fetch call is cancelled (#87) | ||
- New `abort` event; triggered when wavesurfer.js fetch call is cancelled (#87) | ||
- Bump required wavesurfer.js version to 3.1.0 | ||
@@ -9,0 +17,0 @@ |
/*! | ||
* videojs-wavesurfer | ||
* @version 2.10.0 | ||
* @version 2.11.0 | ||
* @see https://github.com/collab-project/videojs-wavesurfer | ||
@@ -195,3 +195,3 @@ * @copyright 2014-2019 Collab | ||
"use strict"; | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.Wavesurfer = void 0;\n\nvar _event = _interopRequireDefault(__webpack_require__(/*! ./event */ \"./src/js/event.js\"));\n\nvar _log2 = _interopRequireDefault(__webpack_require__(/*! ./utils/log */ \"./src/js/utils/log.js\"));\n\nvar _formatTime = _interopRequireDefault(__webpack_require__(/*! ./utils/format-time */ \"./src/js/utils/format-time.js\"));\n\nvar _defaults = _interopRequireDefault(__webpack_require__(/*! ./defaults */ \"./src/js/defaults.js\"));\n\nvar _window = _interopRequireDefault(__webpack_require__(/*! global/window */ \"./node_modules/global/window.js\"));\n\nvar _video = _interopRequireDefault(__webpack_require__(/*! video.js */ \"video.js\"));\n\nvar _wavesurfer = _interopRequireDefault(__webpack_require__(/*! wavesurfer.js */ \"wavesurfer.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _typeof(obj) { 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 _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\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 _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\nvar Plugin = _video.default.getPlugin('plugin');\n\nvar wavesurferClassName = 'vjs-wavedisplay';\n\nvar Wavesurfer = function (_Plugin) {\n _inherits(Wavesurfer, _Plugin);\n\n function Wavesurfer(player, options) {\n var _this;\n\n _classCallCheck(this, Wavesurfer);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(Wavesurfer).call(this, player, options));\n player.addClass('vjs-wavesurfer');\n options = _video.default.mergeOptions(_defaults.default, options);\n _this.waveReady = false;\n _this.waveFinished = false;\n _this.liveMode = false;\n _this.debug = options.debug.toString() === 'true';\n _this.msDisplayMax = parseFloat(options.msDisplayMax);\n _this.textTracksEnabled = _this.player.options_.tracks.length > 0;\n\n if (options.src === 'live') {\n if (_wavesurfer.default.microphone !== undefined) {\n _this.liveMode = true;\n _this.waveReady = true;\n } else {\n _this.onWaveError('Could not find wavesurfer.js ' + 'microphone plugin!');\n\n return _possibleConstructorReturn(_this);\n }\n }\n\n _this.player.one(_event.default.READY, _this.initialize.bind(_assertThisInitialized(_this)));\n\n return _this;\n }\n\n _createClass(Wavesurfer, [{\n key: \"initialize\",\n value: function initialize() {\n var _this2 = this;\n\n this.player.bigPlayButton.hide();\n\n if (this.player.usingNativeControls_ === true) {\n if (this.player.tech_.el_ !== undefined) {\n this.player.tech_.el_.controls = false;\n }\n }\n\n if (this.player.options_.controls === true) {\n this.player.controlBar.show();\n this.player.controlBar.el_.style.display = 'flex';\n\n if (this.player.controlBar.progressControl !== undefined) {\n this.player.controlBar.progressControl.hide();\n }\n\n if (this.player.controlBar.pictureInPictureToggle !== undefined) {\n this.player.controlBar.pictureInPictureToggle.hide();\n }\n\n var uiElements = ['currentTimeDisplay', 'timeDivider', 'durationDisplay'];\n uiElements.forEach(function (element) {\n element = _this2.player.controlBar[element];\n\n if (element !== undefined) {\n element.el_.style.display = 'block';\n element.show();\n }\n });\n\n if (this.player.controlBar.remainingTimeDisplay !== undefined) {\n this.player.controlBar.remainingTimeDisplay.hide();\n }\n\n if (this.player.controlBar.playToggle !== undefined) {\n this.player.controlBar.playToggle.on(['tap', 'click'], this.onPlayToggle.bind(this));\n\n if (!this.liveMode) {\n this.player.controlBar.playToggle.hide();\n }\n }\n }\n\n var mergedOptions = this.parseOptions(this.player.options_.plugins.wavesurfer);\n this.surfer = _wavesurfer.default.create(mergedOptions);\n this.surfer.on(_event.default.ERROR, this.onWaveError.bind(this));\n this.surfer.on(_event.default.FINISH, this.onWaveFinish.bind(this));\n\n if (this.liveMode === true) {\n this.surfer.microphone.on(_event.default.DEVICE_ERROR, this.onWaveError.bind(this));\n }\n\n this.surferReady = this.onWaveReady.bind(this);\n this.surferProgress = this.onWaveProgress.bind(this);\n this.surferSeek = this.onWaveSeek.bind(this);\n\n if (!this.liveMode) {\n this.setupPlaybackEvents(true);\n }\n\n this.player.on(_event.default.VOLUMECHANGE, this.onVolumeChange.bind(this));\n this.player.on(_event.default.FULLSCREENCHANGE, this.onScreenChange.bind(this));\n\n if (this.player.muted()) {\n this.setVolume(0);\n }\n\n if (this.player.options_.fluid === true) {\n this.surfer.drawer.wrapper.className = wavesurferClassName;\n this.responsiveWave = _wavesurfer.default.util.debounce(this.onResizeChange.bind(this), 150);\n\n _window.default.addEventListener(_event.default.RESIZE, this.responsiveWave);\n }\n\n if (this.textTracksEnabled) {\n if (this.player.controlBar.currentTimeDisplay !== undefined) {\n this.player.controlBar.currentTimeDisplay.off(this.player, _event.default.TIMEUPDATE, this.player.controlBar.currentTimeDisplay.throttledUpdateContent);\n }\n\n this.player.tech_.trackCurrentTime();\n }\n\n this.startPlayers();\n }\n }, {\n key: \"parseOptions\",\n value: function parseOptions(surferOpts) {\n var rect = this.player.el_.getBoundingClientRect();\n this.originalWidth = this.player.options_.width || rect.width;\n this.originalHeight = this.player.options_.height || rect.height;\n var controlBarHeight = this.player.controlBar.height();\n\n if (this.player.options_.controls === true && controlBarHeight === 0) {\n controlBarHeight = 30;\n }\n\n if (surferOpts.container === undefined) {\n surferOpts.container = this.player.el_;\n }\n\n if (surferOpts.waveformHeight === undefined) {\n var playerHeight = rect.height;\n surferOpts.height = playerHeight - controlBarHeight;\n } else {\n surferOpts.height = surferOpts.waveformHeight;\n }\n\n if (surferOpts.splitChannels && surferOpts.splitChannels === true) {\n surferOpts.height /= 2;\n }\n\n if (this.liveMode === true) {\n surferOpts.plugins = [_wavesurfer.default.microphone.create(surferOpts)];\n this.log('wavesurfer.js microphone plugin enabled.');\n }\n\n return surferOpts;\n }\n }, {\n key: \"startPlayers\",\n value: function startPlayers() {\n var options = this.player.options_.plugins.wavesurfer;\n\n if (options.src !== undefined) {\n if (this.surfer.microphone === undefined) {\n this.player.loadingSpinner.show();\n this.load(options.src, options.peaks);\n } else {\n this.player.loadingSpinner.hide();\n options.wavesurfer = this.surfer;\n }\n } else {\n this.player.loadingSpinner.hide();\n }\n }\n }, {\n key: \"setupPlaybackEvents\",\n value: function setupPlaybackEvents(enable) {\n if (enable === false) {\n this.surfer.un(_event.default.READY, this.surferReady);\n this.surfer.un(_event.default.AUDIOPROCESS, this.surferProgress);\n this.surfer.un(_event.default.SEEK, this.surferSeek);\n } else if (enable === true) {\n this.surfer.on(_event.default.READY, this.surferReady);\n this.surfer.on(_event.default.AUDIOPROCESS, this.surferProgress);\n this.surfer.on(_event.default.SEEK, this.surferSeek);\n }\n }\n }, {\n key: \"load\",\n value: function load(url, peaks) {\n var _this3 = this;\n\n if (url instanceof Blob || url instanceof File) {\n this.log('Loading object: ' + JSON.stringify(url));\n this.surfer.loadBlob(url);\n } else {\n if (peaks !== undefined) {\n if (Array.isArray(peaks)) {\n this.log('Loading URL: ' + url);\n this.surfer.load(url, peaks);\n } else {\n var requestOptions = {\n url: peaks,\n responseType: 'json'\n };\n\n if (this.player.options_.plugins.wavesurfer.xhr !== undefined) {\n requestOptions.xhr = this.player.options_.plugins.wavesurfer.xhr;\n }\n\n var request = _wavesurfer.default.util.fetchFile(requestOptions);\n\n request.once('success', function (data) {\n _this3.log('Loaded Peak Data URL: ' + peaks);\n\n _this3.surfer.load(url, data);\n });\n request.on('error', function (e) {\n _this3.log('Unable to retrieve peak data from ' + peaks + '. Status code: ' + request.response.status, 'warn');\n\n _this3.log('Loading URL: ' + url);\n\n _this3.surfer.load(url);\n });\n }\n } else {\n this.log('Loading URL: ' + url);\n this.surfer.load(url);\n }\n }\n }\n }, {\n key: \"play\",\n value: function play() {\n if (this.player.controlBar.playToggle !== undefined && this.player.controlBar.playToggle.contentEl()) {\n this.player.controlBar.playToggle.handlePlay();\n }\n\n if (this.liveMode) {\n if (!this.surfer.microphone.active) {\n this.log('Start microphone');\n this.surfer.microphone.start();\n } else {\n var paused = !this.surfer.microphone.paused;\n\n if (paused) {\n this.pause();\n } else {\n this.log('Resume microphone');\n this.surfer.microphone.play();\n }\n }\n } else {\n this.log('Start playback');\n this.player.play();\n this.surfer.play();\n }\n }\n }, {\n key: \"pause\",\n value: function pause() {\n if (this.player.controlBar.playToggle !== undefined && this.player.controlBar.playToggle.contentEl()) {\n this.player.controlBar.playToggle.handlePause();\n }\n\n if (this.liveMode) {\n this.log('Pause microphone');\n this.surfer.microphone.pause();\n } else {\n this.log('Pause playback');\n\n if (!this.waveFinished) {\n this.surfer.pause();\n } else {\n this.waveFinished = false;\n }\n\n this.setCurrentTime();\n }\n }\n }, {\n key: \"dispose\",\n value: function dispose() {\n if (this.surfer) {\n if (this.liveMode && this.surfer.microphone) {\n this.surfer.microphone.destroy();\n this.log('Destroyed microphone plugin');\n }\n\n this.surfer.destroy();\n }\n\n if (this.textTracksEnabled) {\n this.player.tech_.stopTrackingCurrentTime();\n }\n\n this.log('Destroyed plugin');\n }\n }, {\n key: \"isDestroyed\",\n value: function isDestroyed() {\n return this.player && this.player.children() === null;\n }\n }, {\n key: \"destroy\",\n value: function destroy() {\n this.player.dispose();\n }\n }, {\n key: \"setVolume\",\n value: function setVolume(volume) {\n if (volume !== undefined) {\n this.log('Changing volume to: ' + volume);\n this.player.volume(volume);\n }\n }\n }, {\n key: \"exportImage\",\n value: function exportImage(format, quality) {\n return this.surfer.exportImage(format, quality);\n }\n }, {\n key: \"setAudioOutput\",\n value: function setAudioOutput(deviceId) {\n var _this4 = this;\n\n if (deviceId) {\n this.surfer.setSinkId(deviceId).then(function (result) {\n _this4.player.trigger(_event.default.AUDIO_OUTPUT_READY);\n }).catch(function (err) {\n _this4.player.trigger(_event.default.ERROR, err);\n\n _this4.log(err, 'error');\n });\n }\n }\n }, {\n key: \"getCurrentTime\",\n value: function getCurrentTime() {\n var currentTime = this.surfer.getCurrentTime();\n currentTime = isNaN(currentTime) ? 0 : currentTime;\n return currentTime;\n }\n }, {\n key: \"setCurrentTime\",\n value: function setCurrentTime(currentTime, duration) {\n if (currentTime === undefined) {\n currentTime = this.surfer.getCurrentTime();\n }\n\n if (duration === undefined) {\n duration = this.surfer.getDuration();\n }\n\n currentTime = isNaN(currentTime) ? 0 : currentTime;\n duration = isNaN(duration) ? 0 : duration;\n\n if (this.player.controlBar.currentTimeDisplay && this.player.controlBar.currentTimeDisplay.contentEl()) {\n var time = Math.min(currentTime, duration);\n this.player.controlBar.currentTimeDisplay.formattedTime_ = this.player.controlBar.currentTimeDisplay.contentEl().lastChild.textContent = (0, _formatTime.default)(time, duration, this.msDisplayMax);\n }\n\n if (this.textTracksEnabled && this.player.tech_ && this.player.tech_.el_) {\n this.player.tech_.setCurrentTime(currentTime);\n }\n }\n }, {\n key: \"getDuration\",\n value: function getDuration() {\n var duration = this.surfer.getDuration();\n duration = isNaN(duration) ? 0 : duration;\n return duration;\n }\n }, {\n key: \"setDuration\",\n value: function setDuration(duration) {\n if (duration === undefined) {\n duration = this.surfer.getDuration();\n }\n\n duration = isNaN(duration) ? 0 : duration;\n\n if (this.player.controlBar.durationDisplay && this.player.controlBar.durationDisplay.contentEl()) {\n this.player.controlBar.durationDisplay.formattedTime_ = this.player.controlBar.durationDisplay.contentEl().lastChild.textContent = (0, _formatTime.default)(duration, duration, this.msDisplayMax);\n }\n }\n }, {\n key: \"onWaveReady\",\n value: function onWaveReady() {\n this.waveReady = true;\n this.waveFinished = false;\n this.liveMode = false;\n this.log('Waveform is ready');\n this.player.trigger(_event.default.WAVE_READY);\n this.setCurrentTime();\n this.setDuration();\n\n if (this.player.controlBar.playToggle !== undefined && this.player.controlBar.playToggle.contentEl()) {\n this.player.controlBar.playToggle.show();\n }\n\n if (this.player.loadingSpinner.contentEl()) {\n this.player.loadingSpinner.hide();\n }\n\n if (this.player.options_.autoplay === true) {\n this.play();\n }\n }\n }, {\n key: \"onWaveFinish\",\n value: function onWaveFinish() {\n var _this5 = this;\n\n this.log('Finished playback');\n this.player.trigger(_event.default.PLAYBACK_FINISH);\n\n if (this.player.options_.loop === true) {\n this.surfer.stop();\n this.play();\n } else {\n this.waveFinished = true;\n this.pause();\n this.player.trigger(_event.default.ENDED);\n this.surfer.once(_event.default.SEEK, function () {\n if (_this5.player.controlBar.playToggle !== undefined) {\n _this5.player.controlBar.playToggle.removeClass('vjs-ended');\n }\n\n _this5.player.trigger(_event.default.PAUSE);\n });\n }\n }\n }, {\n key: \"onWaveProgress\",\n value: function onWaveProgress(time) {\n this.setCurrentTime();\n }\n }, {\n key: \"onWaveSeek\",\n value: function onWaveSeek() {\n this.setCurrentTime();\n }\n }, {\n key: \"onWaveError\",\n value: function onWaveError(error) {\n if (error.name && error.name === 'AbortError' || error.name === 'DOMException' && error.message.startsWith('The operation was aborted')) {\n this.player.trigger(_event.default.ABORT, error);\n } else {\n this.player.trigger(_event.default.ERROR, error);\n this.log(error, 'error');\n }\n }\n }, {\n key: \"onPlayToggle\",\n value: function onPlayToggle() {\n if (this.player.controlBar.playToggle !== undefined && this.player.controlBar.playToggle.hasClass('vjs-ended')) {\n this.player.controlBar.playToggle.removeClass('vjs-ended');\n }\n\n if (this.surfer.isPlaying()) {\n this.pause();\n } else {\n this.play();\n }\n }\n }, {\n key: \"onVolumeChange\",\n value: function onVolumeChange() {\n var volume = this.player.volume();\n\n if (this.player.muted()) {\n volume = 0;\n }\n\n this.surfer.setVolume(volume);\n }\n }, {\n key: \"onScreenChange\",\n value: function onScreenChange() {\n var _this6 = this;\n\n var fullscreenDelay = this.player.setInterval(function () {\n var isFullscreen = _this6.player.isFullscreen();\n\n var newWidth, newHeight;\n\n if (!isFullscreen) {\n newWidth = _this6.originalWidth;\n newHeight = _this6.originalHeight;\n }\n\n if (_this6.waveReady) {\n if (_this6.liveMode && !_this6.surfer.microphone.active) {\n return;\n }\n\n _this6.redrawWaveform(newWidth, newHeight);\n }\n\n _this6.player.clearInterval(fullscreenDelay);\n }, 100);\n }\n }, {\n key: \"onResizeChange\",\n value: function onResizeChange() {\n if (this.surfer !== undefined) {\n this.redrawWaveform();\n }\n }\n }, {\n key: \"redrawWaveform\",\n value: function redrawWaveform(newWidth, newHeight) {\n if (!this.isDestroyed()) {\n if (this.player.el_) {\n var rect = this.player.el_.getBoundingClientRect();\n\n if (newWidth === undefined) {\n newWidth = rect.width;\n }\n\n if (newHeight === undefined) {\n newHeight = rect.height;\n }\n }\n\n this.surfer.drawer.destroy();\n this.surfer.params.width = newWidth;\n this.surfer.params.height = newHeight - this.player.controlBar.height();\n this.surfer.createDrawer();\n this.surfer.drawer.wrapper.className = wavesurferClassName;\n this.surfer.drawBuffer();\n this.surfer.drawer.progress(this.surfer.backend.getPlayedPercents());\n }\n }\n }, {\n key: \"log\",\n value: function log(args, logType) {\n (0, _log2.default)(args, logType, this.debug);\n }\n }]);\n\n return Wavesurfer;\n}(Plugin);\n\nexports.Wavesurfer = Wavesurfer;\nWavesurfer.VERSION = \"2.10.0\";\n_video.default.Wavesurfer = Wavesurfer;\n\nif (_video.default.getPlugin('wavesurfer') === undefined) {\n _video.default.registerPlugin('wavesurfer', Wavesurfer);\n}\n\n//# sourceURL=webpack://VideojsWavesurfer/./src/js/videojs.wavesurfer.js?"); | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.Wavesurfer = void 0;\n\nvar _event = _interopRequireDefault(__webpack_require__(/*! ./event */ \"./src/js/event.js\"));\n\nvar _log2 = _interopRequireDefault(__webpack_require__(/*! ./utils/log */ \"./src/js/utils/log.js\"));\n\nvar _formatTime = _interopRequireDefault(__webpack_require__(/*! ./utils/format-time */ \"./src/js/utils/format-time.js\"));\n\nvar _defaults = _interopRequireDefault(__webpack_require__(/*! ./defaults */ \"./src/js/defaults.js\"));\n\nvar _window = _interopRequireDefault(__webpack_require__(/*! global/window */ \"./node_modules/global/window.js\"));\n\nvar _video = _interopRequireDefault(__webpack_require__(/*! video.js */ \"video.js\"));\n\nvar _wavesurfer = _interopRequireDefault(__webpack_require__(/*! wavesurfer.js */ \"wavesurfer.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _typeof(obj) { 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 _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\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 _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\nvar Plugin = _video.default.getPlugin('plugin');\n\nvar wavesurferClassName = 'vjs-wavedisplay';\n\nvar Wavesurfer = function (_Plugin) {\n _inherits(Wavesurfer, _Plugin);\n\n function Wavesurfer(player, options) {\n var _this;\n\n _classCallCheck(this, Wavesurfer);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(Wavesurfer).call(this, player, options));\n player.addClass('vjs-wavesurfer');\n options = _video.default.mergeOptions(_defaults.default, options);\n _this.waveReady = false;\n _this.waveFinished = false;\n _this.liveMode = false;\n _this.debug = options.debug.toString() === 'true';\n _this.msDisplayMax = parseFloat(options.msDisplayMax);\n _this.textTracksEnabled = _this.player.options_.tracks.length > 0;\n\n if (options.src === 'live') {\n if (_wavesurfer.default.microphone !== undefined) {\n _this.liveMode = true;\n _this.waveReady = true;\n } else {\n _this.onWaveError('Could not find wavesurfer.js ' + 'microphone plugin!');\n\n return _possibleConstructorReturn(_this);\n }\n }\n\n _this.player.one(_event.default.READY, _this.initialize.bind(_assertThisInitialized(_this)));\n\n return _this;\n }\n\n _createClass(Wavesurfer, [{\n key: \"initialize\",\n value: function initialize() {\n var _this2 = this;\n\n this.player.bigPlayButton.hide();\n\n if (this.player.usingNativeControls_ === true) {\n if (this.player.tech_.el_ !== undefined) {\n this.player.tech_.el_.controls = false;\n }\n }\n\n if (this.player.options_.controls === true) {\n this.player.controlBar.show();\n this.player.controlBar.el_.style.display = 'flex';\n\n if (this.player.controlBar.progressControl !== undefined) {\n this.player.controlBar.progressControl.hide();\n }\n\n if (this.player.controlBar.pictureInPictureToggle !== undefined) {\n this.player.controlBar.pictureInPictureToggle.hide();\n }\n\n var uiElements = ['currentTimeDisplay', 'timeDivider', 'durationDisplay'];\n uiElements.forEach(function (element) {\n element = _this2.player.controlBar[element];\n\n if (element !== undefined) {\n element.el_.style.display = 'block';\n element.show();\n }\n });\n\n if (this.player.controlBar.remainingTimeDisplay !== undefined) {\n this.player.controlBar.remainingTimeDisplay.hide();\n }\n\n if (this.player.controlBar.playToggle !== undefined) {\n this.player.controlBar.playToggle.on(['tap', 'click'], this.onPlayToggle.bind(this));\n\n if (!this.liveMode) {\n this.player.controlBar.playToggle.hide();\n }\n }\n }\n\n var mergedOptions = this.parseOptions(this.player.options_.plugins.wavesurfer);\n this.surfer = _wavesurfer.default.create(mergedOptions);\n this.surfer.on(_event.default.ERROR, this.onWaveError.bind(this));\n this.surfer.on(_event.default.FINISH, this.onWaveFinish.bind(this));\n\n if (this.liveMode === true) {\n this.surfer.microphone.on(_event.default.DEVICE_ERROR, this.onWaveError.bind(this));\n }\n\n this.surferReady = this.onWaveReady.bind(this);\n this.surferProgress = this.onWaveProgress.bind(this);\n this.surferSeek = this.onWaveSeek.bind(this);\n\n if (!this.liveMode) {\n this.setupPlaybackEvents(true);\n }\n\n this.player.on(_event.default.VOLUMECHANGE, this.onVolumeChange.bind(this));\n this.player.on(_event.default.FULLSCREENCHANGE, this.onScreenChange.bind(this));\n\n if (this.player.muted()) {\n this.setVolume(0);\n }\n\n if (this.player.options_.fluid === true) {\n this.surfer.drawer.wrapper.className = wavesurferClassName;\n this.responsiveWave = _wavesurfer.default.util.debounce(this.onResizeChange.bind(this), 150);\n\n _window.default.addEventListener(_event.default.RESIZE, this.responsiveWave);\n }\n\n if (this.textTracksEnabled) {\n if (this.player.controlBar.currentTimeDisplay !== undefined) {\n this.player.controlBar.currentTimeDisplay.off(this.player, _event.default.TIMEUPDATE, this.player.controlBar.currentTimeDisplay.throttledUpdateContent);\n }\n\n this.player.tech_.trackCurrentTime();\n }\n\n this.startPlayers();\n }\n }, {\n key: \"parseOptions\",\n value: function parseOptions(surferOpts) {\n var rect = this.player.el_.getBoundingClientRect();\n this.originalWidth = this.player.options_.width || rect.width;\n this.originalHeight = this.player.options_.height || rect.height;\n var controlBarHeight = this.player.controlBar.height();\n\n if (this.player.options_.controls === true && controlBarHeight === 0) {\n controlBarHeight = 30;\n }\n\n if (surferOpts.container === undefined) {\n surferOpts.container = this.player.el_;\n }\n\n if (surferOpts.waveformHeight === undefined) {\n var playerHeight = rect.height;\n surferOpts.height = playerHeight - controlBarHeight;\n } else {\n surferOpts.height = surferOpts.waveformHeight;\n }\n\n if (surferOpts.splitChannels && surferOpts.splitChannels === true) {\n surferOpts.height /= 2;\n }\n\n if (this.liveMode === true) {\n surferOpts.plugins = [_wavesurfer.default.microphone.create(surferOpts)];\n this.log('wavesurfer.js microphone plugin enabled.');\n }\n\n return surferOpts;\n }\n }, {\n key: \"startPlayers\",\n value: function startPlayers() {\n var options = this.player.options_.plugins.wavesurfer;\n\n if (options.src !== undefined) {\n if (this.surfer.microphone === undefined) {\n this.player.loadingSpinner.show();\n this.load(options.src, options.peaks);\n } else {\n this.player.loadingSpinner.hide();\n options.wavesurfer = this.surfer;\n }\n } else {\n this.player.loadingSpinner.hide();\n }\n }\n }, {\n key: \"setupPlaybackEvents\",\n value: function setupPlaybackEvents(enable) {\n if (enable === false) {\n this.surfer.un(_event.default.READY, this.surferReady);\n this.surfer.un(_event.default.AUDIOPROCESS, this.surferProgress);\n this.surfer.un(_event.default.SEEK, this.surferSeek);\n } else if (enable === true) {\n this.surfer.on(_event.default.READY, this.surferReady);\n this.surfer.on(_event.default.AUDIOPROCESS, this.surferProgress);\n this.surfer.on(_event.default.SEEK, this.surferSeek);\n }\n }\n }, {\n key: \"load\",\n value: function load(url, peaks) {\n var _this3 = this;\n\n if (url instanceof Blob || url instanceof File) {\n this.log('Loading object: ' + JSON.stringify(url));\n this.surfer.loadBlob(url);\n } else {\n if (peaks !== undefined) {\n if (Array.isArray(peaks)) {\n this.log('Loading URL: ' + url);\n this.surfer.load(url, peaks);\n } else {\n var requestOptions = {\n url: peaks,\n responseType: 'json'\n };\n\n if (this.player.options_.plugins.wavesurfer.xhr !== undefined) {\n requestOptions.xhr = this.player.options_.plugins.wavesurfer.xhr;\n }\n\n var request = _wavesurfer.default.util.fetchFile(requestOptions);\n\n request.once('success', function (data) {\n _this3.log('Loaded Peak Data URL: ' + peaks);\n\n if (data && data.data) {\n _this3.surfer.load(url, data.data);\n } else {\n _this3.player.trigger(_event.default.ERROR, 'Could not load peaks data from ' + peaks);\n\n _this3.log(err, 'error');\n }\n });\n request.on('error', function (e) {\n _this3.log('Unable to retrieve peak data from ' + peaks + '. Status code: ' + request.response.status, 'warn');\n\n _this3.log('Loading URL: ' + url);\n\n _this3.surfer.load(url);\n });\n }\n } else {\n this.log('Loading URL: ' + url);\n this.surfer.load(url);\n }\n }\n }\n }, {\n key: \"play\",\n value: function play() {\n if (this.player.controlBar.playToggle !== undefined && this.player.controlBar.playToggle.contentEl()) {\n this.player.controlBar.playToggle.handlePlay();\n }\n\n if (this.liveMode) {\n if (!this.surfer.microphone.active) {\n this.log('Start microphone');\n this.surfer.microphone.start();\n } else {\n var paused = !this.surfer.microphone.paused;\n\n if (paused) {\n this.pause();\n } else {\n this.log('Resume microphone');\n this.surfer.microphone.play();\n }\n }\n } else {\n this.log('Start playback');\n this.player.play();\n this.surfer.play();\n }\n }\n }, {\n key: \"pause\",\n value: function pause() {\n if (this.player.controlBar.playToggle !== undefined && this.player.controlBar.playToggle.contentEl()) {\n this.player.controlBar.playToggle.handlePause();\n }\n\n if (this.liveMode) {\n this.log('Pause microphone');\n this.surfer.microphone.pause();\n } else {\n this.log('Pause playback');\n\n if (!this.waveFinished) {\n this.surfer.pause();\n } else {\n this.waveFinished = false;\n }\n\n this.setCurrentTime();\n }\n }\n }, {\n key: \"dispose\",\n value: function dispose() {\n if (this.surfer) {\n if (this.liveMode && this.surfer.microphone) {\n this.surfer.microphone.destroy();\n this.log('Destroyed microphone plugin');\n }\n\n this.surfer.destroy();\n }\n\n if (this.textTracksEnabled) {\n this.player.tech_.stopTrackingCurrentTime();\n }\n\n this.log('Destroyed plugin');\n }\n }, {\n key: \"isDestroyed\",\n value: function isDestroyed() {\n return this.player && this.player.children() === null;\n }\n }, {\n key: \"destroy\",\n value: function destroy() {\n this.player.dispose();\n }\n }, {\n key: \"setVolume\",\n value: function setVolume(volume) {\n if (volume !== undefined) {\n this.log('Changing volume to: ' + volume);\n this.player.volume(volume);\n }\n }\n }, {\n key: \"exportImage\",\n value: function exportImage(format, quality) {\n return this.surfer.exportImage(format, quality);\n }\n }, {\n key: \"setAudioOutput\",\n value: function setAudioOutput(deviceId) {\n var _this4 = this;\n\n if (deviceId) {\n this.surfer.setSinkId(deviceId).then(function (result) {\n _this4.player.trigger(_event.default.AUDIO_OUTPUT_READY);\n }).catch(function (err) {\n _this4.player.trigger(_event.default.ERROR, err);\n\n _this4.log(err, 'error');\n });\n }\n }\n }, {\n key: \"getCurrentTime\",\n value: function getCurrentTime() {\n var currentTime = this.surfer.getCurrentTime();\n currentTime = isNaN(currentTime) ? 0 : currentTime;\n return currentTime;\n }\n }, {\n key: \"setCurrentTime\",\n value: function setCurrentTime(currentTime, duration) {\n if (currentTime === undefined) {\n currentTime = this.surfer.getCurrentTime();\n }\n\n if (duration === undefined) {\n duration = this.surfer.getDuration();\n }\n\n currentTime = isNaN(currentTime) ? 0 : currentTime;\n duration = isNaN(duration) ? 0 : duration;\n\n if (this.player.controlBar.currentTimeDisplay && this.player.controlBar.currentTimeDisplay.contentEl()) {\n var time = Math.min(currentTime, duration);\n this.player.controlBar.currentTimeDisplay.formattedTime_ = this.player.controlBar.currentTimeDisplay.contentEl().lastChild.textContent = (0, _formatTime.default)(time, duration, this.msDisplayMax);\n }\n\n if (this.textTracksEnabled && this.player.tech_ && this.player.tech_.el_) {\n this.player.tech_.setCurrentTime(currentTime);\n }\n }\n }, {\n key: \"getDuration\",\n value: function getDuration() {\n var duration = this.surfer.getDuration();\n duration = isNaN(duration) ? 0 : duration;\n return duration;\n }\n }, {\n key: \"setDuration\",\n value: function setDuration(duration) {\n if (duration === undefined) {\n duration = this.surfer.getDuration();\n }\n\n duration = isNaN(duration) ? 0 : duration;\n\n if (this.player.controlBar.durationDisplay && this.player.controlBar.durationDisplay.contentEl()) {\n this.player.controlBar.durationDisplay.formattedTime_ = this.player.controlBar.durationDisplay.contentEl().lastChild.textContent = (0, _formatTime.default)(duration, duration, this.msDisplayMax);\n }\n }\n }, {\n key: \"onWaveReady\",\n value: function onWaveReady() {\n this.waveReady = true;\n this.waveFinished = false;\n this.liveMode = false;\n this.log('Waveform is ready');\n this.player.trigger(_event.default.WAVE_READY);\n this.setCurrentTime();\n this.setDuration();\n\n if (this.player.controlBar.playToggle !== undefined && this.player.controlBar.playToggle.contentEl()) {\n this.player.controlBar.playToggle.show();\n }\n\n if (this.player.loadingSpinner.contentEl()) {\n this.player.loadingSpinner.hide();\n }\n\n if (this.player.options_.autoplay === true) {\n this.play();\n }\n }\n }, {\n key: \"onWaveFinish\",\n value: function onWaveFinish() {\n var _this5 = this;\n\n this.log('Finished playback');\n this.player.trigger(_event.default.PLAYBACK_FINISH);\n\n if (this.player.options_.loop === true) {\n this.surfer.stop();\n this.play();\n } else {\n this.waveFinished = true;\n this.pause();\n this.player.trigger(_event.default.ENDED);\n this.surfer.once(_event.default.SEEK, function () {\n if (_this5.player.controlBar.playToggle !== undefined) {\n _this5.player.controlBar.playToggle.removeClass('vjs-ended');\n }\n\n _this5.player.trigger(_event.default.PAUSE);\n });\n }\n }\n }, {\n key: \"onWaveProgress\",\n value: function onWaveProgress(time) {\n this.setCurrentTime();\n }\n }, {\n key: \"onWaveSeek\",\n value: function onWaveSeek() {\n this.setCurrentTime();\n }\n }, {\n key: \"onWaveError\",\n value: function onWaveError(error) {\n if (error.name && error.name === 'AbortError' || error.name === 'DOMException' && error.message.startsWith('The operation was aborted')) {\n this.player.trigger(_event.default.ABORT, error);\n } else {\n this.player.trigger(_event.default.ERROR, error);\n this.log(error, 'error');\n }\n }\n }, {\n key: \"onPlayToggle\",\n value: function onPlayToggle() {\n if (this.player.controlBar.playToggle !== undefined && this.player.controlBar.playToggle.hasClass('vjs-ended')) {\n this.player.controlBar.playToggle.removeClass('vjs-ended');\n }\n\n if (this.surfer.isPlaying()) {\n this.pause();\n } else {\n this.play();\n }\n }\n }, {\n key: \"onVolumeChange\",\n value: function onVolumeChange() {\n var volume = this.player.volume();\n\n if (this.player.muted()) {\n volume = 0;\n }\n\n this.surfer.setVolume(volume);\n }\n }, {\n key: \"onScreenChange\",\n value: function onScreenChange() {\n var _this6 = this;\n\n var fullscreenDelay = this.player.setInterval(function () {\n var isFullscreen = _this6.player.isFullscreen();\n\n var newWidth, newHeight;\n\n if (!isFullscreen) {\n newWidth = _this6.originalWidth;\n newHeight = _this6.originalHeight;\n }\n\n if (_this6.waveReady) {\n if (_this6.liveMode && !_this6.surfer.microphone.active) {\n return;\n }\n\n _this6.redrawWaveform(newWidth, newHeight);\n }\n\n _this6.player.clearInterval(fullscreenDelay);\n }, 100);\n }\n }, {\n key: \"onResizeChange\",\n value: function onResizeChange() {\n if (this.surfer !== undefined) {\n this.redrawWaveform();\n }\n }\n }, {\n key: \"redrawWaveform\",\n value: function redrawWaveform(newWidth, newHeight) {\n if (!this.isDestroyed()) {\n if (this.player.el_) {\n var rect = this.player.el_.getBoundingClientRect();\n\n if (newWidth === undefined) {\n newWidth = rect.width;\n }\n\n if (newHeight === undefined) {\n newHeight = rect.height;\n }\n }\n\n this.surfer.drawer.destroy();\n this.surfer.params.width = newWidth;\n this.surfer.params.height = newHeight - this.player.controlBar.height();\n this.surfer.createDrawer();\n this.surfer.drawer.wrapper.className = wavesurferClassName;\n this.surfer.drawBuffer();\n this.surfer.drawer.progress(this.surfer.backend.getPlayedPercents());\n }\n }\n }, {\n key: \"log\",\n value: function log(args, logType) {\n (0, _log2.default)(args, logType, this.debug);\n }\n }]);\n\n return Wavesurfer;\n}(Plugin);\n\nexports.Wavesurfer = Wavesurfer;\nWavesurfer.VERSION = \"2.11.0\";\n_video.default.Wavesurfer = Wavesurfer;\n\nif (_video.default.getPlugin('wavesurfer') === undefined) {\n _video.default.registerPlugin('wavesurfer', Wavesurfer);\n}\n\n//# sourceURL=webpack://VideojsWavesurfer/./src/js/videojs.wavesurfer.js?"); | ||
@@ -198,0 +198,0 @@ /***/ }), |
/*! | ||
* videojs-wavesurfer | ||
* @version 2.10.0 | ||
* @version 2.11.0 | ||
* @see https://github.com/collab-project/videojs-wavesurfer | ||
@@ -8,2 +8,2 @@ * @copyright 2014-2019 Collab | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("videojs"),require("WaveSurfer")):"function"==typeof define&&define.amd?define("VideojsWavesurfer",["videojs","WaveSurfer"],t):"object"==typeof exports?exports.VideojsWavesurfer=t(require("videojs"),require("WaveSurfer")):e.VideojsWavesurfer=t(e.videojs,e.WaveSurfer)}(window,(function(e,t){return function(e){var t={};function r(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(i,o,function(t){return e[t]}.bind(null,o));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(t,r){t.exports=e},function(e,t,r){r(2),e.exports=r(10)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Wavesurfer=void 0;var i=h(r(3)),o=h(r(4)),a=h(r(5)),s=h(r(6)),n=h(r(7)),l=h(r(0)),u=h(r(9));function h(e){return e&&e.__esModule?e:{default:e}}function f(e){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function p(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function d(e,t){return!t||"object"!==f(t)&&"function"!=typeof t?y(e):t}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function v(e,t){return(v=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var g=l.default.getPlugin("plugin"),m=function(e){function t(e,r){var o;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),o=d(this,c(t).call(this,e,r)),e.addClass("vjs-wavesurfer"),r=l.default.mergeOptions(s.default,r),o.waveReady=!1,o.waveFinished=!1,o.liveMode=!1,o.debug="true"===r.debug.toString(),o.msDisplayMax=parseFloat(r.msDisplayMax),o.textTracksEnabled=o.player.options_.tracks.length>0,"live"===r.src){if(void 0===u.default.microphone)return o.onWaveError("Could not find wavesurfer.js microphone plugin!"),d(o);o.liveMode=!0,o.waveReady=!0}return o.player.one(i.default.READY,o.initialize.bind(y(o))),o}var r,h,f;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&v(e,t)}(t,e),r=t,(h=[{key:"initialize",value:function(){var e=this;this.player.bigPlayButton.hide(),!0===this.player.usingNativeControls_&&void 0!==this.player.tech_.el_&&(this.player.tech_.el_.controls=!1),!0===this.player.options_.controls&&(this.player.controlBar.show(),this.player.controlBar.el_.style.display="flex",void 0!==this.player.controlBar.progressControl&&this.player.controlBar.progressControl.hide(),void 0!==this.player.controlBar.pictureInPictureToggle&&this.player.controlBar.pictureInPictureToggle.hide(),["currentTimeDisplay","timeDivider","durationDisplay"].forEach((function(t){void 0!==(t=e.player.controlBar[t])&&(t.el_.style.display="block",t.show())})),void 0!==this.player.controlBar.remainingTimeDisplay&&this.player.controlBar.remainingTimeDisplay.hide(),void 0!==this.player.controlBar.playToggle&&(this.player.controlBar.playToggle.on(["tap","click"],this.onPlayToggle.bind(this)),this.liveMode||this.player.controlBar.playToggle.hide()));var t=this.parseOptions(this.player.options_.plugins.wavesurfer);this.surfer=u.default.create(t),this.surfer.on(i.default.ERROR,this.onWaveError.bind(this)),this.surfer.on(i.default.FINISH,this.onWaveFinish.bind(this)),!0===this.liveMode&&this.surfer.microphone.on(i.default.DEVICE_ERROR,this.onWaveError.bind(this)),this.surferReady=this.onWaveReady.bind(this),this.surferProgress=this.onWaveProgress.bind(this),this.surferSeek=this.onWaveSeek.bind(this),this.liveMode||this.setupPlaybackEvents(!0),this.player.on(i.default.VOLUMECHANGE,this.onVolumeChange.bind(this)),this.player.on(i.default.FULLSCREENCHANGE,this.onScreenChange.bind(this)),this.player.muted()&&this.setVolume(0),!0===this.player.options_.fluid&&(this.surfer.drawer.wrapper.className="vjs-wavedisplay",this.responsiveWave=u.default.util.debounce(this.onResizeChange.bind(this),150),n.default.addEventListener(i.default.RESIZE,this.responsiveWave)),this.textTracksEnabled&&(void 0!==this.player.controlBar.currentTimeDisplay&&this.player.controlBar.currentTimeDisplay.off(this.player,i.default.TIMEUPDATE,this.player.controlBar.currentTimeDisplay.throttledUpdateContent),this.player.tech_.trackCurrentTime()),this.startPlayers()}},{key:"parseOptions",value:function(e){var t=this.player.el_.getBoundingClientRect();this.originalWidth=this.player.options_.width||t.width,this.originalHeight=this.player.options_.height||t.height;var r=this.player.controlBar.height();if(!0===this.player.options_.controls&&0===r&&(r=30),void 0===e.container&&(e.container=this.player.el_),void 0===e.waveformHeight){var i=t.height;e.height=i-r}else e.height=e.waveformHeight;return e.splitChannels&&!0===e.splitChannels&&(e.height/=2),!0===this.liveMode&&(e.plugins=[u.default.microphone.create(e)],this.log("wavesurfer.js microphone plugin enabled.")),e}},{key:"startPlayers",value:function(){var e=this.player.options_.plugins.wavesurfer;void 0!==e.src?void 0===this.surfer.microphone?(this.player.loadingSpinner.show(),this.load(e.src,e.peaks)):(this.player.loadingSpinner.hide(),e.wavesurfer=this.surfer):this.player.loadingSpinner.hide()}},{key:"setupPlaybackEvents",value:function(e){!1===e?(this.surfer.un(i.default.READY,this.surferReady),this.surfer.un(i.default.AUDIOPROCESS,this.surferProgress),this.surfer.un(i.default.SEEK,this.surferSeek)):!0===e&&(this.surfer.on(i.default.READY,this.surferReady),this.surfer.on(i.default.AUDIOPROCESS,this.surferProgress),this.surfer.on(i.default.SEEK,this.surferSeek))}},{key:"load",value:function(e,t){var r=this;if(e instanceof Blob||e instanceof File)this.log("Loading object: "+JSON.stringify(e)),this.surfer.loadBlob(e);else if(void 0!==t)if(Array.isArray(t))this.log("Loading URL: "+e),this.surfer.load(e,t);else{var i={url:t,responseType:"json"};void 0!==this.player.options_.plugins.wavesurfer.xhr&&(i.xhr=this.player.options_.plugins.wavesurfer.xhr);var o=u.default.util.fetchFile(i);o.once("success",(function(i){r.log("Loaded Peak Data URL: "+t),r.surfer.load(e,i)})),o.on("error",(function(i){r.log("Unable to retrieve peak data from "+t+". Status code: "+o.response.status,"warn"),r.log("Loading URL: "+e),r.surfer.load(e)}))}else this.log("Loading URL: "+e),this.surfer.load(e)}},{key:"play",value:function(){void 0!==this.player.controlBar.playToggle&&this.player.controlBar.playToggle.contentEl()&&this.player.controlBar.playToggle.handlePlay(),this.liveMode?this.surfer.microphone.active?this.surfer.microphone.paused?(this.log("Resume microphone"),this.surfer.microphone.play()):this.pause():(this.log("Start microphone"),this.surfer.microphone.start()):(this.log("Start playback"),this.player.play(),this.surfer.play())}},{key:"pause",value:function(){void 0!==this.player.controlBar.playToggle&&this.player.controlBar.playToggle.contentEl()&&this.player.controlBar.playToggle.handlePause(),this.liveMode?(this.log("Pause microphone"),this.surfer.microphone.pause()):(this.log("Pause playback"),this.waveFinished?this.waveFinished=!1:this.surfer.pause(),this.setCurrentTime())}},{key:"dispose",value:function(){this.surfer&&(this.liveMode&&this.surfer.microphone&&(this.surfer.microphone.destroy(),this.log("Destroyed microphone plugin")),this.surfer.destroy()),this.textTracksEnabled&&this.player.tech_.stopTrackingCurrentTime(),this.log("Destroyed plugin")}},{key:"isDestroyed",value:function(){return this.player&&null===this.player.children()}},{key:"destroy",value:function(){this.player.dispose()}},{key:"setVolume",value:function(e){void 0!==e&&(this.log("Changing volume to: "+e),this.player.volume(e))}},{key:"exportImage",value:function(e,t){return this.surfer.exportImage(e,t)}},{key:"setAudioOutput",value:function(e){var t=this;e&&this.surfer.setSinkId(e).then((function(e){t.player.trigger(i.default.AUDIO_OUTPUT_READY)})).catch((function(e){t.player.trigger(i.default.ERROR,e),t.log(e,"error")}))}},{key:"getCurrentTime",value:function(){var e=this.surfer.getCurrentTime();return e=isNaN(e)?0:e}},{key:"setCurrentTime",value:function(e,t){if(void 0===e&&(e=this.surfer.getCurrentTime()),void 0===t&&(t=this.surfer.getDuration()),e=isNaN(e)?0:e,t=isNaN(t)?0:t,this.player.controlBar.currentTimeDisplay&&this.player.controlBar.currentTimeDisplay.contentEl()){var r=Math.min(e,t);this.player.controlBar.currentTimeDisplay.formattedTime_=this.player.controlBar.currentTimeDisplay.contentEl().lastChild.textContent=(0,a.default)(r,t,this.msDisplayMax)}this.textTracksEnabled&&this.player.tech_&&this.player.tech_.el_&&this.player.tech_.setCurrentTime(e)}},{key:"getDuration",value:function(){var e=this.surfer.getDuration();return e=isNaN(e)?0:e}},{key:"setDuration",value:function(e){void 0===e&&(e=this.surfer.getDuration()),e=isNaN(e)?0:e,this.player.controlBar.durationDisplay&&this.player.controlBar.durationDisplay.contentEl()&&(this.player.controlBar.durationDisplay.formattedTime_=this.player.controlBar.durationDisplay.contentEl().lastChild.textContent=(0,a.default)(e,e,this.msDisplayMax))}},{key:"onWaveReady",value:function(){this.waveReady=!0,this.waveFinished=!1,this.liveMode=!1,this.log("Waveform is ready"),this.player.trigger(i.default.WAVE_READY),this.setCurrentTime(),this.setDuration(),void 0!==this.player.controlBar.playToggle&&this.player.controlBar.playToggle.contentEl()&&this.player.controlBar.playToggle.show(),this.player.loadingSpinner.contentEl()&&this.player.loadingSpinner.hide(),!0===this.player.options_.autoplay&&this.play()}},{key:"onWaveFinish",value:function(){var e=this;this.log("Finished playback"),this.player.trigger(i.default.PLAYBACK_FINISH),!0===this.player.options_.loop?(this.surfer.stop(),this.play()):(this.waveFinished=!0,this.pause(),this.player.trigger(i.default.ENDED),this.surfer.once(i.default.SEEK,(function(){void 0!==e.player.controlBar.playToggle&&e.player.controlBar.playToggle.removeClass("vjs-ended"),e.player.trigger(i.default.PAUSE)})))}},{key:"onWaveProgress",value:function(e){this.setCurrentTime()}},{key:"onWaveSeek",value:function(){this.setCurrentTime()}},{key:"onWaveError",value:function(e){e.name&&"AbortError"===e.name||"DOMException"===e.name&&e.message.startsWith("The operation was aborted")?this.player.trigger(i.default.ABORT,e):(this.player.trigger(i.default.ERROR,e),this.log(e,"error"))}},{key:"onPlayToggle",value:function(){void 0!==this.player.controlBar.playToggle&&this.player.controlBar.playToggle.hasClass("vjs-ended")&&this.player.controlBar.playToggle.removeClass("vjs-ended"),this.surfer.isPlaying()?this.pause():this.play()}},{key:"onVolumeChange",value:function(){var e=this.player.volume();this.player.muted()&&(e=0),this.surfer.setVolume(e)}},{key:"onScreenChange",value:function(){var e=this,t=this.player.setInterval((function(){var r,i;if(e.player.isFullscreen()||(r=e.originalWidth,i=e.originalHeight),e.waveReady){if(e.liveMode&&!e.surfer.microphone.active)return;e.redrawWaveform(r,i)}e.player.clearInterval(t)}),100)}},{key:"onResizeChange",value:function(){void 0!==this.surfer&&this.redrawWaveform()}},{key:"redrawWaveform",value:function(e,t){if(!this.isDestroyed()){if(this.player.el_){var r=this.player.el_.getBoundingClientRect();void 0===e&&(e=r.width),void 0===t&&(t=r.height)}this.surfer.drawer.destroy(),this.surfer.params.width=e,this.surfer.params.height=t-this.player.controlBar.height(),this.surfer.createDrawer(),this.surfer.drawer.wrapper.className="vjs-wavedisplay",this.surfer.drawBuffer(),this.surfer.drawer.progress(this.surfer.backend.getPlayedPercents())}}},{key:"log",value:function(e,t){(0,o.default)(e,t,this.debug)}}])&&p(r.prototype,h),f&&p(r,f),t}(g);t.Wavesurfer=m,m.VERSION="2.10.0",l.default.Wavesurfer=m,void 0===l.default.getPlugin("wavesurfer")&&l.default.registerPlugin("wavesurfer",m)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)};i.READY="ready",i.ERROR="error",i.VOLUMECHANGE="volumechange",i.FULLSCREENCHANGE="fullscreenchange",i.TIMEUPDATE="timeupdate",i.ENDED="ended",i.PAUSE="pause",i.FINISH="finish",i.SEEK="seek",i.REDRAW="redraw",i.AUDIOPROCESS="audioprocess",i.DEVICE_READY="deviceReady",i.DEVICE_ERROR="deviceError",i.AUDIO_OUTPUT_READY="audioOutputReady",i.WAVE_READY="waveReady",i.PLAYBACK_FINISH="playbackFinish",i.ABORT="abort",i.RESIZE="resize",Object.freeze(i);var o=i;t.default=o,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i,o=(i=r(0))&&i.__esModule?i:{default:i};var a=function(e,t,r){!0===r&&("error"===t?o.default.log.error(e):"warn"===t?o.default.log.warn(e):o.default.log(e))};t.default=a,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e,t,r){e=e<0?0:e,t=t||e;var i=Math.floor(e%60),o=Math.floor(e/60%60),a=Math.floor(e/3600),s=Math.floor(t/60%60),n=Math.floor(t/3600),l=Math.floor(1e3*(e-i));return(isNaN(e)||e===1/0)&&(a=o=i=l="-"),t>0&&t<r?(l<100&&(l=l<10?"00"+l:"0"+l),l=":"+l):l="",(a=a>0||n>0?a+":":"")+(o=((a||s>=10)&&o<10?"0"+o:o)+":")+(i=i<10?"0"+i:i)+l};t.default=i,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i={debug:!1,msDisplayMax:3};t.default=i,e.exports=t.default},function(e,t,r){(function(t){var r;r="undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{},e.exports=r}).call(this,r(8))},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,r){e.exports=t},function(e,t,r){}])})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("videojs"),require("WaveSurfer")):"function"==typeof define&&define.amd?define("VideojsWavesurfer",["videojs","WaveSurfer"],t):"object"==typeof exports?exports.VideojsWavesurfer=t(require("videojs"),require("WaveSurfer")):e.VideojsWavesurfer=t(e.videojs,e.WaveSurfer)}(window,(function(e,t){return function(e){var t={};function r(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(i,o,function(t){return e[t]}.bind(null,o));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(t,r){t.exports=e},function(e,t,r){r(2),e.exports=r(10)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Wavesurfer=void 0;var i=h(r(3)),o=h(r(4)),a=h(r(5)),s=h(r(6)),n=h(r(7)),l=h(r(0)),u=h(r(9));function h(e){return e&&e.__esModule?e:{default:e}}function f(e){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function p(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function d(e,t){return!t||"object"!==f(t)&&"function"!=typeof t?y(e):t}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function v(e,t){return(v=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var g=l.default.getPlugin("plugin"),m=function(e){function t(e,r){var o;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),o=d(this,c(t).call(this,e,r)),e.addClass("vjs-wavesurfer"),r=l.default.mergeOptions(s.default,r),o.waveReady=!1,o.waveFinished=!1,o.liveMode=!1,o.debug="true"===r.debug.toString(),o.msDisplayMax=parseFloat(r.msDisplayMax),o.textTracksEnabled=o.player.options_.tracks.length>0,"live"===r.src){if(void 0===u.default.microphone)return o.onWaveError("Could not find wavesurfer.js microphone plugin!"),d(o);o.liveMode=!0,o.waveReady=!0}return o.player.one(i.default.READY,o.initialize.bind(y(o))),o}var r,h,f;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&v(e,t)}(t,e),r=t,(h=[{key:"initialize",value:function(){var e=this;this.player.bigPlayButton.hide(),!0===this.player.usingNativeControls_&&void 0!==this.player.tech_.el_&&(this.player.tech_.el_.controls=!1),!0===this.player.options_.controls&&(this.player.controlBar.show(),this.player.controlBar.el_.style.display="flex",void 0!==this.player.controlBar.progressControl&&this.player.controlBar.progressControl.hide(),void 0!==this.player.controlBar.pictureInPictureToggle&&this.player.controlBar.pictureInPictureToggle.hide(),["currentTimeDisplay","timeDivider","durationDisplay"].forEach((function(t){void 0!==(t=e.player.controlBar[t])&&(t.el_.style.display="block",t.show())})),void 0!==this.player.controlBar.remainingTimeDisplay&&this.player.controlBar.remainingTimeDisplay.hide(),void 0!==this.player.controlBar.playToggle&&(this.player.controlBar.playToggle.on(["tap","click"],this.onPlayToggle.bind(this)),this.liveMode||this.player.controlBar.playToggle.hide()));var t=this.parseOptions(this.player.options_.plugins.wavesurfer);this.surfer=u.default.create(t),this.surfer.on(i.default.ERROR,this.onWaveError.bind(this)),this.surfer.on(i.default.FINISH,this.onWaveFinish.bind(this)),!0===this.liveMode&&this.surfer.microphone.on(i.default.DEVICE_ERROR,this.onWaveError.bind(this)),this.surferReady=this.onWaveReady.bind(this),this.surferProgress=this.onWaveProgress.bind(this),this.surferSeek=this.onWaveSeek.bind(this),this.liveMode||this.setupPlaybackEvents(!0),this.player.on(i.default.VOLUMECHANGE,this.onVolumeChange.bind(this)),this.player.on(i.default.FULLSCREENCHANGE,this.onScreenChange.bind(this)),this.player.muted()&&this.setVolume(0),!0===this.player.options_.fluid&&(this.surfer.drawer.wrapper.className="vjs-wavedisplay",this.responsiveWave=u.default.util.debounce(this.onResizeChange.bind(this),150),n.default.addEventListener(i.default.RESIZE,this.responsiveWave)),this.textTracksEnabled&&(void 0!==this.player.controlBar.currentTimeDisplay&&this.player.controlBar.currentTimeDisplay.off(this.player,i.default.TIMEUPDATE,this.player.controlBar.currentTimeDisplay.throttledUpdateContent),this.player.tech_.trackCurrentTime()),this.startPlayers()}},{key:"parseOptions",value:function(e){var t=this.player.el_.getBoundingClientRect();this.originalWidth=this.player.options_.width||t.width,this.originalHeight=this.player.options_.height||t.height;var r=this.player.controlBar.height();if(!0===this.player.options_.controls&&0===r&&(r=30),void 0===e.container&&(e.container=this.player.el_),void 0===e.waveformHeight){var i=t.height;e.height=i-r}else e.height=e.waveformHeight;return e.splitChannels&&!0===e.splitChannels&&(e.height/=2),!0===this.liveMode&&(e.plugins=[u.default.microphone.create(e)],this.log("wavesurfer.js microphone plugin enabled.")),e}},{key:"startPlayers",value:function(){var e=this.player.options_.plugins.wavesurfer;void 0!==e.src?void 0===this.surfer.microphone?(this.player.loadingSpinner.show(),this.load(e.src,e.peaks)):(this.player.loadingSpinner.hide(),e.wavesurfer=this.surfer):this.player.loadingSpinner.hide()}},{key:"setupPlaybackEvents",value:function(e){!1===e?(this.surfer.un(i.default.READY,this.surferReady),this.surfer.un(i.default.AUDIOPROCESS,this.surferProgress),this.surfer.un(i.default.SEEK,this.surferSeek)):!0===e&&(this.surfer.on(i.default.READY,this.surferReady),this.surfer.on(i.default.AUDIOPROCESS,this.surferProgress),this.surfer.on(i.default.SEEK,this.surferSeek))}},{key:"load",value:function(e,t){var r=this;if(e instanceof Blob||e instanceof File)this.log("Loading object: "+JSON.stringify(e)),this.surfer.loadBlob(e);else if(void 0!==t)if(Array.isArray(t))this.log("Loading URL: "+e),this.surfer.load(e,t);else{var o={url:t,responseType:"json"};void 0!==this.player.options_.plugins.wavesurfer.xhr&&(o.xhr=this.player.options_.plugins.wavesurfer.xhr);var a=u.default.util.fetchFile(o);a.once("success",(function(o){r.log("Loaded Peak Data URL: "+t),o&&o.data?r.surfer.load(e,o.data):(r.player.trigger(i.default.ERROR,"Could not load peaks data from "+t),r.log(err,"error"))})),a.on("error",(function(i){r.log("Unable to retrieve peak data from "+t+". Status code: "+a.response.status,"warn"),r.log("Loading URL: "+e),r.surfer.load(e)}))}else this.log("Loading URL: "+e),this.surfer.load(e)}},{key:"play",value:function(){void 0!==this.player.controlBar.playToggle&&this.player.controlBar.playToggle.contentEl()&&this.player.controlBar.playToggle.handlePlay(),this.liveMode?this.surfer.microphone.active?this.surfer.microphone.paused?(this.log("Resume microphone"),this.surfer.microphone.play()):this.pause():(this.log("Start microphone"),this.surfer.microphone.start()):(this.log("Start playback"),this.player.play(),this.surfer.play())}},{key:"pause",value:function(){void 0!==this.player.controlBar.playToggle&&this.player.controlBar.playToggle.contentEl()&&this.player.controlBar.playToggle.handlePause(),this.liveMode?(this.log("Pause microphone"),this.surfer.microphone.pause()):(this.log("Pause playback"),this.waveFinished?this.waveFinished=!1:this.surfer.pause(),this.setCurrentTime())}},{key:"dispose",value:function(){this.surfer&&(this.liveMode&&this.surfer.microphone&&(this.surfer.microphone.destroy(),this.log("Destroyed microphone plugin")),this.surfer.destroy()),this.textTracksEnabled&&this.player.tech_.stopTrackingCurrentTime(),this.log("Destroyed plugin")}},{key:"isDestroyed",value:function(){return this.player&&null===this.player.children()}},{key:"destroy",value:function(){this.player.dispose()}},{key:"setVolume",value:function(e){void 0!==e&&(this.log("Changing volume to: "+e),this.player.volume(e))}},{key:"exportImage",value:function(e,t){return this.surfer.exportImage(e,t)}},{key:"setAudioOutput",value:function(e){var t=this;e&&this.surfer.setSinkId(e).then((function(e){t.player.trigger(i.default.AUDIO_OUTPUT_READY)})).catch((function(e){t.player.trigger(i.default.ERROR,e),t.log(e,"error")}))}},{key:"getCurrentTime",value:function(){var e=this.surfer.getCurrentTime();return e=isNaN(e)?0:e}},{key:"setCurrentTime",value:function(e,t){if(void 0===e&&(e=this.surfer.getCurrentTime()),void 0===t&&(t=this.surfer.getDuration()),e=isNaN(e)?0:e,t=isNaN(t)?0:t,this.player.controlBar.currentTimeDisplay&&this.player.controlBar.currentTimeDisplay.contentEl()){var r=Math.min(e,t);this.player.controlBar.currentTimeDisplay.formattedTime_=this.player.controlBar.currentTimeDisplay.contentEl().lastChild.textContent=(0,a.default)(r,t,this.msDisplayMax)}this.textTracksEnabled&&this.player.tech_&&this.player.tech_.el_&&this.player.tech_.setCurrentTime(e)}},{key:"getDuration",value:function(){var e=this.surfer.getDuration();return e=isNaN(e)?0:e}},{key:"setDuration",value:function(e){void 0===e&&(e=this.surfer.getDuration()),e=isNaN(e)?0:e,this.player.controlBar.durationDisplay&&this.player.controlBar.durationDisplay.contentEl()&&(this.player.controlBar.durationDisplay.formattedTime_=this.player.controlBar.durationDisplay.contentEl().lastChild.textContent=(0,a.default)(e,e,this.msDisplayMax))}},{key:"onWaveReady",value:function(){this.waveReady=!0,this.waveFinished=!1,this.liveMode=!1,this.log("Waveform is ready"),this.player.trigger(i.default.WAVE_READY),this.setCurrentTime(),this.setDuration(),void 0!==this.player.controlBar.playToggle&&this.player.controlBar.playToggle.contentEl()&&this.player.controlBar.playToggle.show(),this.player.loadingSpinner.contentEl()&&this.player.loadingSpinner.hide(),!0===this.player.options_.autoplay&&this.play()}},{key:"onWaveFinish",value:function(){var e=this;this.log("Finished playback"),this.player.trigger(i.default.PLAYBACK_FINISH),!0===this.player.options_.loop?(this.surfer.stop(),this.play()):(this.waveFinished=!0,this.pause(),this.player.trigger(i.default.ENDED),this.surfer.once(i.default.SEEK,(function(){void 0!==e.player.controlBar.playToggle&&e.player.controlBar.playToggle.removeClass("vjs-ended"),e.player.trigger(i.default.PAUSE)})))}},{key:"onWaveProgress",value:function(e){this.setCurrentTime()}},{key:"onWaveSeek",value:function(){this.setCurrentTime()}},{key:"onWaveError",value:function(e){e.name&&"AbortError"===e.name||"DOMException"===e.name&&e.message.startsWith("The operation was aborted")?this.player.trigger(i.default.ABORT,e):(this.player.trigger(i.default.ERROR,e),this.log(e,"error"))}},{key:"onPlayToggle",value:function(){void 0!==this.player.controlBar.playToggle&&this.player.controlBar.playToggle.hasClass("vjs-ended")&&this.player.controlBar.playToggle.removeClass("vjs-ended"),this.surfer.isPlaying()?this.pause():this.play()}},{key:"onVolumeChange",value:function(){var e=this.player.volume();this.player.muted()&&(e=0),this.surfer.setVolume(e)}},{key:"onScreenChange",value:function(){var e=this,t=this.player.setInterval((function(){var r,i;if(e.player.isFullscreen()||(r=e.originalWidth,i=e.originalHeight),e.waveReady){if(e.liveMode&&!e.surfer.microphone.active)return;e.redrawWaveform(r,i)}e.player.clearInterval(t)}),100)}},{key:"onResizeChange",value:function(){void 0!==this.surfer&&this.redrawWaveform()}},{key:"redrawWaveform",value:function(e,t){if(!this.isDestroyed()){if(this.player.el_){var r=this.player.el_.getBoundingClientRect();void 0===e&&(e=r.width),void 0===t&&(t=r.height)}this.surfer.drawer.destroy(),this.surfer.params.width=e,this.surfer.params.height=t-this.player.controlBar.height(),this.surfer.createDrawer(),this.surfer.drawer.wrapper.className="vjs-wavedisplay",this.surfer.drawBuffer(),this.surfer.drawer.progress(this.surfer.backend.getPlayedPercents())}}},{key:"log",value:function(e,t){(0,o.default)(e,t,this.debug)}}])&&p(r.prototype,h),f&&p(r,f),t}(g);t.Wavesurfer=m,m.VERSION="2.11.0",l.default.Wavesurfer=m,void 0===l.default.getPlugin("wavesurfer")&&l.default.registerPlugin("wavesurfer",m)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)};i.READY="ready",i.ERROR="error",i.VOLUMECHANGE="volumechange",i.FULLSCREENCHANGE="fullscreenchange",i.TIMEUPDATE="timeupdate",i.ENDED="ended",i.PAUSE="pause",i.FINISH="finish",i.SEEK="seek",i.REDRAW="redraw",i.AUDIOPROCESS="audioprocess",i.DEVICE_READY="deviceReady",i.DEVICE_ERROR="deviceError",i.AUDIO_OUTPUT_READY="audioOutputReady",i.WAVE_READY="waveReady",i.PLAYBACK_FINISH="playbackFinish",i.ABORT="abort",i.RESIZE="resize",Object.freeze(i);var o=i;t.default=o,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i,o=(i=r(0))&&i.__esModule?i:{default:i};var a=function(e,t,r){!0===r&&("error"===t?o.default.log.error(e):"warn"===t?o.default.log.warn(e):o.default.log(e))};t.default=a,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e,t,r){e=e<0?0:e,t=t||e;var i=Math.floor(e%60),o=Math.floor(e/60%60),a=Math.floor(e/3600),s=Math.floor(t/60%60),n=Math.floor(t/3600),l=Math.floor(1e3*(e-i));return(isNaN(e)||e===1/0)&&(a=o=i=l="-"),t>0&&t<r?(l<100&&(l=l<10?"00"+l:"0"+l),l=":"+l):l="",(a=a>0||n>0?a+":":"")+(o=((a||s>=10)&&o<10?"0"+o:o)+":")+(i=i<10?"0"+i:i)+l};t.default=i,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i={debug:!1,msDisplayMax:3};t.default=i,e.exports=t.default},function(e,t,r){(function(t){var r;r="undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{},e.exports=r}).call(this,r(8))},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,r){e.exports=t},function(e,t,r){}])})); |
{ | ||
"name": "videojs-wavesurfer", | ||
"version": "2.10.0", | ||
"version": "2.11.0", | ||
"description": "video.js plugin that adds a navigable waveform for audio and video files.", | ||
@@ -12,3 +12,5 @@ "author": "Collab", | ||
"homepage": "https://github.com/collab-project/videojs-wavesurfer", | ||
"main": "dist/videojs.wavesurfer.min.js", | ||
"main": "dist/videojs.wavesurfer.js", | ||
"style": "dist/css/videojs.wavesurfer.css", | ||
"sass": "src/css/videojs.wavesurfer.scss", | ||
"directories": { | ||
@@ -56,4 +58,4 @@ "doc": "./docs", | ||
"devDependencies": { | ||
"@babel/core": "^7.6.2", | ||
"@babel/preset-env": "^7.6.2", | ||
"@babel/core": "^7.6.4", | ||
"@babel/preset-env": "^7.6.3", | ||
"@babel/register": "^7.6.2", | ||
@@ -66,3 +68,3 @@ "babel-loader": "^8.0.6", | ||
"date-fns": "^2.4.1", | ||
"eslint": "^6.5.0", | ||
"eslint": "^6.5.1", | ||
"htmlhint": "^0.11.0", | ||
@@ -93,7 +95,7 @@ "in-publish": "^2.0.0", | ||
"style-loader": "^1.0.0", | ||
"terser-webpack-plugin": "^2.1.2", | ||
"terser-webpack-plugin": "^2.1.3", | ||
"tui-jsdoc-template": "^1.2.2", | ||
"webpack": "^4.41.0", | ||
"webpack": "^4.41.1", | ||
"webpack-cli": "^3.3.9", | ||
"webpack-dev-server": "^3.8.1", | ||
"webpack-dev-server": "^3.8.2", | ||
"webpack-merge": "^4.2.2", | ||
@@ -100,0 +102,0 @@ "webrtc-adapter": "^7.3.0" |
@@ -322,3 +322,10 @@ /** | ||
this.log('Loaded Peak Data URL: ' + peaks); | ||
this.surfer.load(url, data); | ||
// check for data property containing peaks | ||
if (data && data.data) { | ||
this.surfer.load(url, data.data); | ||
} else { | ||
this.player.trigger(Event.ERROR, | ||
'Could not load peaks data from ' + peaks); | ||
this.log(err, 'error'); | ||
} | ||
}); | ||
@@ -325,0 +332,0 @@ request.on('error', e => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
111991
1187