videojs-wavesurfer
Advanced tools
Comparing version 3.4.0 to 3.5.0
# videojs-wavesurfer changelog | ||
## 3.5.0 - 2021/02/01 | ||
- Add `formatTime` option and `setFormatTime(impl)` for replacing the default | ||
`formatTime` implementation (#125) | ||
- Build using webpack 5 (#118) | ||
## 3.4.0 - 2021/01/24 | ||
@@ -4,0 +11,0 @@ |
/*! | ||
* videojs-wavesurfer | ||
* @version 3.4.0 | ||
* @version 3.5.0 | ||
* @see https://github.com/collab-project/videojs-wavesurfer | ||
@@ -17,90 +17,5 @@ * @copyright 2014-2021 Collab | ||
root["VideojsWavesurfer"] = factory(root["videojs"], root["WaveSurfer"]); | ||
})(window, function(__WEBPACK_EXTERNAL_MODULE_video_js__, __WEBPACK_EXTERNAL_MODULE_wavesurfer_js__) { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) { | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // define __esModule on exports | ||
/******/ __webpack_require__.r = function(exports) { | ||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
/******/ } | ||
/******/ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/******/ }; | ||
/******/ | ||
/******/ // create a fake namespace object | ||
/******/ // mode & 1: value is a module id, require it | ||
/******/ // mode & 2: merge all properties of value into the ns | ||
/******/ // mode & 4: return value when already ns object | ||
/******/ // mode & 8|1: behave like require | ||
/******/ __webpack_require__.t = function(value, mode) { | ||
/******/ if(mode & 1) value = __webpack_require__(value); | ||
/******/ if(mode & 8) return value; | ||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; | ||
/******/ var ns = Object.create(null); | ||
/******/ __webpack_require__.r(ns); | ||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); | ||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); | ||
/******/ return ns; | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ({ | ||
})(self, function(__WEBPACK_EXTERNAL_MODULE_video_js__, __WEBPACK_EXTERNAL_MODULE_wavesurfer_js__) { | ||
return /******/ (() => { // webpackBootstrap | ||
/******/ var __webpack_modules__ = ({ | ||
@@ -111,55 +26,37 @@ /***/ "./node_modules/add-zero/index.js": | ||
\****************************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
eval("var __WEBPACK_AMD_DEFINE_RESULT__;(function(exports) {\n\n 'use strict';\n\n function addZero(value, digits) {\n digits = digits || 2;\n\n var isNegative = Number(value) < 0;\n var buffer = value.toString();\n var size = 0;\n\n // Strip minus sign if number is negative\n if(isNegative) {\n buffer = buffer.slice(1);\n }\n\n size = digits - buffer.length + 1;\n buffer = new Array(size).join('0').concat(buffer);\n\n // Adds back minus sign if needed\n return (isNegative ? '-' : '') + buffer;\n }\n\n if(true) {\n !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { return addZero; }).call(exports, __webpack_require__, exports, module),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n } else {}\n\n})(this);\n\n\n//# sourceURL=webpack://VideojsWavesurfer/./node_modules/add-zero/index.js?"); | ||
var __WEBPACK_AMD_DEFINE_RESULT__;(function(exports) { | ||
/***/ }), | ||
'use strict'; | ||
/***/ "./node_modules/global/window.js": | ||
/*!***************************************!*\ | ||
!*** ./node_modules/global/window.js ***! | ||
\***************************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
function addZero(value, digits) { | ||
digits = digits || 2; | ||
eval("/* WEBPACK VAR INJECTION */(function(global) {var win;\n\nif (typeof window !== \"undefined\") {\n win = window;\n} else if (typeof global !== \"undefined\") {\n win = global;\n} else if (typeof self !== \"undefined\"){\n win = self;\n} else {\n win = {};\n}\n\nmodule.exports = win;\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ \"./node_modules/webpack/buildin/global.js\")))\n\n//# sourceURL=webpack://VideojsWavesurfer/./node_modules/global/window.js?"); | ||
var isNegative = Number(value) < 0; | ||
var buffer = value.toString(); | ||
var size = 0; | ||
/***/ }), | ||
// Strip minus sign if number is negative | ||
if(isNegative) { | ||
buffer = buffer.slice(1); | ||
} | ||
/***/ "./node_modules/parse-ms/index.js": | ||
/*!****************************************!*\ | ||
!*** ./node_modules/parse-ms/index.js ***! | ||
\****************************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
size = digits - buffer.length + 1; | ||
buffer = new Array(size).join('0').concat(buffer); | ||
"use strict"; | ||
eval("\nmodule.exports = milliseconds => {\n\tif (typeof milliseconds !== 'number') {\n\t\tthrow new TypeError('Expected a number');\n\t}\n\n\tconst roundTowardsZero = milliseconds > 0 ? Math.floor : Math.ceil;\n\n\treturn {\n\t\tdays: roundTowardsZero(milliseconds / 86400000),\n\t\thours: roundTowardsZero(milliseconds / 3600000) % 24,\n\t\tminutes: roundTowardsZero(milliseconds / 60000) % 60,\n\t\tseconds: roundTowardsZero(milliseconds / 1000) % 60,\n\t\tmilliseconds: roundTowardsZero(milliseconds) % 1000,\n\t\tmicroseconds: roundTowardsZero(milliseconds * 1000) % 1000,\n\t\tnanoseconds: roundTowardsZero(milliseconds * 1e6) % 1000\n\t};\n};\n\n\n//# sourceURL=webpack://VideojsWavesurfer/./node_modules/parse-ms/index.js?"); | ||
// Adds back minus sign if needed | ||
return (isNegative ? '-' : '') + buffer; | ||
} | ||
/***/ }), | ||
if(true) { | ||
!(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { return addZero; }).call(exports, __webpack_require__, exports, module), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
} else {} | ||
/***/ "./node_modules/webpack/buildin/global.js": | ||
/*!***********************************!*\ | ||
!*** (webpack)/buildin/global.js ***! | ||
\***********************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports) { | ||
})(this); | ||
eval("var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n\n\n//# sourceURL=webpack://VideojsWavesurfer/(webpack)/buildin/global.js?"); | ||
/***/ }), | ||
/***/ "./src/css/videojs.wavesurfer.scss": | ||
/*!*****************************************!*\ | ||
!*** ./src/css/videojs.wavesurfer.scss ***! | ||
\*****************************************/ | ||
/*! no exports provided */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
eval("__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extract-plugin\n\n\n//# sourceURL=webpack://VideojsWavesurfer/./src/css/videojs.wavesurfer.scss?"); | ||
/***/ }), | ||
/***/ "./src/js/defaults.js": | ||
@@ -169,8 +66,19 @@ /*!****************************!*\ | ||
\****************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/***/ ((module, exports) => { | ||
"use strict"; | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\nvar pluginDefaultOptions = {\n debug: false,\n displayMilliseconds: true\n};\nvar _default = pluginDefaultOptions;\nexports.default = _default;\nmodule.exports = exports.default;\n\n//# sourceURL=webpack://VideojsWavesurfer/./src/js/defaults.js?"); | ||
Object.defineProperty(exports, "__esModule", ({ | ||
value: true | ||
})); | ||
exports.default = void 0; | ||
var pluginDefaultOptions = { | ||
debug: false, | ||
displayMilliseconds: true | ||
}; | ||
var _default = pluginDefaultOptions; | ||
exports.default = _default; | ||
module.exports = exports.default; | ||
/***/ }), | ||
@@ -182,8 +90,41 @@ | ||
\*************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/***/ ((module, exports) => { | ||
"use strict"; | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar Event = function Event() {\n _classCallCheck(this, Event);\n};\n\nEvent.READY = 'ready';\nEvent.ERROR = 'error';\nEvent.VOLUMECHANGE = 'volumechange';\nEvent.FULLSCREENCHANGE = 'fullscreenchange';\nEvent.TIMEUPDATE = 'timeupdate';\nEvent.ENDED = 'ended';\nEvent.PAUSE = 'pause';\nEvent.FINISH = 'finish';\nEvent.SEEK = 'seek';\nEvent.REDRAW = 'redraw';\nEvent.AUDIOPROCESS = 'audioprocess';\nEvent.DEVICE_READY = 'deviceReady';\nEvent.DEVICE_ERROR = 'deviceError';\nEvent.AUDIO_OUTPUT_READY = 'audioOutputReady';\nEvent.WAVE_READY = 'waveReady';\nEvent.PLAYBACK_FINISH = 'playbackFinish';\nEvent.ABORT = 'abort';\nEvent.RESIZE = 'resize';\nObject.freeze(Event);\nvar _default = Event;\nexports.default = _default;\nmodule.exports = exports.default;\n\n//# sourceURL=webpack://VideojsWavesurfer/./src/js/event.js?"); | ||
Object.defineProperty(exports, "__esModule", ({ | ||
value: true | ||
})); | ||
exports.default = void 0; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var Event = function Event() { | ||
_classCallCheck(this, Event); | ||
}; | ||
Event.READY = 'ready'; | ||
Event.ERROR = 'error'; | ||
Event.VOLUMECHANGE = 'volumechange'; | ||
Event.FULLSCREENCHANGE = 'fullscreenchange'; | ||
Event.TIMEUPDATE = 'timeupdate'; | ||
Event.ENDED = 'ended'; | ||
Event.PAUSE = 'pause'; | ||
Event.FINISH = 'finish'; | ||
Event.SEEK = 'seek'; | ||
Event.REDRAW = 'redraw'; | ||
Event.AUDIOPROCESS = 'audioprocess'; | ||
Event.DEVICE_READY = 'deviceReady'; | ||
Event.DEVICE_ERROR = 'deviceError'; | ||
Event.AUDIO_OUTPUT_READY = 'audioOutputReady'; | ||
Event.WAVE_READY = 'waveReady'; | ||
Event.PLAYBACK_FINISH = 'playbackFinish'; | ||
Event.ABORT = 'abort'; | ||
Event.RESIZE = 'resize'; | ||
Object.freeze(Event); | ||
var _default = Event; | ||
exports.default = _default; | ||
module.exports = exports.default; | ||
/***/ }), | ||
@@ -195,8 +136,44 @@ | ||
\******************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/***/ ((module, exports) => { | ||
"use strict"; | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\nvar WavesurferMiddleware = {\n setSource: function setSource(srcObj, next) {\n if (this.player.usingPlugin('wavesurfer')) {\n var backend = this.player.wavesurfer().surfer.params.backend;\n var src = srcObj.src;\n var peaks = srcObj.peaks;\n\n switch (backend) {\n case 'WebAudio':\n this.player.wavesurfer().load(src);\n break;\n\n default:\n next(null, srcObj);\n var element = this.player.tech_.el();\n\n if (peaks === undefined) {\n this.player.wavesurfer().load(element);\n } else {\n this.player.wavesurfer().load(element, peaks);\n }\n\n break;\n }\n } else {\n next(null, srcObj);\n }\n }\n};\nvar _default = WavesurferMiddleware;\nexports.default = _default;\nmodule.exports = exports.default;\n\n//# sourceURL=webpack://VideojsWavesurfer/./src/js/middleware.js?"); | ||
Object.defineProperty(exports, "__esModule", ({ | ||
value: true | ||
})); | ||
exports.default = void 0; | ||
var WavesurferMiddleware = { | ||
setSource: function setSource(srcObj, next) { | ||
if (this.player.usingPlugin('wavesurfer')) { | ||
var backend = this.player.wavesurfer().surfer.params.backend; | ||
var src = srcObj.src; | ||
var peaks = srcObj.peaks; | ||
switch (backend) { | ||
case 'WebAudio': | ||
this.player.wavesurfer().load(src); | ||
break; | ||
default: | ||
next(null, srcObj); | ||
var element = this.player.tech_.el(); | ||
if (peaks === undefined) { | ||
this.player.wavesurfer().load(element); | ||
} else { | ||
this.player.wavesurfer().load(element, peaks); | ||
} | ||
break; | ||
} | ||
} else { | ||
next(null, srcObj); | ||
} | ||
} | ||
}; | ||
var _default = WavesurferMiddleware; | ||
exports.default = _default; | ||
module.exports = exports.default; | ||
/***/ }), | ||
@@ -208,8 +185,58 @@ | ||
\*************************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/***/ ((module, exports, __webpack_require__) => { | ||
"use strict"; | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _addZero = _interopRequireDefault(__webpack_require__(/*! add-zero */ \"./node_modules/add-zero/index.js\"));\n\nvar _parseMs = _interopRequireDefault(__webpack_require__(/*! parse-ms */ \"./node_modules/parse-ms/index.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar formatTime = function formatTime(seconds, guide) {\n var displayMilliseconds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;\n seconds = seconds < 0 ? 0 : seconds;\n\n if (isNaN(seconds) || seconds === Infinity) {\n seconds = 0;\n }\n\n var inputTime = (0, _parseMs.default)(seconds * 1000);\n var guideTime = inputTime;\n\n if (guide !== undefined) {\n guideTime = (0, _parseMs.default)(guide * 1000);\n }\n\n var hr = (0, _addZero.default)(inputTime.hours);\n var min = (0, _addZero.default)(inputTime.minutes);\n var sec = (0, _addZero.default)(inputTime.seconds);\n var ms = (0, _addZero.default)(inputTime.milliseconds, 3);\n\n if (inputTime.days > 0 || guideTime.days > 0) {\n var day = (0, _addZero.default)(inputTime.days);\n return \"\".concat(day, \":\").concat(hr, \":\").concat(min, \":\").concat(sec);\n }\n\n if (inputTime.hours > 0 || guideTime.hours > 0) {\n return \"\".concat(hr, \":\").concat(min, \":\").concat(sec);\n }\n\n if (displayMilliseconds) {\n return \"\".concat(min, \":\").concat(sec, \":\").concat(ms);\n }\n\n return \"\".concat(min, \":\").concat(sec);\n};\n\nvar _default = formatTime;\nexports.default = _default;\nmodule.exports = exports.default;\n\n//# sourceURL=webpack://VideojsWavesurfer/./src/js/utils/format-time.js?"); | ||
Object.defineProperty(exports, "__esModule", ({ | ||
value: true | ||
})); | ||
exports.default = void 0; | ||
var _addZero = _interopRequireDefault(__webpack_require__(/*! add-zero */ "./node_modules/add-zero/index.js")); | ||
var _parseMs = _interopRequireDefault(__webpack_require__(/*! parse-ms */ "./node_modules/parse-ms/index.js")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var formatTime = function formatTime(seconds, guide) { | ||
var displayMilliseconds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; | ||
seconds = seconds < 0 ? 0 : seconds; | ||
if (isNaN(seconds) || seconds === Infinity) { | ||
seconds = 0; | ||
} | ||
var inputTime = (0, _parseMs.default)(seconds * 1000); | ||
var guideTime = inputTime; | ||
if (guide !== undefined) { | ||
guideTime = (0, _parseMs.default)(guide * 1000); | ||
} | ||
var hr = (0, _addZero.default)(inputTime.hours); | ||
var min = (0, _addZero.default)(inputTime.minutes); | ||
var sec = (0, _addZero.default)(inputTime.seconds); | ||
var ms = (0, _addZero.default)(inputTime.milliseconds, 3); | ||
if (inputTime.days > 0 || guideTime.days > 0) { | ||
var day = (0, _addZero.default)(inputTime.days); | ||
return "".concat(day, ":").concat(hr, ":").concat(min, ":").concat(sec); | ||
} | ||
if (inputTime.hours > 0 || guideTime.hours > 0) { | ||
return "".concat(hr, ":").concat(min, ":").concat(sec); | ||
} | ||
if (displayMilliseconds) { | ||
return "".concat(min, ":").concat(sec, ":").concat(ms); | ||
} | ||
return "".concat(min, ":").concat(sec); | ||
}; | ||
var _default = formatTime; | ||
exports.default = _default; | ||
module.exports = exports.default; | ||
/***/ }), | ||
@@ -221,8 +248,35 @@ | ||
\*****************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/***/ ((module, exports, __webpack_require__) => { | ||
"use strict"; | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _video = _interopRequireDefault(__webpack_require__(/*! video.js */ \"video.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar ERROR = 'error';\nvar WARN = 'warn';\n\nvar log = function log(args, logType, debug) {\n if (debug === true) {\n if (logType === ERROR) {\n _video.default.log.error(args);\n } else if (logType === WARN) {\n _video.default.log.warn(args);\n } else {\n _video.default.log(args);\n }\n }\n};\n\nvar _default = log;\nexports.default = _default;\nmodule.exports = exports.default;\n\n//# sourceURL=webpack://VideojsWavesurfer/./src/js/utils/log.js?"); | ||
Object.defineProperty(exports, "__esModule", ({ | ||
value: true | ||
})); | ||
exports.default = void 0; | ||
var _video = _interopRequireDefault(__webpack_require__(/*! video.js */ "video.js")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var ERROR = 'error'; | ||
var WARN = 'warn'; | ||
var log = function log(args, logType, debug) { | ||
if (debug === true) { | ||
if (logType === ERROR) { | ||
_video.default.log.error(args); | ||
} else if (logType === WARN) { | ||
_video.default.log.warn(args); | ||
} else { | ||
_video.default.log(args); | ||
} | ||
} | ||
}; | ||
var _default = log; | ||
exports.default = _default; | ||
module.exports = exports.default; | ||
/***/ }), | ||
@@ -234,21 +288,691 @@ | ||
\**************************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => { | ||
"use strict"; | ||
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.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 _middleware = _interopRequireDefault(__webpack_require__(/*! ./middleware */ \"./src/js/middleware.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 _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 { Date.prototype.toString.call(Reflect.construct(Date, [], 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 Plugin = _video.default.getPlugin('plugin');\n\nvar wavesurferPluginName = 'wavesurfer';\nvar wavesurferClassName = 'vjs-wavedisplay';\nvar wavesurferStyleName = 'vjs-wavesurfer';\nvar WEBAUDIO = 'WebAudio';\nvar MEDIAELEMENT = 'MediaElement';\nvar MEDIAELEMENT_WEBAUDIO = 'MediaElementWebAudio';\n\nvar Wavesurfer = function (_Plugin) {\n _inherits(Wavesurfer, _Plugin);\n\n var _super = _createSuper(Wavesurfer);\n\n function Wavesurfer(player, options) {\n var _this;\n\n _classCallCheck(this, Wavesurfer);\n\n _this = _super.call(this, player, options);\n player.addClass(wavesurferStyleName);\n options = _video.default.mergeOptions(_defaults.default, options);\n _this.waveReady = false;\n _this.waveFinished = false;\n _this.liveMode = false;\n _this.backend = null;\n _this.debug = options.debug.toString() === 'true';\n _this.textTracksEnabled = _this.player.options_.tracks.length > 0;\n _this.displayMilliseconds = options.displayMilliseconds;\n\n _video.default.setFormatTime(function (seconds, guide) {\n return (0, _formatTime.default)(seconds, guide, _this.displayMilliseconds);\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 if (this.player.bigPlayButton !== undefined) {\n this.player.bigPlayButton.hide();\n }\n\n var mergedOptions = this.parseOptions(this.player.options_.plugins.wavesurfer);\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.backend === WEBAUDIO && 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.backend === WEBAUDIO && this.player.controlBar.playToggle !== undefined) {\n this.player.controlBar.playToggle.on(['tap', 'click'], this.onPlayToggle.bind(this));\n this.player.controlBar.playToggle.hide();\n }\n }\n\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 this.backend = this.surfer.params.backend;\n this.log('Using wavesurfer.js ' + this.backend + ' backend.');\n\n if ('microphone' in this.player.wavesurfer().surfer.getActivePlugins()) {\n this.liveMode = true;\n this.waveReady = true;\n this.log('wavesurfer.js microphone plugin enabled.');\n this.player.controlBar.playToggle.show();\n this.surfer.microphone.on(_event.default.DEVICE_ERROR, this.onWaveError.bind(this));\n }\n\n this.surferReady = this.onWaveReady.bind(this);\n\n if (this.backend === WEBAUDIO) {\n this.surferProgress = this.onWaveProgress.bind(this);\n this.surferSeek = this.onWaveSeek.bind(this);\n\n if (this.player.muted()) {\n this.setVolume(0);\n }\n }\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.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 }, {\n key: \"parseOptions\",\n value: function parseOptions() {\n var surferOpts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\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 ('backend' in surferOpts) {\n this.backend = surferOpts.backend;\n } else {\n surferOpts.backend = this.backend = MEDIAELEMENT;\n }\n\n return surferOpts;\n }\n }, {\n key: \"setupPlaybackEvents\",\n value: function setupPlaybackEvents(enable) {\n if (enable === false) {\n this.surfer.un(_event.default.READY, this.surferReady);\n\n if (this.backend === WEBAUDIO) {\n this.surfer.un(_event.default.AUDIOPROCESS, this.surferProgress);\n this.surfer.un(_event.default.SEEK, this.surferSeek);\n }\n } else if (enable === true) {\n this.surfer.on(_event.default.READY, this.surferReady);\n\n if (this.backend === WEBAUDIO) {\n this.surfer.on(_event.default.AUDIOPROCESS, this.surferProgress);\n this.surfer.on(_event.default.SEEK, this.surferSeek);\n }\n }\n }\n }, {\n key: \"load\",\n value: function load(url, peaks) {\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 this.loadPeaks(url, peaks);\n } else {\n if (typeof url === 'string') {\n this.log('Loading URL: ' + url);\n } else {\n this.log('Loading element: ' + url);\n }\n\n this.surfer.load(url);\n }\n }\n }\n }, {\n key: \"loadPeaks\",\n value: function loadPeaks(url, peaks) {\n var _this3 = this;\n\n if (Array.isArray(peaks)) {\n this.log('Loading URL with array of peaks: ' + 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.once('error', function (e) {\n _this3.player.trigger(_event.default.ERROR, 'Unable to retrieve peak data from ' + peaks + '. Status code: ' + request.response.status);\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 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 var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'blob';\n return this.surfer.exportImage(format, quality, type);\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() && this.player.controlBar.currentTimeDisplay.contentEl().lastChild) {\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.displayMilliseconds);\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() && this.player.controlBar.durationDisplay.contentEl().lastChild) {\n this.player.controlBar.durationDisplay.formattedTime_ = this.player.controlBar.durationDisplay.contentEl().lastChild.textContent = (0, _formatTime.default)(duration, duration, this.displayMilliseconds);\n }\n }\n }, {\n key: \"onWaveReady\",\n value: function onWaveReady() {\n var _this5 = this;\n\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\n if (this.backend === WEBAUDIO) {\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\n if (this.player.loadingSpinner.contentEl()) {\n this.player.loadingSpinner.hide();\n }\n\n if (this.player.options_.autoplay === true) {\n this.setVolume(0);\n\n if (this.backend === WEBAUDIO) {\n this.play();\n } else {\n this.player.play().catch(function (e) {\n _this5.onWaveError(e);\n });\n }\n }\n }\n }, {\n key: \"onWaveFinish\",\n value: function onWaveFinish() {\n var _this6 = this;\n\n this.log('Finished playback');\n this.player.trigger(_event.default.PLAYBACK_FINISH);\n\n if (this.player.options_.loop === true) {\n if (this.backend === WEBAUDIO) {\n this.surfer.stop();\n this.play();\n }\n } else {\n this.waveFinished = true;\n\n if (this.backend === WEBAUDIO) {\n this.pause();\n this.player.trigger(_event.default.ENDED);\n this.surfer.once(_event.default.SEEK, function () {\n if (_this6.player.controlBar.playToggle !== undefined) {\n _this6.player.controlBar.playToggle.removeClass('vjs-ended');\n }\n\n _this6.player.trigger(_event.default.PAUSE);\n });\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 _this7 = this;\n\n var fullscreenDelay = this.player.setInterval(function () {\n var isFullscreen = _this7.player.isFullscreen();\n\n var newWidth, newHeight;\n\n if (!isFullscreen) {\n newWidth = _this7.originalWidth;\n newHeight = _this7.originalHeight;\n }\n\n if (_this7.waveReady) {\n if (_this7.liveMode && !_this7.surfer.microphone.active) {\n return;\n }\n\n _this7.redrawWaveform(newWidth, newHeight);\n }\n\n _this7.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 = \"3.4.0\";\n_video.default.Wavesurfer = Wavesurfer;\n\nif (_video.default.getPlugin(wavesurferPluginName) === undefined) {\n _video.default.registerPlugin(wavesurferPluginName, Wavesurfer);\n}\n\n_video.default.use('*', function (player) {\n _middleware.default.player = player;\n return _middleware.default;\n});\n\n//# sourceURL=webpack://VideojsWavesurfer/./src/js/videojs.wavesurfer.js?"); | ||
function _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); } | ||
Object.defineProperty(exports, "__esModule", ({ | ||
value: true | ||
})); | ||
exports.Wavesurfer = void 0; | ||
var _event = _interopRequireDefault(__webpack_require__(/*! ./event */ "./src/js/event.js")); | ||
var _log2 = _interopRequireDefault(__webpack_require__(/*! ./utils/log */ "./src/js/utils/log.js")); | ||
var _formatTime = _interopRequireDefault(__webpack_require__(/*! ./utils/format-time */ "./src/js/utils/format-time.js")); | ||
var _defaults = _interopRequireDefault(__webpack_require__(/*! ./defaults */ "./src/js/defaults.js")); | ||
var _middleware = _interopRequireDefault(__webpack_require__(/*! ./middleware */ "./src/js/middleware.js")); | ||
var _window = _interopRequireDefault(__webpack_require__(/*! global/window */ "./node_modules/global/window.js")); | ||
var _video = _interopRequireDefault(__webpack_require__(/*! video.js */ "video.js")); | ||
var _wavesurfer = _interopRequireDefault(__webpack_require__(/*! wavesurfer.js */ "wavesurfer.js")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _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); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
var Plugin = _video.default.getPlugin('plugin'); | ||
var wavesurferPluginName = 'wavesurfer'; | ||
var wavesurferClassName = 'vjs-wavedisplay'; | ||
var wavesurferStyleName = 'vjs-wavesurfer'; | ||
var WEBAUDIO = 'WebAudio'; | ||
var MEDIAELEMENT = 'MediaElement'; | ||
var MEDIAELEMENT_WEBAUDIO = 'MediaElementWebAudio'; | ||
var Wavesurfer = function (_Plugin) { | ||
_inherits(Wavesurfer, _Plugin); | ||
var _super = _createSuper(Wavesurfer); | ||
function Wavesurfer(player, options) { | ||
var _this; | ||
_classCallCheck(this, Wavesurfer); | ||
_this = _super.call(this, player, options); | ||
player.addClass(wavesurferStyleName); | ||
options = _video.default.mergeOptions(_defaults.default, options); | ||
_this.waveReady = false; | ||
_this.waveFinished = false; | ||
_this.liveMode = false; | ||
_this.backend = null; | ||
_this.debug = options.debug.toString() === 'true'; | ||
_this.textTracksEnabled = _this.player.options_.tracks.length > 0; | ||
_this.displayMilliseconds = options.displayMilliseconds; | ||
if (options.formatTime && typeof options.formatTime === 'function') { | ||
_this.setFormatTime(options.formatTime); | ||
} else { | ||
_this.setFormatTime(function (seconds, guide) { | ||
return (0, _formatTime.default)(seconds, guide, _this.displayMilliseconds); | ||
}); | ||
} | ||
_this.player.one(_event.default.READY, _this.initialize.bind(_assertThisInitialized(_this))); | ||
return _this; | ||
} | ||
_createClass(Wavesurfer, [{ | ||
key: "initialize", | ||
value: function initialize() { | ||
var _this2 = this; | ||
if (this.player.bigPlayButton !== undefined) { | ||
this.player.bigPlayButton.hide(); | ||
} | ||
var mergedOptions = this.parseOptions(this.player.options_.plugins.wavesurfer); | ||
if (this.player.options_.controls === true) { | ||
this.player.controlBar.show(); | ||
this.player.controlBar.el_.style.display = 'flex'; | ||
if (this.backend === WEBAUDIO && this.player.controlBar.progressControl !== undefined) { | ||
this.player.controlBar.progressControl.hide(); | ||
} | ||
if (this.player.controlBar.pictureInPictureToggle !== undefined) { | ||
this.player.controlBar.pictureInPictureToggle.hide(); | ||
} | ||
var uiElements = ['currentTimeDisplay', 'timeDivider', 'durationDisplay']; | ||
uiElements.forEach(function (element) { | ||
element = _this2.player.controlBar[element]; | ||
if (element !== undefined) { | ||
element.el_.style.display = 'block'; | ||
element.show(); | ||
} | ||
}); | ||
if (this.player.controlBar.remainingTimeDisplay !== undefined) { | ||
this.player.controlBar.remainingTimeDisplay.hide(); | ||
} | ||
if (this.backend === WEBAUDIO && this.player.controlBar.playToggle !== undefined) { | ||
this.player.controlBar.playToggle.on(['tap', 'click'], this.onPlayToggle.bind(this)); | ||
this.player.controlBar.playToggle.hide(); | ||
} | ||
} | ||
this.surfer = _wavesurfer.default.create(mergedOptions); | ||
this.surfer.on(_event.default.ERROR, this.onWaveError.bind(this)); | ||
this.surfer.on(_event.default.FINISH, this.onWaveFinish.bind(this)); | ||
this.backend = this.surfer.params.backend; | ||
this.log('Using wavesurfer.js ' + this.backend + ' backend.'); | ||
if ('microphone' in this.player.wavesurfer().surfer.getActivePlugins()) { | ||
this.liveMode = true; | ||
this.waveReady = true; | ||
this.log('wavesurfer.js microphone plugin enabled.'); | ||
this.player.controlBar.playToggle.show(); | ||
this.surfer.microphone.on(_event.default.DEVICE_ERROR, this.onWaveError.bind(this)); | ||
} | ||
this.surferReady = this.onWaveReady.bind(this); | ||
if (this.backend === WEBAUDIO) { | ||
this.surferProgress = this.onWaveProgress.bind(this); | ||
this.surferSeek = this.onWaveSeek.bind(this); | ||
if (this.player.muted()) { | ||
this.setVolume(0); | ||
} | ||
} | ||
if (!this.liveMode) { | ||
this.setupPlaybackEvents(true); | ||
} | ||
this.player.on(_event.default.VOLUMECHANGE, this.onVolumeChange.bind(this)); | ||
this.player.on(_event.default.FULLSCREENCHANGE, this.onScreenChange.bind(this)); | ||
if (this.player.options_.fluid === true) { | ||
this.surfer.drawer.wrapper.className = wavesurferClassName; | ||
this.responsiveWave = _wavesurfer.default.util.debounce(this.onResizeChange.bind(this), 150); | ||
_window.default.addEventListener(_event.default.RESIZE, this.responsiveWave); | ||
} | ||
} | ||
}, { | ||
key: "parseOptions", | ||
value: function parseOptions() { | ||
var surferOpts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var rect = this.player.el_.getBoundingClientRect(); | ||
this.originalWidth = this.player.options_.width || rect.width; | ||
this.originalHeight = this.player.options_.height || rect.height; | ||
var controlBarHeight = this.player.controlBar.height(); | ||
if (this.player.options_.controls === true && controlBarHeight === 0) { | ||
controlBarHeight = 30; | ||
} | ||
if (surferOpts.container === undefined) { | ||
surferOpts.container = this.player.el_; | ||
} | ||
if (surferOpts.waveformHeight === undefined) { | ||
var playerHeight = rect.height; | ||
surferOpts.height = playerHeight - controlBarHeight; | ||
} else { | ||
surferOpts.height = surferOpts.waveformHeight; | ||
} | ||
if (surferOpts.splitChannels && surferOpts.splitChannels === true) { | ||
surferOpts.height /= 2; | ||
} | ||
if ('backend' in surferOpts) { | ||
this.backend = surferOpts.backend; | ||
} else { | ||
surferOpts.backend = this.backend = MEDIAELEMENT; | ||
} | ||
return surferOpts; | ||
} | ||
}, { | ||
key: "setupPlaybackEvents", | ||
value: function setupPlaybackEvents(enable) { | ||
if (enable === false) { | ||
this.surfer.un(_event.default.READY, this.surferReady); | ||
if (this.backend === WEBAUDIO) { | ||
this.surfer.un(_event.default.AUDIOPROCESS, this.surferProgress); | ||
this.surfer.un(_event.default.SEEK, this.surferSeek); | ||
} | ||
} else if (enable === true) { | ||
this.surfer.on(_event.default.READY, this.surferReady); | ||
if (this.backend === WEBAUDIO) { | ||
this.surfer.on(_event.default.AUDIOPROCESS, this.surferProgress); | ||
this.surfer.on(_event.default.SEEK, this.surferSeek); | ||
} | ||
} | ||
} | ||
}, { | ||
key: "load", | ||
value: function load(url, peaks) { | ||
if (url instanceof Blob || url instanceof File) { | ||
this.log('Loading object: ' + JSON.stringify(url)); | ||
this.surfer.loadBlob(url); | ||
} else { | ||
if (peaks !== undefined) { | ||
this.loadPeaks(url, peaks); | ||
} else { | ||
if (typeof url === 'string') { | ||
this.log('Loading URL: ' + url); | ||
} else { | ||
this.log('Loading element: ' + url); | ||
} | ||
this.surfer.load(url); | ||
} | ||
} | ||
} | ||
}, { | ||
key: "loadPeaks", | ||
value: function loadPeaks(url, peaks) { | ||
var _this3 = this; | ||
if (Array.isArray(peaks)) { | ||
this.log('Loading URL with array of peaks: ' + url); | ||
this.surfer.load(url, peaks); | ||
} else { | ||
var requestOptions = { | ||
url: peaks, | ||
responseType: 'json' | ||
}; | ||
if (this.player.options_.plugins.wavesurfer.xhr !== undefined) { | ||
requestOptions.xhr = this.player.options_.plugins.wavesurfer.xhr; | ||
} | ||
var request = _wavesurfer.default.util.fetchFile(requestOptions); | ||
request.once('success', function (data) { | ||
_this3.log('Loaded Peak Data URL: ' + peaks); | ||
if (data && data.data) { | ||
_this3.surfer.load(url, data.data); | ||
} else { | ||
_this3.player.trigger(_event.default.ERROR, 'Could not load peaks data from ' + peaks); | ||
_this3.log(err, 'error'); | ||
} | ||
}); | ||
request.once('error', function (e) { | ||
_this3.player.trigger(_event.default.ERROR, 'Unable to retrieve peak data from ' + peaks + '. Status code: ' + request.response.status); | ||
}); | ||
} | ||
} | ||
}, { | ||
key: "play", | ||
value: function play() { | ||
if (this.player.controlBar.playToggle !== undefined && this.player.controlBar.playToggle.contentEl()) { | ||
this.player.controlBar.playToggle.handlePlay(); | ||
} | ||
if (this.liveMode) { | ||
if (!this.surfer.microphone.active) { | ||
this.log('Start microphone'); | ||
this.surfer.microphone.start(); | ||
} else { | ||
var paused = !this.surfer.microphone.paused; | ||
if (paused) { | ||
this.pause(); | ||
} else { | ||
this.log('Resume microphone'); | ||
this.surfer.microphone.play(); | ||
} | ||
} | ||
} else { | ||
this.log('Start playback'); | ||
this.player.play(); | ||
this.surfer.play(); | ||
} | ||
} | ||
}, { | ||
key: "pause", | ||
value: function pause() { | ||
if (this.player.controlBar.playToggle !== undefined && this.player.controlBar.playToggle.contentEl()) { | ||
this.player.controlBar.playToggle.handlePause(); | ||
} | ||
if (this.liveMode) { | ||
this.log('Pause microphone'); | ||
this.surfer.microphone.pause(); | ||
} else { | ||
this.log('Pause playback'); | ||
if (!this.waveFinished) { | ||
this.surfer.pause(); | ||
} else { | ||
this.waveFinished = false; | ||
} | ||
this.setCurrentTime(); | ||
} | ||
} | ||
}, { | ||
key: "dispose", | ||
value: function dispose() { | ||
if (this.surfer) { | ||
if (this.liveMode && this.surfer.microphone) { | ||
this.surfer.microphone.destroy(); | ||
this.log('Destroyed microphone plugin'); | ||
} | ||
this.surfer.destroy(); | ||
} | ||
this.log('Destroyed plugin'); | ||
} | ||
}, { | ||
key: "isDestroyed", | ||
value: function isDestroyed() { | ||
return this.player && this.player.children() === null; | ||
} | ||
}, { | ||
key: "destroy", | ||
value: function destroy() { | ||
this.player.dispose(); | ||
} | ||
}, { | ||
key: "setVolume", | ||
value: function setVolume(volume) { | ||
if (volume !== undefined) { | ||
this.log('Changing volume to: ' + volume); | ||
this.player.volume(volume); | ||
} | ||
} | ||
}, { | ||
key: "exportImage", | ||
value: function exportImage(format, quality) { | ||
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'blob'; | ||
return this.surfer.exportImage(format, quality, type); | ||
} | ||
}, { | ||
key: "setAudioOutput", | ||
value: function setAudioOutput(deviceId) { | ||
var _this4 = this; | ||
if (deviceId) { | ||
this.surfer.setSinkId(deviceId).then(function (result) { | ||
_this4.player.trigger(_event.default.AUDIO_OUTPUT_READY); | ||
}).catch(function (err) { | ||
_this4.player.trigger(_event.default.ERROR, err); | ||
_this4.log(err, 'error'); | ||
}); | ||
} | ||
} | ||
}, { | ||
key: "getCurrentTime", | ||
value: function getCurrentTime() { | ||
var currentTime = this.surfer.getCurrentTime(); | ||
currentTime = isNaN(currentTime) ? 0 : currentTime; | ||
return currentTime; | ||
} | ||
}, { | ||
key: "setCurrentTime", | ||
value: function setCurrentTime(currentTime, duration) { | ||
if (currentTime === undefined) { | ||
currentTime = this.surfer.getCurrentTime(); | ||
} | ||
if (duration === undefined) { | ||
duration = this.surfer.getDuration(); | ||
} | ||
currentTime = isNaN(currentTime) ? 0 : currentTime; | ||
duration = isNaN(duration) ? 0 : duration; | ||
if (this.player.controlBar.currentTimeDisplay && this.player.controlBar.currentTimeDisplay.contentEl() && this.player.controlBar.currentTimeDisplay.contentEl().lastChild) { | ||
var time = Math.min(currentTime, duration); | ||
this.player.controlBar.currentTimeDisplay.formattedTime_ = this.player.controlBar.currentTimeDisplay.contentEl().lastChild.textContent = this._formatTime(time, duration, this.displayMilliseconds); | ||
} | ||
if (this.textTracksEnabled && this.player.tech_ && this.player.tech_.el_) { | ||
this.player.tech_.setCurrentTime(currentTime); | ||
} | ||
} | ||
}, { | ||
key: "getDuration", | ||
value: function getDuration() { | ||
var duration = this.surfer.getDuration(); | ||
duration = isNaN(duration) ? 0 : duration; | ||
return duration; | ||
} | ||
}, { | ||
key: "setDuration", | ||
value: function setDuration(duration) { | ||
if (duration === undefined) { | ||
duration = this.surfer.getDuration(); | ||
} | ||
duration = isNaN(duration) ? 0 : duration; | ||
if (this.player.controlBar.durationDisplay && this.player.controlBar.durationDisplay.contentEl() && this.player.controlBar.durationDisplay.contentEl().lastChild) { | ||
this.player.controlBar.durationDisplay.formattedTime_ = this.player.controlBar.durationDisplay.contentEl().lastChild.textContent = this._formatTime(duration, duration, this.displayMilliseconds); | ||
} | ||
} | ||
}, { | ||
key: "onWaveReady", | ||
value: function onWaveReady() { | ||
var _this5 = this; | ||
this.waveReady = true; | ||
this.waveFinished = false; | ||
this.liveMode = false; | ||
this.log('Waveform is ready'); | ||
this.player.trigger(_event.default.WAVE_READY); | ||
if (this.backend === WEBAUDIO) { | ||
this.setCurrentTime(); | ||
this.setDuration(); | ||
if (this.player.controlBar.playToggle !== undefined && this.player.controlBar.playToggle.contentEl()) { | ||
this.player.controlBar.playToggle.show(); | ||
} | ||
} | ||
if (this.player.loadingSpinner.contentEl()) { | ||
this.player.loadingSpinner.hide(); | ||
} | ||
if (this.player.options_.autoplay === true) { | ||
this.setVolume(0); | ||
if (this.backend === WEBAUDIO) { | ||
this.play(); | ||
} else { | ||
this.player.play().catch(function (e) { | ||
_this5.onWaveError(e); | ||
}); | ||
} | ||
} | ||
} | ||
}, { | ||
key: "onWaveFinish", | ||
value: function onWaveFinish() { | ||
var _this6 = this; | ||
this.log('Finished playback'); | ||
this.player.trigger(_event.default.PLAYBACK_FINISH); | ||
if (this.player.options_.loop === true) { | ||
if (this.backend === WEBAUDIO) { | ||
this.surfer.stop(); | ||
this.play(); | ||
} | ||
} else { | ||
this.waveFinished = true; | ||
if (this.backend === WEBAUDIO) { | ||
this.pause(); | ||
this.player.trigger(_event.default.ENDED); | ||
this.surfer.once(_event.default.SEEK, function () { | ||
if (_this6.player.controlBar.playToggle !== undefined) { | ||
_this6.player.controlBar.playToggle.removeClass('vjs-ended'); | ||
} | ||
_this6.player.trigger(_event.default.PAUSE); | ||
}); | ||
} | ||
} | ||
} | ||
}, { | ||
key: "onWaveProgress", | ||
value: function onWaveProgress(time) { | ||
this.setCurrentTime(); | ||
} | ||
}, { | ||
key: "onWaveSeek", | ||
value: function onWaveSeek() { | ||
this.setCurrentTime(); | ||
} | ||
}, { | ||
key: "onWaveError", | ||
value: function onWaveError(error) { | ||
if (error.name && error.name === 'AbortError' || error.name === 'DOMException' && error.message.startsWith('The operation was aborted')) { | ||
this.player.trigger(_event.default.ABORT, error); | ||
} else { | ||
this.player.trigger(_event.default.ERROR, error); | ||
this.log(error, 'error'); | ||
} | ||
} | ||
}, { | ||
key: "onPlayToggle", | ||
value: function onPlayToggle() { | ||
if (this.player.controlBar.playToggle !== undefined && this.player.controlBar.playToggle.hasClass('vjs-ended')) { | ||
this.player.controlBar.playToggle.removeClass('vjs-ended'); | ||
} | ||
if (this.surfer.isPlaying()) { | ||
this.pause(); | ||
} else { | ||
this.play(); | ||
} | ||
} | ||
}, { | ||
key: "onVolumeChange", | ||
value: function onVolumeChange() { | ||
var volume = this.player.volume(); | ||
if (this.player.muted()) { | ||
volume = 0; | ||
} | ||
this.surfer.setVolume(volume); | ||
} | ||
}, { | ||
key: "onScreenChange", | ||
value: function onScreenChange() { | ||
var _this7 = this; | ||
var fullscreenDelay = this.player.setInterval(function () { | ||
var isFullscreen = _this7.player.isFullscreen(); | ||
var newWidth, newHeight; | ||
if (!isFullscreen) { | ||
newWidth = _this7.originalWidth; | ||
newHeight = _this7.originalHeight; | ||
} | ||
if (_this7.waveReady) { | ||
if (_this7.liveMode && !_this7.surfer.microphone.active) { | ||
return; | ||
} | ||
_this7.redrawWaveform(newWidth, newHeight); | ||
} | ||
_this7.player.clearInterval(fullscreenDelay); | ||
}, 100); | ||
} | ||
}, { | ||
key: "onResizeChange", | ||
value: function onResizeChange() { | ||
if (this.surfer !== undefined) { | ||
this.redrawWaveform(); | ||
} | ||
} | ||
}, { | ||
key: "redrawWaveform", | ||
value: function redrawWaveform(newWidth, newHeight) { | ||
if (!this.isDestroyed()) { | ||
if (this.player.el_) { | ||
var rect = this.player.el_.getBoundingClientRect(); | ||
if (newWidth === undefined) { | ||
newWidth = rect.width; | ||
} | ||
if (newHeight === undefined) { | ||
newHeight = rect.height; | ||
} | ||
} | ||
this.surfer.drawer.destroy(); | ||
this.surfer.params.width = newWidth; | ||
this.surfer.params.height = newHeight - this.player.controlBar.height(); | ||
this.surfer.createDrawer(); | ||
this.surfer.drawer.wrapper.className = wavesurferClassName; | ||
this.surfer.drawBuffer(); | ||
this.surfer.drawer.progress(this.surfer.backend.getPlayedPercents()); | ||
} | ||
} | ||
}, { | ||
key: "log", | ||
value: function log(args, logType) { | ||
(0, _log2.default)(args, logType, this.debug); | ||
} | ||
}, { | ||
key: "setFormatTime", | ||
value: function setFormatTime(customImplementation) { | ||
this._formatTime = customImplementation; | ||
_video.default.setFormatTime(this._formatTime); | ||
} | ||
}]); | ||
return Wavesurfer; | ||
}(Plugin); | ||
exports.Wavesurfer = Wavesurfer; | ||
Wavesurfer.VERSION = "3.5.0"; | ||
_video.default.Wavesurfer = Wavesurfer; | ||
if (_video.default.getPlugin(wavesurferPluginName) === undefined) { | ||
_video.default.registerPlugin(wavesurferPluginName, Wavesurfer); | ||
} | ||
_video.default.use('*', function (player) { | ||
_middleware.default.player = player; | ||
return _middleware.default; | ||
}); | ||
/***/ }), | ||
/***/ 0: | ||
/*!******************************************************************************!*\ | ||
!*** multi ./src/js/videojs.wavesurfer.js ./src/css/videojs.wavesurfer.scss ***! | ||
\******************************************************************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/***/ "./node_modules/global/window.js": | ||
/*!***************************************!*\ | ||
!*** ./node_modules/global/window.js ***! | ||
\***************************************/ | ||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => { | ||
eval("__webpack_require__(/*! /home/thijs/projects/videojs-wavesurfer/src/js/videojs.wavesurfer.js */\"./src/js/videojs.wavesurfer.js\");\nmodule.exports = __webpack_require__(/*! /home/thijs/projects/videojs-wavesurfer/src/css/videojs.wavesurfer.scss */\"./src/css/videojs.wavesurfer.scss\");\n\n\n//# sourceURL=webpack://VideojsWavesurfer/multi_./src/js/videojs.wavesurfer.js_./src/css/videojs.wavesurfer.scss?"); | ||
var win; | ||
if (typeof window !== "undefined") { | ||
win = window; | ||
} else if (typeof __webpack_require__.g !== "undefined") { | ||
win = __webpack_require__.g; | ||
} else if (typeof self !== "undefined"){ | ||
win = self; | ||
} else { | ||
win = {}; | ||
} | ||
module.exports = win; | ||
/***/ }), | ||
/***/ "./node_modules/parse-ms/index.js": | ||
/*!****************************************!*\ | ||
!*** ./node_modules/parse-ms/index.js ***! | ||
\****************************************/ | ||
/***/ ((module) => { | ||
"use strict"; | ||
module.exports = milliseconds => { | ||
if (typeof milliseconds !== 'number') { | ||
throw new TypeError('Expected a number'); | ||
} | ||
const roundTowardsZero = milliseconds > 0 ? Math.floor : Math.ceil; | ||
return { | ||
days: roundTowardsZero(milliseconds / 86400000), | ||
hours: roundTowardsZero(milliseconds / 3600000) % 24, | ||
minutes: roundTowardsZero(milliseconds / 60000) % 60, | ||
seconds: roundTowardsZero(milliseconds / 1000) % 60, | ||
milliseconds: roundTowardsZero(milliseconds) % 1000, | ||
microseconds: roundTowardsZero(milliseconds * 1000) % 1000, | ||
nanoseconds: roundTowardsZero(milliseconds * 1e6) % 1000 | ||
}; | ||
}; | ||
/***/ }), | ||
/***/ "video.js": | ||
@@ -258,6 +982,6 @@ /*!*************************************************************************************************!*\ | ||
\*************************************************************************************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports) { | ||
/***/ ((module) => { | ||
eval("module.exports = __WEBPACK_EXTERNAL_MODULE_video_js__;\n\n//# sourceURL=webpack://VideojsWavesurfer/external_%7B%22commonjs%22:%22video.js%22,%22commonjs2%22:%22video.js%22,%22amd%22:%22video.js%22,%22root%22:%22videojs%22%7D?"); | ||
"use strict"; | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_video_js__; | ||
@@ -270,10 +994,54 @@ /***/ }), | ||
\*******************************************************************************************************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports) { | ||
/***/ ((module) => { | ||
eval("module.exports = __WEBPACK_EXTERNAL_MODULE_wavesurfer_js__;\n\n//# sourceURL=webpack://VideojsWavesurfer/external_%7B%22commonjs%22:%22wavesurfer.js%22,%22commonjs2%22:%22wavesurfer.js%22,%22amd%22:%22wavesurfer.js%22,%22root%22:%22WaveSurfer%22%7D?"); | ||
"use strict"; | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_wavesurfer_js__; | ||
/***/ }) | ||
/******/ }); | ||
/******/ }); | ||
/************************************************************************/ | ||
/******/ // The module cache | ||
/******/ var __webpack_module_cache__ = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ // Check if module is in cache | ||
/******/ if(__webpack_module_cache__[moduleId]) { | ||
/******/ return __webpack_module_cache__[moduleId].exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = __webpack_module_cache__[moduleId] = { | ||
/******/ // no module.id needed | ||
/******/ // no module.loaded needed | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/************************************************************************/ | ||
/******/ /* webpack/runtime/global */ | ||
/******/ (() => { | ||
/******/ __webpack_require__.g = (function() { | ||
/******/ if (typeof globalThis === 'object') return globalThis; | ||
/******/ try { | ||
/******/ return this || new Function('return this')(); | ||
/******/ } catch (e) { | ||
/******/ if (typeof window === 'object') return window; | ||
/******/ } | ||
/******/ })(); | ||
/******/ })(); | ||
/******/ | ||
/************************************************************************/ | ||
/******/ // module exports must be returned from runtime so entry inlining is disabled | ||
/******/ // startup | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__("./src/js/videojs.wavesurfer.js"); | ||
/******/ })() | ||
; | ||
}); |
/*! | ||
* videojs-wavesurfer | ||
* @version 3.4.0 | ||
* @version 3.5.0 | ||
* @see https://github.com/collab-project/videojs-wavesurfer | ||
@@ -8,2 +8,2 @@ * @copyright 2014-2021 Collab | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("video.js"),require("wavesurfer.js")):"function"==typeof define&&define.amd?define("VideojsWavesurfer",["video.js","wavesurfer.js"],t):"object"==typeof exports?exports.VideojsWavesurfer=t(require("video.js"),require("wavesurfer.js")):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(13)},function(e,t,r){"use strict";function i(e){return(i="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)}Object.defineProperty(t,"__esModule",{value:!0}),t.Wavesurfer=void 0;var o=d(r(3)),a=d(r(4)),n=d(r(5)),s=d(r(8)),l=d(r(9)),u=d(r(10)),c=d(r(0)),h=d(r(12));function d(e){return e&&e.__esModule?e:{default:e}}function f(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 p(e,t){return(p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,i=b(e);if(t){var o=b(this).constructor;r=Reflect.construct(i,arguments,o)}else r=i.apply(this,arguments);return v(this,r)}}function v(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?g(e):t}function g(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e){return(b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var m=c.default.getPlugin("plugin"),E="wavesurfer",w="vjs-wavedisplay",k="WebAudio",R="MediaElement",_=function(e){!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&&p(e,t)}(d,e);var t,r,i,l=y(d);function d(e,t){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,d),r=l.call(this,e,t),e.addClass("vjs-wavesurfer"),t=c.default.mergeOptions(s.default,t),r.waveReady=!1,r.waveFinished=!1,r.liveMode=!1,r.backend=null,r.debug="true"===t.debug.toString(),r.textTracksEnabled=r.player.options_.tracks.length>0,r.displayMilliseconds=t.displayMilliseconds,c.default.setFormatTime((function(e,t){return(0,n.default)(e,t,r.displayMilliseconds)})),r.player.one(o.default.READY,r.initialize.bind(g(r))),r}return t=d,(r=[{key:"initialize",value:function(){var e=this;void 0!==this.player.bigPlayButton&&this.player.bigPlayButton.hide();var t=this.parseOptions(this.player.options_.plugins.wavesurfer);!0===this.player.options_.controls&&(this.player.controlBar.show(),this.player.controlBar.el_.style.display="flex",this.backend===k&&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(),this.backend===k&&void 0!==this.player.controlBar.playToggle&&(this.player.controlBar.playToggle.on(["tap","click"],this.onPlayToggle.bind(this)),this.player.controlBar.playToggle.hide())),this.surfer=h.default.create(t),this.surfer.on(o.default.ERROR,this.onWaveError.bind(this)),this.surfer.on(o.default.FINISH,this.onWaveFinish.bind(this)),this.backend=this.surfer.params.backend,this.log("Using wavesurfer.js "+this.backend+" backend."),"microphone"in this.player.wavesurfer().surfer.getActivePlugins()&&(this.liveMode=!0,this.waveReady=!0,this.log("wavesurfer.js microphone plugin enabled."),this.player.controlBar.playToggle.show(),this.surfer.microphone.on(o.default.DEVICE_ERROR,this.onWaveError.bind(this))),this.surferReady=this.onWaveReady.bind(this),this.backend===k&&(this.surferProgress=this.onWaveProgress.bind(this),this.surferSeek=this.onWaveSeek.bind(this),this.player.muted()&&this.setVolume(0)),this.liveMode||this.setupPlaybackEvents(!0),this.player.on(o.default.VOLUMECHANGE,this.onVolumeChange.bind(this)),this.player.on(o.default.FULLSCREENCHANGE,this.onScreenChange.bind(this)),!0===this.player.options_.fluid&&(this.surfer.drawer.wrapper.className=w,this.responsiveWave=h.default.util.debounce(this.onResizeChange.bind(this),150),u.default.addEventListener(o.default.RESIZE,this.responsiveWave))}},{key:"parseOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},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),"backend"in e?this.backend=e.backend:e.backend=this.backend=R,e}},{key:"setupPlaybackEvents",value:function(e){!1===e?(this.surfer.un(o.default.READY,this.surferReady),this.backend===k&&(this.surfer.un(o.default.AUDIOPROCESS,this.surferProgress),this.surfer.un(o.default.SEEK,this.surferSeek))):!0===e&&(this.surfer.on(o.default.READY,this.surferReady),this.backend===k&&(this.surfer.on(o.default.AUDIOPROCESS,this.surferProgress),this.surfer.on(o.default.SEEK,this.surferSeek)))}},{key:"load",value:function(e,t){e instanceof Blob||e instanceof File?(this.log("Loading object: "+JSON.stringify(e)),this.surfer.loadBlob(e)):void 0!==t?this.loadPeaks(e,t):("string"==typeof e?this.log("Loading URL: "+e):this.log("Loading element: "+e),this.surfer.load(e))}},{key:"loadPeaks",value:function(e,t){var r=this;if(Array.isArray(t))this.log("Loading URL with array of peaks: "+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 a=h.default.util.fetchFile(i);a.once("success",(function(i){r.log("Loaded Peak Data URL: "+t),i&&i.data?r.surfer.load(e,i.data):(r.player.trigger(o.default.ERROR,"Could not load peaks data from "+t),r.log(err,"error"))})),a.once("error",(function(e){r.player.trigger(o.default.ERROR,"Unable to retrieve peak data from "+t+". Status code: "+a.response.status)}))}}},{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.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){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"blob";return this.surfer.exportImage(e,t,r)}},{key:"setAudioOutput",value:function(e){var t=this;e&&this.surfer.setSinkId(e).then((function(e){t.player.trigger(o.default.AUDIO_OUTPUT_READY)})).catch((function(e){t.player.trigger(o.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()&&this.player.controlBar.currentTimeDisplay.contentEl().lastChild){var r=Math.min(e,t);this.player.controlBar.currentTimeDisplay.formattedTime_=this.player.controlBar.currentTimeDisplay.contentEl().lastChild.textContent=(0,n.default)(r,t,this.displayMilliseconds)}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.contentEl().lastChild&&(this.player.controlBar.durationDisplay.formattedTime_=this.player.controlBar.durationDisplay.contentEl().lastChild.textContent=(0,n.default)(e,e,this.displayMilliseconds))}},{key:"onWaveReady",value:function(){var e=this;this.waveReady=!0,this.waveFinished=!1,this.liveMode=!1,this.log("Waveform is ready"),this.player.trigger(o.default.WAVE_READY),this.backend===k&&(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.setVolume(0),this.backend===k?this.play():this.player.play().catch((function(t){e.onWaveError(t)})))}},{key:"onWaveFinish",value:function(){var e=this;this.log("Finished playback"),this.player.trigger(o.default.PLAYBACK_FINISH),!0===this.player.options_.loop?this.backend===k&&(this.surfer.stop(),this.play()):(this.waveFinished=!0,this.backend===k&&(this.pause(),this.player.trigger(o.default.ENDED),this.surfer.once(o.default.SEEK,(function(){void 0!==e.player.controlBar.playToggle&&e.player.controlBar.playToggle.removeClass("vjs-ended"),e.player.trigger(o.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(o.default.ABORT,e):(this.player.trigger(o.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=w,this.surfer.drawBuffer(),this.surfer.drawer.progress(this.surfer.backend.getPlayedPercents())}}},{key:"log",value:function(e,t){(0,a.default)(e,t,this.debug)}}])&&f(t.prototype,r),i&&f(t,i),d}(m);t.Wavesurfer=_,_.VERSION="3.4.0",c.default.Wavesurfer=_,void 0===c.default.getPlugin(E)&&c.default.registerPlugin(E,_),c.default.use("*",(function(e){return l.default.player=e,l.default}))},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=a(r(6)),o=a(r(7));function a(e){return e&&e.__esModule?e:{default:e}}var n=function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];e=e<0?0:e,(isNaN(e)||e===1/0)&&(e=0);var a=(0,o.default)(1e3*e),n=a;void 0!==t&&(n=(0,o.default)(1e3*t));var s=(0,i.default)(a.hours),l=(0,i.default)(a.minutes),u=(0,i.default)(a.seconds),c=(0,i.default)(a.milliseconds,3);if(a.days>0||n.days>0){var h=(0,i.default)(a.days);return"".concat(h,":").concat(s,":").concat(l,":").concat(u)}return a.hours>0||n.hours>0?"".concat(s,":").concat(l,":").concat(u):r?"".concat(l,":").concat(u,":").concat(c):"".concat(l,":").concat(u)};t.default=n,e.exports=t.default},function(e,t,r){var i;!function(t){"use strict";function o(e,t){t=t||2;var r,i=Number(e)<0,o=e.toString();return i&&(o=o.slice(1)),r=t-o.length+1,(i?"-":"")+(o=new Array(r).join("0").concat(o))}void 0===(i=function(){return o}.call(t,r,t,e))||(e.exports=i)}(this)},function(e,t,r){"use strict";e.exports=e=>{if("number"!=typeof e)throw new TypeError("Expected a number");const t=e>0?Math.floor:Math.ceil;return{days:t(e/864e5),hours:t(e/36e5)%24,minutes:t(e/6e4)%60,seconds:t(e/1e3)%60,milliseconds:t(e)%1e3,microseconds:t(1e3*e)%1e3,nanoseconds:t(1e6*e)%1e3}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i={debug:!1,displayMilliseconds:!0};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={setSource:function(e,t){if(this.player.usingPlugin("wavesurfer")){var r=this.player.wavesurfer().surfer.params.backend,i=e.src,o=e.peaks;switch(r){case"WebAudio":this.player.wavesurfer().load(i);break;default:t(null,e);var a=this.player.tech_.el();void 0===o?this.player.wavesurfer().load(a):this.player.wavesurfer().load(a,o)}}else t(null,e)}};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(11))},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){"use strict";r.r(t)}])})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("video.js"),require("wavesurfer.js")):"function"==typeof define&&define.amd?define("VideojsWavesurfer",["video.js","wavesurfer.js"],t):"object"==typeof exports?exports.VideojsWavesurfer=t(require("video.js"),require("wavesurfer.js")):e.VideojsWavesurfer=t(e.videojs,e.WaveSurfer)}(self,(function(e,t){return(()=>{var r={21:function(e,t,r){var i;!function(t){"use strict";function a(e,t){t=t||2;var r,i=Number(e)<0,a=e.toString();return i&&(a=a.slice(1)),r=t-a.length+1,(i?"-":"")+(a=new Array(r).join("0").concat(a))}void 0===(i=function(){return a}.call(t,r,t,e))||(e.exports=i)}(this)},997:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r={debug:!1,displayMilliseconds:!0};t.default=r,e.exports=t.default},537:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)};r.READY="ready",r.ERROR="error",r.VOLUMECHANGE="volumechange",r.FULLSCREENCHANGE="fullscreenchange",r.TIMEUPDATE="timeupdate",r.ENDED="ended",r.PAUSE="pause",r.FINISH="finish",r.SEEK="seek",r.REDRAW="redraw",r.AUDIOPROCESS="audioprocess",r.DEVICE_READY="deviceReady",r.DEVICE_ERROR="deviceError",r.AUDIO_OUTPUT_READY="audioOutputReady",r.WAVE_READY="waveReady",r.PLAYBACK_FINISH="playbackFinish",r.ABORT="abort",r.RESIZE="resize",Object.freeze(r);var i=r;t.default=i,e.exports=t.default},200:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r={setSource:function(e,t){if(this.player.usingPlugin("wavesurfer")){var r=this.player.wavesurfer().surfer.params.backend,i=e.src,a=e.peaks;switch(r){case"WebAudio":this.player.wavesurfer().load(i);break;default:t(null,e);var o=this.player.tech_.el();void 0===a?this.player.wavesurfer().load(o):this.player.wavesurfer().load(o,a)}}else t(null,e)}};t.default=r,e.exports=t.default},518:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=o(r(21)),a=o(r(455));function o(e){return e&&e.__esModule?e:{default:e}}var s=function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];e=e<0?0:e,(isNaN(e)||e===1/0)&&(e=0);var o=(0,a.default)(1e3*e),s=o;void 0!==t&&(s=(0,a.default)(1e3*t));var n=(0,i.default)(o.hours),l=(0,i.default)(o.minutes),u=(0,i.default)(o.seconds),h=(0,i.default)(o.milliseconds,3);if(o.days>0||s.days>0){var c=(0,i.default)(o.days);return"".concat(c,":").concat(n,":").concat(l,":").concat(u)}return o.hours>0||s.hours>0?"".concat(n,":").concat(l,":").concat(u):r?"".concat(l,":").concat(u,":").concat(h):"".concat(l,":").concat(u)};t.default=s,e.exports=t.default},456:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i,a=(i=r(390))&&i.__esModule?i:{default:i};var o=function(e,t,r){!0===r&&("error"===t?a.default.log.error(e):"warn"===t?a.default.log.warn(e):a.default.log(e))};t.default=o,e.exports=t.default},734:(e,t,r)=>{"use strict";function i(e){return(i="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)}Object.defineProperty(t,"__esModule",{value:!0}),t.Wavesurfer=void 0;var a=d(r(537)),o=d(r(456)),s=d(r(518)),n=d(r(997)),l=d(r(200)),u=d(r(908)),h=d(r(390)),c=d(r(410));function d(e){return e&&e.__esModule?e:{default:e}}function f(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 p(e,t){return(p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,i=m(e);if(t){var a=m(this).constructor;r=Reflect.construct(i,arguments,a)}else r=i.apply(this,arguments);return v(this,r)}}function v(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?g(e):t}function g(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var b=h.default.getPlugin("plugin"),E="wavesurfer",k="vjs-wavedisplay",w="WebAudio",R="MediaElement",T=function(e){!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&&p(e,t)}(d,e);var t,r,i,l=y(d);function d(e,t){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,d),r=l.call(this,e,t),e.addClass("vjs-wavesurfer"),t=h.default.mergeOptions(n.default,t),r.waveReady=!1,r.waveFinished=!1,r.liveMode=!1,r.backend=null,r.debug="true"===t.debug.toString(),r.textTracksEnabled=r.player.options_.tracks.length>0,r.displayMilliseconds=t.displayMilliseconds,t.formatTime&&"function"==typeof t.formatTime?r.setFormatTime(t.formatTime):r.setFormatTime((function(e,t){return(0,s.default)(e,t,r.displayMilliseconds)})),r.player.one(a.default.READY,r.initialize.bind(g(r))),r}return t=d,(r=[{key:"initialize",value:function(){var e=this;void 0!==this.player.bigPlayButton&&this.player.bigPlayButton.hide();var t=this.parseOptions(this.player.options_.plugins.wavesurfer);!0===this.player.options_.controls&&(this.player.controlBar.show(),this.player.controlBar.el_.style.display="flex",this.backend===w&&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(),this.backend===w&&void 0!==this.player.controlBar.playToggle&&(this.player.controlBar.playToggle.on(["tap","click"],this.onPlayToggle.bind(this)),this.player.controlBar.playToggle.hide())),this.surfer=c.default.create(t),this.surfer.on(a.default.ERROR,this.onWaveError.bind(this)),this.surfer.on(a.default.FINISH,this.onWaveFinish.bind(this)),this.backend=this.surfer.params.backend,this.log("Using wavesurfer.js "+this.backend+" backend."),"microphone"in this.player.wavesurfer().surfer.getActivePlugins()&&(this.liveMode=!0,this.waveReady=!0,this.log("wavesurfer.js microphone plugin enabled."),this.player.controlBar.playToggle.show(),this.surfer.microphone.on(a.default.DEVICE_ERROR,this.onWaveError.bind(this))),this.surferReady=this.onWaveReady.bind(this),this.backend===w&&(this.surferProgress=this.onWaveProgress.bind(this),this.surferSeek=this.onWaveSeek.bind(this),this.player.muted()&&this.setVolume(0)),this.liveMode||this.setupPlaybackEvents(!0),this.player.on(a.default.VOLUMECHANGE,this.onVolumeChange.bind(this)),this.player.on(a.default.FULLSCREENCHANGE,this.onScreenChange.bind(this)),!0===this.player.options_.fluid&&(this.surfer.drawer.wrapper.className=k,this.responsiveWave=c.default.util.debounce(this.onResizeChange.bind(this),150),u.default.addEventListener(a.default.RESIZE,this.responsiveWave))}},{key:"parseOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},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),"backend"in e?this.backend=e.backend:e.backend=this.backend=R,e}},{key:"setupPlaybackEvents",value:function(e){!1===e?(this.surfer.un(a.default.READY,this.surferReady),this.backend===w&&(this.surfer.un(a.default.AUDIOPROCESS,this.surferProgress),this.surfer.un(a.default.SEEK,this.surferSeek))):!0===e&&(this.surfer.on(a.default.READY,this.surferReady),this.backend===w&&(this.surfer.on(a.default.AUDIOPROCESS,this.surferProgress),this.surfer.on(a.default.SEEK,this.surferSeek)))}},{key:"load",value:function(e,t){e instanceof Blob||e instanceof File?(this.log("Loading object: "+JSON.stringify(e)),this.surfer.loadBlob(e)):void 0!==t?this.loadPeaks(e,t):("string"==typeof e?this.log("Loading URL: "+e):this.log("Loading element: "+e),this.surfer.load(e))}},{key:"loadPeaks",value:function(e,t){var r=this;if(Array.isArray(t))this.log("Loading URL with array of peaks: "+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=c.default.util.fetchFile(i);o.once("success",(function(i){r.log("Loaded Peak Data URL: "+t),i&&i.data?r.surfer.load(e,i.data):(r.player.trigger(a.default.ERROR,"Could not load peaks data from "+t),r.log(err,"error"))})),o.once("error",(function(e){r.player.trigger(a.default.ERROR,"Unable to retrieve peak data from "+t+". Status code: "+o.response.status)}))}}},{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.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){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"blob";return this.surfer.exportImage(e,t,r)}},{key:"setAudioOutput",value:function(e){var t=this;e&&this.surfer.setSinkId(e).then((function(e){t.player.trigger(a.default.AUDIO_OUTPUT_READY)})).catch((function(e){t.player.trigger(a.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()&&this.player.controlBar.currentTimeDisplay.contentEl().lastChild){var r=Math.min(e,t);this.player.controlBar.currentTimeDisplay.formattedTime_=this.player.controlBar.currentTimeDisplay.contentEl().lastChild.textContent=this._formatTime(r,t,this.displayMilliseconds)}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.contentEl().lastChild&&(this.player.controlBar.durationDisplay.formattedTime_=this.player.controlBar.durationDisplay.contentEl().lastChild.textContent=this._formatTime(e,e,this.displayMilliseconds))}},{key:"onWaveReady",value:function(){var e=this;this.waveReady=!0,this.waveFinished=!1,this.liveMode=!1,this.log("Waveform is ready"),this.player.trigger(a.default.WAVE_READY),this.backend===w&&(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.setVolume(0),this.backend===w?this.play():this.player.play().catch((function(t){e.onWaveError(t)})))}},{key:"onWaveFinish",value:function(){var e=this;this.log("Finished playback"),this.player.trigger(a.default.PLAYBACK_FINISH),!0===this.player.options_.loop?this.backend===w&&(this.surfer.stop(),this.play()):(this.waveFinished=!0,this.backend===w&&(this.pause(),this.player.trigger(a.default.ENDED),this.surfer.once(a.default.SEEK,(function(){void 0!==e.player.controlBar.playToggle&&e.player.controlBar.playToggle.removeClass("vjs-ended"),e.player.trigger(a.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(a.default.ABORT,e):(this.player.trigger(a.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=k,this.surfer.drawBuffer(),this.surfer.drawer.progress(this.surfer.backend.getPlayedPercents())}}},{key:"log",value:function(e,t){(0,o.default)(e,t,this.debug)}},{key:"setFormatTime",value:function(e){this._formatTime=e,h.default.setFormatTime(this._formatTime)}}])&&f(t.prototype,r),i&&f(t,i),d}(b);t.Wavesurfer=T,T.VERSION="3.5.0",h.default.Wavesurfer=T,void 0===h.default.getPlugin(E)&&h.default.registerPlugin(E,T),h.default.use("*",(function(e){return l.default.player=e,l.default}))},908:(e,t,r)=>{var i;i="undefined"!=typeof window?window:void 0!==r.g?r.g:"undefined"!=typeof self?self:{},e.exports=i},455:e=>{"use strict";e.exports=e=>{if("number"!=typeof e)throw new TypeError("Expected a number");const t=e>0?Math.floor:Math.ceil;return{days:t(e/864e5),hours:t(e/36e5)%24,minutes:t(e/6e4)%60,seconds:t(e/1e3)%60,milliseconds:t(e)%1e3,microseconds:t(1e3*e)%1e3,nanoseconds:t(1e6*e)%1e3}}},390:t=>{"use strict";t.exports=e},410:e=>{"use strict";e.exports=t}},i={};function a(e){if(i[e])return i[e].exports;var t=i[e]={exports:{}};return r[e].call(t.exports,t,t.exports,a),t.exports}return a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a(734)})()})); |
{ | ||
"name": "videojs-wavesurfer", | ||
"version": "3.4.0", | ||
"version": "3.5.0", | ||
"description": "video.js plugin that adds a navigable waveform for audio and video files.", | ||
@@ -35,3 +35,4 @@ "author": "Collab", | ||
"lint:html": "htmlhint examples docs/demo", | ||
"start": "npm run build && webpack-dev-server --config ./build-config/webpack.dev.main.js", | ||
"start": "npm run build && webpack serve --config ./build-config/webpack.dev.main.js", | ||
"start-doc": "docsify serve docs", | ||
"test": "karma start karma.conf.js", | ||
@@ -67,4 +68,5 @@ "prepublishOnly": "not-in-install && npm run build || in-install" | ||
"babel-plugin-istanbul": "^6.0.0", | ||
"browserslist": "^4.16.1", | ||
"browserslist": "^4.16.3", | ||
"css-loader": "^5.0.1", | ||
"css-minimizer-webpack-plugin": "^1.2.0", | ||
"date-fns": "^2.16.1", | ||
@@ -74,3 +76,3 @@ "docsify-cli": "^4.4.2", | ||
"esdoc-standard-plugin": "^1.0.0", | ||
"eslint": "^7.18.0", | ||
"eslint": "^7.19.0", | ||
"htmlhint": "^0.14.2", | ||
@@ -83,15 +85,11 @@ "in-publish": "^2.0.1", | ||
"karma-detect-browsers": "^2.3.3", | ||
"karma-edge-launcher": "^0.4.2", | ||
"karma-firefox-launcher": "^2.1.0", | ||
"karma-jasmine": "^4.0.1", | ||
"karma-jasmine-matchers": "^4.0.2", | ||
"karma-safari-launcher": "^1.0.0", | ||
"karma-safaritechpreview-launcher": "^2.0.2", | ||
"karma-verbose-reporter": "0.0.6", | ||
"karma-webpack": "^4.0.2", | ||
"mini-css-extract-plugin": "^1.3.4", | ||
"karma-webpack": "^5.0.0-alpha.6", | ||
"mini-css-extract-plugin": "^1.3.5", | ||
"npm-run-all": "^4.1.5", | ||
"optimize-css-assets-webpack-plugin": "^5.0.4", | ||
"parse-ms": "^2.1.0", | ||
"replace-in-file": "^6.1.0", | ||
"replace-in-file": "^6.2.0", | ||
"rimraf": "^3.0.2", | ||
@@ -101,9 +99,9 @@ "sass": "^1.32.5", | ||
"style-loader": "^2.0.0", | ||
"terser-webpack-plugin": "^4.2.3", | ||
"webpack": "^4.44.2", | ||
"webpack-cli": "^3.3.12", | ||
"webpack-dev-server": "^3.11.2", | ||
"webpack": "^5.19.0", | ||
"webpack-cli": "^4.4.0", | ||
"webpack-dev-server": "^4.0.0-beta.0", | ||
"webpack-merge": "^5.7.3", | ||
"webpack-remove-empty-scripts": "^0.7.1", | ||
"webrtc-adapter": "^7.7.0" | ||
} | ||
} |
@@ -58,6 +58,12 @@ /** | ||
// use custom video.js time format | ||
videojs.setFormatTime((seconds, guide) => { | ||
return formatTime(seconds, guide, this.displayMilliseconds); | ||
}); | ||
// use custom time format for video.js player | ||
if (options.formatTime && typeof options.formatTime === 'function') { | ||
// user-supplied formatTime | ||
this.setFormatTime(options.formatTime); | ||
} else { | ||
// plugin's default formatTime | ||
this.setFormatTime((seconds, guide) => { | ||
return formatTime(seconds, guide, this.displayMilliseconds); | ||
}); | ||
} | ||
@@ -532,3 +538,3 @@ // wait until player ui is ready | ||
this.player.controlBar.currentTimeDisplay.contentEl().lastChild.textContent = | ||
formatTime(time, duration, this.displayMilliseconds); | ||
this._formatTime(time, duration, this.displayMilliseconds); | ||
} | ||
@@ -574,3 +580,3 @@ | ||
this.player.controlBar.durationDisplay.contentEl().lastChild.textContent = | ||
formatTime(duration, duration, this.displayMilliseconds); | ||
this._formatTime(duration, duration, this.displayMilliseconds); | ||
} | ||
@@ -831,2 +837,15 @@ } | ||
} | ||
/** | ||
* Replaces the default `formatTime` implementation with a custom implementation. | ||
* | ||
* @param {function} customImplementation - A function which will be used in place | ||
* of the default `formatTime` implementation. Will receive the current time | ||
* in seconds and the guide (in seconds) as arguments. | ||
*/ | ||
setFormatTime(customImplementation) { | ||
this._formatTime = customImplementation; | ||
videojs.setFormatTime(this._formatTime); | ||
} | ||
} | ||
@@ -833,0 +852,0 @@ |
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
43
1818
0
2
102226