wavesurfer.js 5.1.0 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGES.md +11 -0
  2. package/dist/plugin/wavesurfer.cursor.js +2 -2
  3. package/dist/plugin/wavesurfer.cursor.js.map +1 -1
  4. package/dist/plugin/wavesurfer.cursor.min.js +2 -2
  5. package/dist/plugin/wavesurfer.cursor.min.js.map +1 -1
  6. package/dist/plugin/wavesurfer.elan.js +2 -2
  7. package/dist/plugin/wavesurfer.elan.js.map +1 -1
  8. package/dist/plugin/wavesurfer.elan.min.js +2 -2
  9. package/dist/plugin/wavesurfer.elan.min.js.map +1 -1
  10. package/dist/plugin/wavesurfer.markers.js +2 -2
  11. package/dist/plugin/wavesurfer.markers.js.map +1 -1
  12. package/dist/plugin/wavesurfer.markers.min.js +2 -2
  13. package/dist/plugin/wavesurfer.markers.min.js.map +1 -1
  14. package/dist/plugin/wavesurfer.mediasession.js +2 -2
  15. package/dist/plugin/wavesurfer.mediasession.js.map +1 -1
  16. package/dist/plugin/wavesurfer.mediasession.min.js +2 -2
  17. package/dist/plugin/wavesurfer.mediasession.min.js.map +1 -1
  18. package/dist/plugin/wavesurfer.microphone.js +2 -2
  19. package/dist/plugin/wavesurfer.microphone.js.map +1 -1
  20. package/dist/plugin/wavesurfer.microphone.min.js +2 -2
  21. package/dist/plugin/wavesurfer.microphone.min.js.map +1 -1
  22. package/dist/plugin/wavesurfer.minimap.js +2 -2
  23. package/dist/plugin/wavesurfer.minimap.js.map +1 -1
  24. package/dist/plugin/wavesurfer.minimap.min.js +2 -2
  25. package/dist/plugin/wavesurfer.minimap.min.js.map +1 -1
  26. package/dist/plugin/wavesurfer.playhead.js +2 -2
  27. package/dist/plugin/wavesurfer.playhead.js.map +1 -1
  28. package/dist/plugin/wavesurfer.playhead.min.js +2 -2
  29. package/dist/plugin/wavesurfer.playhead.min.js.map +1 -1
  30. package/dist/plugin/wavesurfer.regions.js +37 -7
  31. package/dist/plugin/wavesurfer.regions.js.map +1 -1
  32. package/dist/plugin/wavesurfer.regions.min.js +2 -2
  33. package/dist/plugin/wavesurfer.regions.min.js.map +1 -1
  34. package/dist/plugin/wavesurfer.spectrogram.js +2 -2
  35. package/dist/plugin/wavesurfer.spectrogram.js.map +1 -1
  36. package/dist/plugin/wavesurfer.spectrogram.min.js +2 -2
  37. package/dist/plugin/wavesurfer.spectrogram.min.js.map +1 -1
  38. package/dist/plugin/wavesurfer.timeline.js +14 -11
  39. package/dist/plugin/wavesurfer.timeline.js.map +1 -1
  40. package/dist/plugin/wavesurfer.timeline.min.js +2 -2
  41. package/dist/plugin/wavesurfer.timeline.min.js.map +1 -1
  42. package/dist/wavesurfer-html-init.js +2 -2
  43. package/dist/wavesurfer-html-init.js.map +1 -1
  44. package/dist/wavesurfer-html-init.min.js +2 -2
  45. package/dist/wavesurfer-html-init.min.js.map +1 -1
  46. package/dist/wavesurfer.js +99 -21
  47. package/dist/wavesurfer.js.map +1 -1
  48. package/dist/wavesurfer.min.js +2 -2
  49. package/dist/wavesurfer.min.js.map +1 -1
  50. package/package.json +11 -11
  51. package/src/plugin/regions/region.js +33 -5
  52. package/src/plugin/timeline/index.js +11 -9
  53. package/src/util/index.js +1 -0
  54. package/src/util/silence-mode.js +35 -0
  55. package/src/wavesurfer.js +23 -13
  56. package/src/webaudio.js +10 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/markers/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"names":["DEFAULT_FILL_COLOR","DEFAULT_POSITION","MarkersPlugin","params","ws","wavesurfer","util","style","markerWidth","markerHeight","_onResize","_updateMarkerPositions","_onBackendCreated","wrapper","drawer","markers","forEach","marker","add","window","addEventListener","on","_onReady","isReady","once","un","removeEventListener","clear","time","label","color","position","markerElement","width","height","el","_createMarkerElement","appendChild","push","index","removeChild","splice","svgNS","document","createElementNS","polygon","setAttribute","createElement","className","display","overflow","line","background","opacity","labelDiv","point","_createPointerSVG","labelEl","innerText","cursor","e","stopPropagation","setCurrentTime","fireEvent","duration","getDuration","i","length","elementWidth","pixelRatio","positionPct","Math","min","leftPx","remove","name","deferInit","staticProps","addMarker","options","initialisedPluginList","initPlugin","clearMarkers","instance"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD,O;;;;;;;;;;;;;;;;;;;;;;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,IAAMA,kBAAkB,GAAG,SAA3B;AACA,IAAMC,gBAAgB,GAAG,QAAzB;;IAEqBC,a;AAqCjB,yBAAYC,MAAZ,EAAoBC,EAApB,EAAwB;AAAA;;AAAA;;AACpB,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,UAAL,GAAkBD,EAAlB;AACA,SAAKE,IAAL,GAAYF,EAAE,CAACE,IAAf;AACA,SAAKC,KAAL,GAAa,KAAKD,IAAL,CAAUC,KAAvB;AACA,SAAKC,WAAL,GAAmB,EAAnB;AACA,SAAKC,YAAL,GAAoB,EAApB;;AAGA,SAAKC,SAAL,GAAiB,YAAM;AACnB,WAAI,CAACC,sBAAL;AACH,KAFD;;AAIA,SAAKC,iBAAL,GAAyB,YAAM;AAC3B,WAAI,CAACC,OAAL,GAAe,KAAI,CAACR,UAAL,CAAgBS,MAAhB,CAAuBD,OAAtC;;AACA,UAAI,KAAI,CAACV,MAAL,CAAYY,OAAhB,EAAyB;AACrB,aAAI,CAACZ,MAAL,CAAYY,OAAZ,CAAoBC,OAApB,CAA4B,UAAAC,MAAM;AAAA,iBAAI,KAAI,CAACC,GAAL,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6D,OAAjB,CAAP;AACH,WANQ;AAOTG,sBAPS,0BAOM;AACX,iBAAKnE,OAAL,IAAgB,KAAKA,OAAL,CAAaY,KAAb,EAAhB;AACH;AATQ,SAJV;AAeHwD,gBAAQ,EAAEjF;AAfP,OAAP;AAiBH;;;;;;;;;;;;;UCzEL;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UCtBA;UACA;UACA;UACA","file":"wavesurfer.markers.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"markers\"] = factory();\n})(this, function() {\nreturn ","\n/**\n * @typedef {Object} MarkerParams\n * @desc The parameters used to describe a marker.\n * @example wavesurfer.addMarker(regionParams);\n * @property {number} time The time to set the marker at\n * @property {?label} string An optional marker label\n * @property {?color} string Background color for marker\n * @property {?position} string \"top\" or \"bottom\", defaults to \"bottom\"\n * @property {?markerElement} element An HTML element to display instead of the default marker image\n */\n\n\n/**\n * Markers are points in time in the audio that can be jumped to.\n *\n * @implements {PluginClass}\n *\n * @example\n * import MarkersPlugin from 'wavesurfer.markers.js';\n *\n * // if you are using <script> tags\n * var MarkerPlugin = window.WaveSurfer.markers;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MarkersPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\n\nconst DEFAULT_FILL_COLOR = \"#D8D8D8\";\nconst DEFAULT_POSITION = \"bottom\";\n\nexport default class MarkersPlugin {\n /**\n * @typedef {Object} MarkersPluginParams\n * @property {?MarkerParams[]} markers Initial set of markers\n * @fires MarkersPlugin#marker-click\n */\n\n /**\n * Markers plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MarkersPluginParams} params parameters use to initialise the plugin\n * @since 4.6.0\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'markers',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {\n addMarker(options) {\n if (!this.initialisedPluginList.markers) {\n this.initPlugin('markers');\n }\n return this.markers.add(options);\n },\n clearMarkers() {\n this.markers && this.markers.clear();\n }\n },\n instance: MarkersPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n this.util = ws.util;\n this.style = this.util.style;\n this.markerWidth = 11;\n this.markerHeight = 22;\n\n\n this._onResize = () => {\n this._updateMarkerPositions();\n };\n\n this._onBackendCreated = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n if (this.params.markers) {\n this.params.markers.forEach(marker => this.add(marker));\n }\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.on('zoom', this._onResize);\n };\n\n this.markers = [];\n this._onReady = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this._updateMarkerPositions();\n };\n }\n\n init() {\n // Check if ws is ready\n if (this.wavesurfer.isReady) {\n this._onBackendCreated();\n this._onReady();\n } else {\n this.wavesurfer.once('ready', this._onReady);\n this.wavesurfer.once('backend-created', this._onBackendCreated);\n }\n }\n\n destroy() {\n this.wavesurfer.un('ready', this._onReady);\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n\n this.wavesurfer.un('zoom', this._onResize);\n\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n\n this.clear();\n }\n\n /**\n * Add a marker\n *\n * @param {MarkerParams} params Marker definition\n * @return {object} The created marker\n */\n add(params) {\n let marker = {\n time: params.time,\n label: params.label,\n color: params.color || DEFAULT_FILL_COLOR,\n position: params.position || DEFAULT_POSITION\n };\n\n if (params.markerElement) {\n this.markerWidth = params.markerElement.width;\n this.markerHeight = params.markerElement.height;\n }\n\n marker.el = this._createMarkerElement(marker, params.markerElement);\n\n this.wrapper.appendChild(marker.el);\n this.markers.push(marker);\n this._updateMarkerPositions();\n\n return marker;\n }\n\n /**\n * Remove a marker\n *\n * @param {number} index Index of the marker to remove\n */\n remove(index) {\n let marker = this.markers[index];\n if (!marker) {\n return;\n }\n\n this.wrapper.removeChild(marker.el);\n this.markers.splice(index, 1);\n }\n\n _createPointerSVG(color, position) {\n const svgNS = \"http://www.w3.org/2000/svg\";\n\n const el = document.createElementNS(svgNS, \"svg\");\n const polygon = document.createElementNS(svgNS, \"polygon\");\n\n el.setAttribute(\"viewBox\", \"0 0 40 80\");\n\n polygon.setAttribute(\"id\", \"polygon\");\n polygon.setAttribute(\"stroke\", \"#979797\");\n polygon.setAttribute(\"fill\", color);\n polygon.setAttribute(\"points\", \"20 0 40 30 40 80 0 80 0 30\");\n if ( position == \"top\" ) {\n polygon.setAttribute(\"transform\", \"rotate(180, 20 40)\");\n }\n\n el.appendChild(polygon);\n\n this.style(el, {\n width: this.markerWidth + \"px\",\n height: this.markerHeight + \"px\",\n \"min-width\": this.markerWidth + \"px\",\n \"margin-right\": \"5px\",\n \"z-index\": 4\n });\n return el;\n }\n\n _createMarkerElement(marker, markerElement) {\n let label = marker.label;\n let time = marker.time;\n\n const el = document.createElement('marker');\n el.className = \"wavesurfer-marker\";\n\n this.style(el, {\n position: \"absolute\",\n height: \"100%\",\n display: \"flex\",\n overflow: \"hidden\",\n \"flex-direction\": (marker.position == \"top\" ? \"column-reverse\" : \"column\")\n });\n\n const line = document.createElement('div');\n this.style(line, {\n \"flex-grow\": 1,\n \"margin-left\": (this.markerWidth / 2 - 0.5) + \"px\",\n background: \"black\",\n width: \"1px\",\n opacity: 0.1\n });\n el.appendChild(line);\n\n const labelDiv = document.createElement('div');\n const point = markerElement || this._createPointerSVG(marker.color, marker.position);\n labelDiv.appendChild(point);\n\n if ( label ) {\n const labelEl = document.createElement('span');\n labelEl.innerText = label;\n this.style(labelEl, {\n \"font-family\": \"monospace\",\n \"font-size\": \"90%\"\n });\n labelDiv.appendChild(labelEl);\n }\n\n this.style(labelDiv, {\n display: \"flex\",\n \"align-items\": \"center\",\n cursor: \"pointer\"\n });\n\n el.appendChild(labelDiv);\n\n labelDiv.addEventListener(\"click\", e => {\n e.stopPropagation();\n this.wavesurfer.setCurrentTime(time);\n this.wavesurfer.fireEvent(\"marker-click\", marker, e);\n });\n\n return el;\n }\n\n _updateMarkerPositions() {\n const duration = this.wavesurfer.getDuration();\n\n for ( let i = 0 ; i < this.markers.length; i++ ) {\n let marker = this.markers[i];\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n\n const positionPct = Math.min(marker.time / duration, 1);\n const leftPx = ((elementWidth * positionPct) - (this.markerWidth / 2));\n this.style(marker.el, {\n \"left\": leftPx + \"px\",\n \"max-width\": (elementWidth - leftPx) + \"px\"\n });\n }\n }\n\n /**\n * Remove all markers\n */\n clear() {\n while ( this.markers.length > 0 ) {\n this.remove(0);\n }\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/plugin/markers/index.js\");\n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B,SAAhB;AACH;;AACD,mBAAO,KAAKlE,OAAL,CAAaG,GAAb,CAAiB6D,OAAjB,CAAP;AACH,WANQ;AAOTG,UAAAA,YAPS,0BAOM;AACX,iBAAKnE,OAAL,IAAgB,KAAKA,OAAL,CAAaY,KAAb,EAAhB;AACH;AATQ,SAJV;AAeHwD,QAAAA,QAAQ,EAAEjF;AAfP,OAAP;AAiBH;;;;;;;;;;;;;UCzEL;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UEtBA;UACA;UACA;UACA","sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/markers/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/before-startup","webpack://WaveSurfer.[name]/webpack/startup","webpack://WaveSurfer.[name]/webpack/after-startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"markers\"] = factory();\n})(self, function() {\nreturn ","\n/**\n * @typedef {Object} MarkerParams\n * @desc The parameters used to describe a marker.\n * @example wavesurfer.addMarker(regionParams);\n * @property {number} time The time to set the marker at\n * @property {?label} string An optional marker label\n * @property {?color} string Background color for marker\n * @property {?position} string \"top\" or \"bottom\", defaults to \"bottom\"\n * @property {?markerElement} element An HTML element to display instead of the default marker image\n */\n\n\n/**\n * Markers are points in time in the audio that can be jumped to.\n *\n * @implements {PluginClass}\n *\n * @example\n * import MarkersPlugin from 'wavesurfer.markers.js';\n *\n * // if you are using <script> tags\n * var MarkerPlugin = window.WaveSurfer.markers;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MarkersPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\n\nconst DEFAULT_FILL_COLOR = \"#D8D8D8\";\nconst DEFAULT_POSITION = \"bottom\";\n\nexport default class MarkersPlugin {\n /**\n * @typedef {Object} MarkersPluginParams\n * @property {?MarkerParams[]} markers Initial set of markers\n * @fires MarkersPlugin#marker-click\n */\n\n /**\n * Markers plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MarkersPluginParams} params parameters use to initialise the plugin\n * @since 4.6.0\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'markers',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {\n addMarker(options) {\n if (!this.initialisedPluginList.markers) {\n this.initPlugin('markers');\n }\n return this.markers.add(options);\n },\n clearMarkers() {\n this.markers && this.markers.clear();\n }\n },\n instance: MarkersPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n this.util = ws.util;\n this.style = this.util.style;\n this.markerWidth = 11;\n this.markerHeight = 22;\n\n\n this._onResize = () => {\n this._updateMarkerPositions();\n };\n\n this._onBackendCreated = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n if (this.params.markers) {\n this.params.markers.forEach(marker => this.add(marker));\n }\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.on('zoom', this._onResize);\n };\n\n this.markers = [];\n this._onReady = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this._updateMarkerPositions();\n };\n }\n\n init() {\n // Check if ws is ready\n if (this.wavesurfer.isReady) {\n this._onBackendCreated();\n this._onReady();\n } else {\n this.wavesurfer.once('ready', this._onReady);\n this.wavesurfer.once('backend-created', this._onBackendCreated);\n }\n }\n\n destroy() {\n this.wavesurfer.un('ready', this._onReady);\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n\n this.wavesurfer.un('zoom', this._onResize);\n\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n\n this.clear();\n }\n\n /**\n * Add a marker\n *\n * @param {MarkerParams} params Marker definition\n * @return {object} The created marker\n */\n add(params) {\n let marker = {\n time: params.time,\n label: params.label,\n color: params.color || DEFAULT_FILL_COLOR,\n position: params.position || DEFAULT_POSITION\n };\n\n if (params.markerElement) {\n this.markerWidth = params.markerElement.width;\n this.markerHeight = params.markerElement.height;\n }\n\n marker.el = this._createMarkerElement(marker, params.markerElement);\n\n this.wrapper.appendChild(marker.el);\n this.markers.push(marker);\n this._updateMarkerPositions();\n\n return marker;\n }\n\n /**\n * Remove a marker\n *\n * @param {number} index Index of the marker to remove\n */\n remove(index) {\n let marker = this.markers[index];\n if (!marker) {\n return;\n }\n\n this.wrapper.removeChild(marker.el);\n this.markers.splice(index, 1);\n }\n\n _createPointerSVG(color, position) {\n const svgNS = \"http://www.w3.org/2000/svg\";\n\n const el = document.createElementNS(svgNS, \"svg\");\n const polygon = document.createElementNS(svgNS, \"polygon\");\n\n el.setAttribute(\"viewBox\", \"0 0 40 80\");\n\n polygon.setAttribute(\"id\", \"polygon\");\n polygon.setAttribute(\"stroke\", \"#979797\");\n polygon.setAttribute(\"fill\", color);\n polygon.setAttribute(\"points\", \"20 0 40 30 40 80 0 80 0 30\");\n if ( position == \"top\" ) {\n polygon.setAttribute(\"transform\", \"rotate(180, 20 40)\");\n }\n\n el.appendChild(polygon);\n\n this.style(el, {\n width: this.markerWidth + \"px\",\n height: this.markerHeight + \"px\",\n \"min-width\": this.markerWidth + \"px\",\n \"margin-right\": \"5px\",\n \"z-index\": 4\n });\n return el;\n }\n\n _createMarkerElement(marker, markerElement) {\n let label = marker.label;\n let time = marker.time;\n\n const el = document.createElement('marker');\n el.className = \"wavesurfer-marker\";\n\n this.style(el, {\n position: \"absolute\",\n height: \"100%\",\n display: \"flex\",\n overflow: \"hidden\",\n \"flex-direction\": (marker.position == \"top\" ? \"column-reverse\" : \"column\")\n });\n\n const line = document.createElement('div');\n this.style(line, {\n \"flex-grow\": 1,\n \"margin-left\": (this.markerWidth / 2 - 0.5) + \"px\",\n background: \"black\",\n width: \"1px\",\n opacity: 0.1\n });\n el.appendChild(line);\n\n const labelDiv = document.createElement('div');\n const point = markerElement || this._createPointerSVG(marker.color, marker.position);\n labelDiv.appendChild(point);\n\n if ( label ) {\n const labelEl = document.createElement('span');\n labelEl.innerText = label;\n this.style(labelEl, {\n \"font-family\": \"monospace\",\n \"font-size\": \"90%\"\n });\n labelDiv.appendChild(labelEl);\n }\n\n this.style(labelDiv, {\n display: \"flex\",\n \"align-items\": \"center\",\n cursor: \"pointer\"\n });\n\n el.appendChild(labelDiv);\n\n labelDiv.addEventListener(\"click\", e => {\n e.stopPropagation();\n this.wavesurfer.setCurrentTime(time);\n this.wavesurfer.fireEvent(\"marker-click\", marker, e);\n });\n\n return el;\n }\n\n _updateMarkerPositions() {\n const duration = this.wavesurfer.getDuration();\n\n for ( let i = 0 ; i < this.markers.length; i++ ) {\n let marker = this.markers[i];\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n\n const positionPct = Math.min(marker.time / duration, 1);\n const leftPx = ((elementWidth * positionPct) - (this.markerWidth / 2));\n this.style(marker.el, {\n \"left\": leftPx + \"px\",\n \"max-width\": (elementWidth - leftPx) + \"px\"\n });\n }\n }\n\n /**\n * Remove all markers\n */\n clear() {\n while ( this.markers.length > 0 ) {\n this.remove(0);\n }\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/plugin/markers/index.js\");\n",""],"names":["DEFAULT_FILL_COLOR","DEFAULT_POSITION","MarkersPlugin","params","ws","wavesurfer","util","style","markerWidth","markerHeight","_onResize","_updateMarkerPositions","_onBackendCreated","wrapper","drawer","markers","forEach","marker","add","window","addEventListener","on","_onReady","isReady","once","un","removeEventListener","clear","time","label","color","position","markerElement","width","height","el","_createMarkerElement","appendChild","push","index","removeChild","splice","svgNS","document","createElementNS","polygon","setAttribute","createElement","className","display","overflow","line","background","opacity","labelDiv","point","_createPointerSVG","labelEl","innerText","cursor","e","stopPropagation","setCurrentTime","fireEvent","duration","getDuration","i","length","elementWidth","pixelRatio","positionPct","Math","min","leftPx","remove","name","deferInit","staticProps","addMarker","options","initialisedPluginList","initPlugin","clearMarkers","instance"],"sourceRoot":""}
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * wavesurfer.js markers plugin 5.1.0 (2021-06-20)
2
+ * wavesurfer.js markers plugin 5.2.0 (2021-08-16)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
6
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.markers=t())}(this,(function(){return(()=>{"use strict";var e={188:(e,t)=>{function r(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)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(){function e(t,r){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=t,this.wavesurfer=r,this.util=r.util,this.style=this.util.style,this.markerWidth=11,this.markerHeight=22,this._onResize=function(){i._updateMarkerPositions()},this._onBackendCreated=function(){i.wrapper=i.wavesurfer.drawer.wrapper,i.params.markers&&i.params.markers.forEach((function(e){return i.add(e)})),window.addEventListener("resize",i._onResize,!0),window.addEventListener("orientationchange",i._onResize,!0),i.wavesurfer.on("zoom",i._onResize)},this.markers=[],this._onReady=function(){i.wrapper=i.wavesurfer.drawer.wrapper,i._updateMarkerPositions()}}var t,i,a;return t=e,a=[{key:"create",value:function(t){return{name:"markers",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,staticProps:{addMarker:function(e){return this.initialisedPluginList.markers||this.initPlugin("markers"),this.markers.add(e)},clearMarkers:function(){this.markers&&this.markers.clear()}},instance:e}}}],(i=[{key:"init",value:function(){this.wavesurfer.isReady?(this._onBackendCreated(),this._onReady()):(this.wavesurfer.once("ready",this._onReady),this.wavesurfer.once("backend-created",this._onBackendCreated))}},{key:"destroy",value:function(){this.wavesurfer.un("ready",this._onReady),this.wavesurfer.un("backend-created",this._onBackendCreated),this.wavesurfer.un("zoom",this._onResize),window.removeEventListener("resize",this._onResize,!0),window.removeEventListener("orientationchange",this._onResize,!0),this.clear()}},{key:"add",value:function(e){var t={time:e.time,label:e.label,color:e.color||"#D8D8D8",position:e.position||"bottom"};return e.markerElement&&(this.markerWidth=e.markerElement.width,this.markerHeight=e.markerElement.height),t.el=this._createMarkerElement(t,e.markerElement),this.wrapper.appendChild(t.el),this.markers.push(t),this._updateMarkerPositions(),t}},{key:"remove",value:function(e){var t=this.markers[e];t&&(this.wrapper.removeChild(t.el),this.markers.splice(e,1))}},{key:"_createPointerSVG",value:function(e,t){var r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),a=document.createElementNS(r,"polygon");return i.setAttribute("viewBox","0 0 40 80"),a.setAttribute("id","polygon"),a.setAttribute("stroke","#979797"),a.setAttribute("fill",e),a.setAttribute("points","20 0 40 30 40 80 0 80 0 30"),"top"==t&&a.setAttribute("transform","rotate(180, 20 40)"),i.appendChild(a),this.style(i,{width:this.markerWidth+"px",height:this.markerHeight+"px","min-width":this.markerWidth+"px","margin-right":"5px","z-index":4}),i}},{key:"_createMarkerElement",value:function(e,t){var r=this,i=e.label,a=e.time,n=document.createElement("marker");n.className="wavesurfer-marker",this.style(n,{position:"absolute",height:"100%",display:"flex",overflow:"hidden","flex-direction":"top"==e.position?"column-reverse":"column"});var s=document.createElement("div");this.style(s,{"flex-grow":1,"margin-left":this.markerWidth/2-.5+"px",background:"black",width:"1px",opacity:.1}),n.appendChild(s);var o=document.createElement("div"),u=t||this._createPointerSVG(e.color,e.position);if(o.appendChild(u),i){var d=document.createElement("span");d.innerText=i,this.style(d,{"font-family":"monospace","font-size":"90%"}),o.appendChild(d)}return this.style(o,{display:"flex","align-items":"center",cursor:"pointer"}),n.appendChild(o),o.addEventListener("click",(function(t){t.stopPropagation(),r.wavesurfer.setCurrentTime(a),r.wavesurfer.fireEvent("marker-click",e,t)})),n}},{key:"_updateMarkerPositions",value:function(){for(var e=this.wavesurfer.getDuration(),t=0;t<this.markers.length;t++){var r=this.markers[t],i=this.wavesurfer.drawer.width/this.wavesurfer.params.pixelRatio,a=i*Math.min(r.time/e,1)-this.markerWidth/2;this.style(r.el,{left:a+"px","max-width":i-a+"px"})}}},{key:"clear",value:function(){for(;this.markers.length>0;)this.remove(0)}}])&&r(t.prototype,i),a&&r(t,a),e}();t.default=i,e.exports=t.default}},t={};return function r(i){var a=t[i];if(void 0!==a)return a.exports;var n=t[i]={exports:{}};return e[i](n,n.exports,r),n.exports}(188)})()}));
6
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.markers=t())}(self,(function(){return(()=>{"use strict";var e={188:(e,t)=>{function r(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)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(){function e(t,r){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=t,this.wavesurfer=r,this.util=r.util,this.style=this.util.style,this.markerWidth=11,this.markerHeight=22,this._onResize=function(){i._updateMarkerPositions()},this._onBackendCreated=function(){i.wrapper=i.wavesurfer.drawer.wrapper,i.params.markers&&i.params.markers.forEach((function(e){return i.add(e)})),window.addEventListener("resize",i._onResize,!0),window.addEventListener("orientationchange",i._onResize,!0),i.wavesurfer.on("zoom",i._onResize)},this.markers=[],this._onReady=function(){i.wrapper=i.wavesurfer.drawer.wrapper,i._updateMarkerPositions()}}var t,i,a;return t=e,a=[{key:"create",value:function(t){return{name:"markers",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,staticProps:{addMarker:function(e){return this.initialisedPluginList.markers||this.initPlugin("markers"),this.markers.add(e)},clearMarkers:function(){this.markers&&this.markers.clear()}},instance:e}}}],(i=[{key:"init",value:function(){this.wavesurfer.isReady?(this._onBackendCreated(),this._onReady()):(this.wavesurfer.once("ready",this._onReady),this.wavesurfer.once("backend-created",this._onBackendCreated))}},{key:"destroy",value:function(){this.wavesurfer.un("ready",this._onReady),this.wavesurfer.un("backend-created",this._onBackendCreated),this.wavesurfer.un("zoom",this._onResize),window.removeEventListener("resize",this._onResize,!0),window.removeEventListener("orientationchange",this._onResize,!0),this.clear()}},{key:"add",value:function(e){var t={time:e.time,label:e.label,color:e.color||"#D8D8D8",position:e.position||"bottom"};return e.markerElement&&(this.markerWidth=e.markerElement.width,this.markerHeight=e.markerElement.height),t.el=this._createMarkerElement(t,e.markerElement),this.wrapper.appendChild(t.el),this.markers.push(t),this._updateMarkerPositions(),t}},{key:"remove",value:function(e){var t=this.markers[e];t&&(this.wrapper.removeChild(t.el),this.markers.splice(e,1))}},{key:"_createPointerSVG",value:function(e,t){var r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),a=document.createElementNS(r,"polygon");return i.setAttribute("viewBox","0 0 40 80"),a.setAttribute("id","polygon"),a.setAttribute("stroke","#979797"),a.setAttribute("fill",e),a.setAttribute("points","20 0 40 30 40 80 0 80 0 30"),"top"==t&&a.setAttribute("transform","rotate(180, 20 40)"),i.appendChild(a),this.style(i,{width:this.markerWidth+"px",height:this.markerHeight+"px","min-width":this.markerWidth+"px","margin-right":"5px","z-index":4}),i}},{key:"_createMarkerElement",value:function(e,t){var r=this,i=e.label,a=e.time,n=document.createElement("marker");n.className="wavesurfer-marker",this.style(n,{position:"absolute",height:"100%",display:"flex",overflow:"hidden","flex-direction":"top"==e.position?"column-reverse":"column"});var s=document.createElement("div");this.style(s,{"flex-grow":1,"margin-left":this.markerWidth/2-.5+"px",background:"black",width:"1px",opacity:.1}),n.appendChild(s);var o=document.createElement("div"),u=t||this._createPointerSVG(e.color,e.position);if(o.appendChild(u),i){var d=document.createElement("span");d.innerText=i,this.style(d,{"font-family":"monospace","font-size":"90%"}),o.appendChild(d)}return this.style(o,{display:"flex","align-items":"center",cursor:"pointer"}),n.appendChild(o),o.addEventListener("click",(function(t){t.stopPropagation(),r.wavesurfer.setCurrentTime(a),r.wavesurfer.fireEvent("marker-click",e,t)})),n}},{key:"_updateMarkerPositions",value:function(){for(var e=this.wavesurfer.getDuration(),t=0;t<this.markers.length;t++){var r=this.markers[t],i=this.wavesurfer.drawer.width/this.wavesurfer.params.pixelRatio,a=i*Math.min(r.time/e,1)-this.markerWidth/2;this.style(r.el,{left:a+"px","max-width":i-a+"px"})}}},{key:"clear",value:function(){for(;this.markers.length>0;)this.remove(0)}}])&&r(t.prototype,i),a&&r(t,a),e}();t.default=i,e.exports=t.default}},t={};return function r(i){var a=t[i];if(void 0!==a)return a.exports;var n=t[i]={exports:{}};return e[i](n,n.exports,r),n.exports}(188)})()}));
7
7
  //# sourceMappingURL=wavesurfer.markers.min.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/markers/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"names":["root","factory","exports","module","define","amd","this","MarkersPlugin","params","ws","wavesurfer","util","style","markerWidth","markerHeight","_onResize","_updateMarkerPositions","_onBackendCreated","wrapper","drawer","markers","forEach","marker","add","window","addEventListener","on","_onReady","name","deferInit","staticProps","addMarker","options","initialisedPluginList","initPlugin","clearMarkers","clear","instance","isReady","once","un","removeEventListener","time","label","color","position","markerElement","width","height","el","_createMarkerElement","appendChild","push","index","removeChild","splice","svgNS","document","createElementNS","polygon","setAttribute","createElement","className","display","overflow","line","background","opacity","labelDiv","point","_createPointerSVG","labelEl","innerText","cursor","e","stopPropagation","setCurrentTime","fireEvent","duration","getDuration","i","length","elementWidth","pixelRatio","leftPx","Math","min","remove","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,QAAoB,WAAID,KAExBD,EAAiB,WAAIA,EAAiB,YAAK,GAAIA,EAAiB,WAAW,QAAIC,KARjF,CASGK,MAAM,WACT,M,8QCyBA,IAGqBC,E,WAqCjB,WAAYC,EAAQC,GAAI,Y,4FAAA,SACpBH,KAAKE,OAASA,EACdF,KAAKI,WAAaD,EAClBH,KAAKK,KAAOF,EAAGE,KACfL,KAAKM,MAAQN,KAAKK,KAAKC,MACvBN,KAAKO,YAAc,GACnBP,KAAKQ,aAAe,GAGpBR,KAAKS,UAAY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qF,EAAyBE,GAAY,CAGjDxF,QAAS,IAOV,OAHA2F,EAAoBH,GAAUvF,EAAQA,EAAOD,QAASuF,GAG/CtF,EAAOD,QClBWuF,CAAoB,M","file":"wavesurfer.markers.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"markers\"] = factory();\n})(this, function() {\nreturn ","\n/**\n * @typedef {Object} MarkerParams\n * @desc The parameters used to describe a marker.\n * @example wavesurfer.addMarker(regionParams);\n * @property {number} time The time to set the marker at\n * @property {?label} string An optional marker label\n * @property {?color} string Background color for marker\n * @property {?position} string \"top\" or \"bottom\", defaults to \"bottom\"\n * @property {?markerElement} element An HTML element to display instead of the default marker image\n */\n\n\n/**\n * Markers are points in time in the audio that can be jumped to.\n *\n * @implements {PluginClass}\n *\n * @example\n * import MarkersPlugin from 'wavesurfer.markers.js';\n *\n * // if you are using <script> tags\n * var MarkerPlugin = window.WaveSurfer.markers;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MarkersPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\n\nconst DEFAULT_FILL_COLOR = \"#D8D8D8\";\nconst DEFAULT_POSITION = \"bottom\";\n\nexport default class MarkersPlugin {\n /**\n * @typedef {Object} MarkersPluginParams\n * @property {?MarkerParams[]} markers Initial set of markers\n * @fires MarkersPlugin#marker-click\n */\n\n /**\n * Markers plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MarkersPluginParams} params parameters use to initialise the plugin\n * @since 4.6.0\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'markers',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {\n addMarker(options) {\n if (!this.initialisedPluginList.markers) {\n this.initPlugin('markers');\n }\n return this.markers.add(options);\n },\n clearMarkers() {\n this.markers && this.markers.clear();\n }\n },\n instance: MarkersPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n this.util = ws.util;\n this.style = this.util.style;\n this.markerWidth = 11;\n this.markerHeight = 22;\n\n\n this._onResize = () => {\n this._updateMarkerPositions();\n };\n\n this._onBackendCreated = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n if (this.params.markers) {\n this.params.markers.forEach(marker => this.add(marker));\n }\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.on('zoom', this._onResize);\n };\n\n this.markers = [];\n this._onReady = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this._updateMarkerPositions();\n };\n }\n\n init() {\n // Check if ws is ready\n if (this.wavesurfer.isReady) {\n this._onBackendCreated();\n this._onReady();\n } else {\n this.wavesurfer.once('ready', this._onReady);\n this.wavesurfer.once('backend-created', this._onBackendCreated);\n }\n }\n\n destroy() {\n this.wavesurfer.un('ready', this._onReady);\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n\n this.wavesurfer.un('zoom', this._onResize);\n\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n\n this.clear();\n }\n\n /**\n * Add a marker\n *\n * @param {MarkerParams} params Marker definition\n * @return {object} The created marker\n */\n add(params) {\n let marker = {\n time: params.time,\n label: params.label,\n color: params.color || DEFAULT_FILL_COLOR,\n position: params.position || DEFAULT_POSITION\n };\n\n if (params.markerElement) {\n this.markerWidth = params.markerElement.width;\n this.markerHeight = params.markerElement.height;\n }\n\n marker.el = this._createMarkerElement(marker, params.markerElement);\n\n this.wrapper.appendChild(marker.el);\n this.markers.push(marker);\n this._updateMarkerPositions();\n\n return marker;\n }\n\n /**\n * Remove a marker\n *\n * @param {number} index Index of the marker to remove\n */\n remove(index) {\n let marker = this.markers[index];\n if (!marker) {\n return;\n }\n\n this.wrapper.removeChild(marker.el);\n this.markers.splice(index, 1);\n }\n\n _createPointerSVG(color, position) {\n const svgNS = \"http://www.w3.org/2000/svg\";\n\n const el = document.createElementNS(svgNS, \"svg\");\n const polygon = document.createElementNS(svgNS, \"polygon\");\n\n el.setAttribute(\"viewBox\", \"0 0 40 80\");\n\n polygon.setAttribute(\"id\", \"polygon\");\n polygon.setAttribute(\"stroke\", \"#979797\");\n polygon.setAttribute(\"fill\", color);\n polygon.setAttribute(\"points\", \"20 0 40 30 40 80 0 80 0 30\");\n if ( position == \"top\" ) {\n polygon.setAttribute(\"transform\", \"rotate(180, 20 40)\");\n }\n\n el.appendChild(polygon);\n\n this.style(el, {\n width: this.markerWidth + \"px\",\n height: this.markerHeight + \"px\",\n \"min-width\": this.markerWidth + \"px\",\n \"margin-right\": \"5px\",\n \"z-index\": 4\n });\n return el;\n }\n\n _createMarkerElement(marker, markerElement) {\n let label = marker.label;\n let time = marker.time;\n\n const el = document.createElement('marker');\n el.className = \"wavesurfer-marker\";\n\n this.style(el, {\n position: \"absolute\",\n height: \"100%\",\n display: \"flex\",\n overflow: \"hidden\",\n \"flex-direction\": (marker.position == \"top\" ? \"column-reverse\" : \"column\")\n });\n\n const line = document.createElement('div');\n this.style(line, {\n \"flex-grow\": 1,\n \"margin-left\": (this.markerWidth / 2 - 0.5) + \"px\",\n background: \"black\",\n width: \"1px\",\n opacity: 0.1\n });\n el.appendChild(line);\n\n const labelDiv = document.createElement('div');\n const point = markerElement || this._createPointerSVG(marker.color, marker.position);\n labelDiv.appendChild(point);\n\n if ( label ) {\n const labelEl = document.createElement('span');\n labelEl.innerText = label;\n this.style(labelEl, {\n \"font-family\": \"monospace\",\n \"font-size\": \"90%\"\n });\n labelDiv.appendChild(labelEl);\n }\n\n this.style(labelDiv, {\n display: \"flex\",\n \"align-items\": \"center\",\n cursor: \"pointer\"\n });\n\n el.appendChild(labelDiv);\n\n labelDiv.addEventListener(\"click\", e => {\n e.stopPropagation();\n this.wavesurfer.setCurrentTime(time);\n this.wavesurfer.fireEvent(\"marker-click\", marker, e);\n });\n\n return el;\n }\n\n _updateMarkerPositions() {\n const duration = this.wavesurfer.getDuration();\n\n for ( let i = 0 ; i < this.markers.length; i++ ) {\n let marker = this.markers[i];\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n\n const positionPct = Math.min(marker.time / duration, 1);\n const leftPx = ((elementWidth * positionPct) - (this.markerWidth / 2));\n this.style(marker.el, {\n \"left\": leftPx + \"px\",\n \"max-width\": (elementWidth - leftPx) + \"px\"\n });\n }\n }\n\n /**\n * Remove all markers\n */\n clear() {\n while ( this.markers.length > 0 ) {\n this.remove(0);\n }\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(188);\n"],"sourceRoot":""}
1
+ {"version":3,"file":"wavesurfer.markers.min.js","mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,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B,KAAOoC,EAAU,GACLrE,KAAKI,YAAc,EACnEJ,KAAKG,MAAMU,EAAO2B,GAAI,CAClB,KAASmC,EAAS,KAClB,YAAcF,EAAeE,EAAU,U,mBAQnD,WACI,KAAQ3E,KAAKW,QAAQ6D,OAAS,GAC1BxE,KAAK8E,OAAO,Q,6BAhPHjF,G,kCCrCjBkF,EAA2B,G,OAG/B,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAa1F,QAGrB,IAAIC,EAASsF,EAAyBE,GAAY,CAGjDzF,QAAS,IAOV,OAHA4F,EAAoBH,GAAUxF,EAAQA,EAAOD,QAASwF,GAG/CvF,EAAOD,QClBWwF,CAAoB,MHO9C","sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/markers/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"markers\"] = factory();\n})(self, function() {\nreturn ","\n/**\n * @typedef {Object} MarkerParams\n * @desc The parameters used to describe a marker.\n * @example wavesurfer.addMarker(regionParams);\n * @property {number} time The time to set the marker at\n * @property {?label} string An optional marker label\n * @property {?color} string Background color for marker\n * @property {?position} string \"top\" or \"bottom\", defaults to \"bottom\"\n * @property {?markerElement} element An HTML element to display instead of the default marker image\n */\n\n\n/**\n * Markers are points in time in the audio that can be jumped to.\n *\n * @implements {PluginClass}\n *\n * @example\n * import MarkersPlugin from 'wavesurfer.markers.js';\n *\n * // if you are using <script> tags\n * var MarkerPlugin = window.WaveSurfer.markers;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MarkersPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\n\nconst DEFAULT_FILL_COLOR = \"#D8D8D8\";\nconst DEFAULT_POSITION = \"bottom\";\n\nexport default class MarkersPlugin {\n /**\n * @typedef {Object} MarkersPluginParams\n * @property {?MarkerParams[]} markers Initial set of markers\n * @fires MarkersPlugin#marker-click\n */\n\n /**\n * Markers plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MarkersPluginParams} params parameters use to initialise the plugin\n * @since 4.6.0\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'markers',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {\n addMarker(options) {\n if (!this.initialisedPluginList.markers) {\n this.initPlugin('markers');\n }\n return this.markers.add(options);\n },\n clearMarkers() {\n this.markers && this.markers.clear();\n }\n },\n instance: MarkersPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n this.util = ws.util;\n this.style = this.util.style;\n this.markerWidth = 11;\n this.markerHeight = 22;\n\n\n this._onResize = () => {\n this._updateMarkerPositions();\n };\n\n this._onBackendCreated = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n if (this.params.markers) {\n this.params.markers.forEach(marker => this.add(marker));\n }\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.on('zoom', this._onResize);\n };\n\n this.markers = [];\n this._onReady = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this._updateMarkerPositions();\n };\n }\n\n init() {\n // Check if ws is ready\n if (this.wavesurfer.isReady) {\n this._onBackendCreated();\n this._onReady();\n } else {\n this.wavesurfer.once('ready', this._onReady);\n this.wavesurfer.once('backend-created', this._onBackendCreated);\n }\n }\n\n destroy() {\n this.wavesurfer.un('ready', this._onReady);\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n\n this.wavesurfer.un('zoom', this._onResize);\n\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n\n this.clear();\n }\n\n /**\n * Add a marker\n *\n * @param {MarkerParams} params Marker definition\n * @return {object} The created marker\n */\n add(params) {\n let marker = {\n time: params.time,\n label: params.label,\n color: params.color || DEFAULT_FILL_COLOR,\n position: params.position || DEFAULT_POSITION\n };\n\n if (params.markerElement) {\n this.markerWidth = params.markerElement.width;\n this.markerHeight = params.markerElement.height;\n }\n\n marker.el = this._createMarkerElement(marker, params.markerElement);\n\n this.wrapper.appendChild(marker.el);\n this.markers.push(marker);\n this._updateMarkerPositions();\n\n return marker;\n }\n\n /**\n * Remove a marker\n *\n * @param {number} index Index of the marker to remove\n */\n remove(index) {\n let marker = this.markers[index];\n if (!marker) {\n return;\n }\n\n this.wrapper.removeChild(marker.el);\n this.markers.splice(index, 1);\n }\n\n _createPointerSVG(color, position) {\n const svgNS = \"http://www.w3.org/2000/svg\";\n\n const el = document.createElementNS(svgNS, \"svg\");\n const polygon = document.createElementNS(svgNS, \"polygon\");\n\n el.setAttribute(\"viewBox\", \"0 0 40 80\");\n\n polygon.setAttribute(\"id\", \"polygon\");\n polygon.setAttribute(\"stroke\", \"#979797\");\n polygon.setAttribute(\"fill\", color);\n polygon.setAttribute(\"points\", \"20 0 40 30 40 80 0 80 0 30\");\n if ( position == \"top\" ) {\n polygon.setAttribute(\"transform\", \"rotate(180, 20 40)\");\n }\n\n el.appendChild(polygon);\n\n this.style(el, {\n width: this.markerWidth + \"px\",\n height: this.markerHeight + \"px\",\n \"min-width\": this.markerWidth + \"px\",\n \"margin-right\": \"5px\",\n \"z-index\": 4\n });\n return el;\n }\n\n _createMarkerElement(marker, markerElement) {\n let label = marker.label;\n let time = marker.time;\n\n const el = document.createElement('marker');\n el.className = \"wavesurfer-marker\";\n\n this.style(el, {\n position: \"absolute\",\n height: \"100%\",\n display: \"flex\",\n overflow: \"hidden\",\n \"flex-direction\": (marker.position == \"top\" ? \"column-reverse\" : \"column\")\n });\n\n const line = document.createElement('div');\n this.style(line, {\n \"flex-grow\": 1,\n \"margin-left\": (this.markerWidth / 2 - 0.5) + \"px\",\n background: \"black\",\n width: \"1px\",\n opacity: 0.1\n });\n el.appendChild(line);\n\n const labelDiv = document.createElement('div');\n const point = markerElement || this._createPointerSVG(marker.color, marker.position);\n labelDiv.appendChild(point);\n\n if ( label ) {\n const labelEl = document.createElement('span');\n labelEl.innerText = label;\n this.style(labelEl, {\n \"font-family\": \"monospace\",\n \"font-size\": \"90%\"\n });\n labelDiv.appendChild(labelEl);\n }\n\n this.style(labelDiv, {\n display: \"flex\",\n \"align-items\": \"center\",\n cursor: \"pointer\"\n });\n\n el.appendChild(labelDiv);\n\n labelDiv.addEventListener(\"click\", e => {\n e.stopPropagation();\n this.wavesurfer.setCurrentTime(time);\n this.wavesurfer.fireEvent(\"marker-click\", marker, e);\n });\n\n return el;\n }\n\n _updateMarkerPositions() {\n const duration = this.wavesurfer.getDuration();\n\n for ( let i = 0 ; i < this.markers.length; i++ ) {\n let marker = this.markers[i];\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n\n const positionPct = Math.min(marker.time / duration, 1);\n const leftPx = ((elementWidth * positionPct) - (this.markerWidth / 2));\n this.style(marker.el, {\n \"left\": leftPx + \"px\",\n \"max-width\": (elementWidth - leftPx) + \"px\"\n });\n }\n }\n\n /**\n * Remove all markers\n */\n clear() {\n while ( this.markers.length > 0 ) {\n this.remove(0);\n }\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(188);\n"],"names":["root","factory","exports","module","define","amd","self","MarkersPlugin","params","ws","this","wavesurfer","util","style","markerWidth","markerHeight","_onResize","_updateMarkerPositions","_onBackendCreated","wrapper","drawer","markers","forEach","marker","add","window","addEventListener","on","_onReady","name","deferInit","staticProps","addMarker","options","initialisedPluginList","initPlugin","clearMarkers","clear","instance","isReady","once","un","removeEventListener","time","label","color","position","markerElement","width","height","el","_createMarkerElement","appendChild","push","index","removeChild","splice","svgNS","document","createElementNS","polygon","setAttribute","createElement","className","display","overflow","line","background","opacity","labelDiv","point","_createPointerSVG","labelEl","innerText","cursor","e","stopPropagation","setCurrentTime","fireEvent","duration","getDuration","i","length","elementWidth","pixelRatio","leftPx","Math","min","remove","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js mediasession plugin 5.1.0 (2021-06-20)
2
+ * wavesurfer.js mediasession plugin 5.2.0 (2021-08-16)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -12,7 +12,7 @@
12
12
  exports["WaveSurfer"] = factory();
13
13
  else
14
14
  root["WaveSurfer"] = root["WaveSurfer"] || {}, root["WaveSurfer"]["mediasession"] = factory();
15
- })(this, function() {
15
+ })(self, function() {
16
16
  return /******/ (() => { // webpackBootstrap
17
17
  /******/ "use strict";
18
18
  /******/ var __webpack_modules__ = ({
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/mediasession/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"names":["MediaSessionPlugin","params","ws","wavesurfer","navigator","metadata","update","on","mediaSession","setActionHandler","play","playPause","skipBackward","skipForward","MediaMetadata","Function","name","deferInit","instance"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD,O;;;;;;;;;;;;;;;;;;;;;;;;;ACVA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACqBA,kB;AAmBjB,8BAAYC,MAAZ,EAAoBC,EAApB,EAAwB;AAAA;;AAAA;;AACpB,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,UAAL,GAAkBD,EAAlB;;AAEA,QAAI,kBAAkBE,SAAtB,EAAiC;AAC7B;AACA,WAAKC,QAAL,GAAgB,KAAKJ,MAAL,CAAYI,QAA5B;AACA,WAAKC,MAAL,GAH6B,CAK7B;;AACA,WAAKH,UAAL,CAAgBI,EAAhB,CAAmB,MAAnB,EAA2B,YAAM;AAC7B,aAAI,CAACD,MAAL;AACH,OAFD,EAN6B,CAU7B;;AACAF,eAAS,CAACI,YAAV,CAAuBC,gBAAvB,CAAwC,MAAxC,EAAgD,YAAM;AAClD,aAAI,CAACN,UAAL,CAAgBO,IAAhB;AACH,OAFD;AAGAN,eAAS,CAACI,YAAV,CAAuBC,gBAAvB,CAAwC,OAAxC,EAAiD,YAAM;AACnD,aAAI,CAACN,UAAL,CAAgBQ,SAAhB;AACH,OAFD;AAGAP,eAAS,CAACI,YAAV,CAAuBC,gBAAvB,CAAwC,cAAxC,EAAwD,YAAM;AAC1D,aAAI,CAACN,UAAL,CAAgBS,YAAhB;AACH,OAFD;AAGAR,eAAS,CAACI,YAAV,CAAuBC,gBAAvB,CAAwC,aAAxC,EAAuD,YAAM;AACzD,aAAI,CAACN,UAAL,CAAgBU,WAAhB;AACH,OAFD;AAGH;AACJ;;;;WAED,gBAAO,CAAE;;;WAET,mBAAU,CAAE;;;WAEZ,kBAAS;AACL,UAAI,QAAOC,aAAP,yCAAOA,aAAP,eAAgCC,QAAhC,yCAAgCA,QAAhC,EAAJ,EAA8C;AAC1C;AACAX,iBAAS,CAACI,YAAV,CAAuBH,QAAvB,GAAkC,IAAIS,aAAJ,CAAkB,KAAKT,QAAvB,CAAlC;AACH;AACJ;;;;AAzDD;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACI,oBAAcJ,MAAd,EAAsB;AAClB,aAAO;AACHe,YAAI,EAAE,cADH;AAEHC,iBAAS,EAAEhB,MAAM,IAAIA,MAAM,CAACgB,SAAjB,GAA6BhB,MAAM,CAACgB,SAApC,GAAgD,KAFxD;AAGHhB,cAAM,EAAEA,MAHL;AAIHiB,gBAAQ,EAAElB;AAJP,OAAP;AAMH;;;;;;;;;;;;;UCrDL;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UCtBA;UACA;UACA;UACA","file":"wavesurfer.mediasession.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"mediasession\"] = factory();\n})(this, function() {\nreturn ","/*global MediaMetadata*/\n\n/**\n * @typedef {Object} MediaSessionPluginParams\n * @property {MediaMetadata} metadata A MediaMetadata object: a representation\n * of the metadata associated with a MediaSession that can be used by user agents\n * to provide a customized user interface.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('mediasession')`\n */\n\n/**\n * Visualize MediaSession information for a wavesurfer instance.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import MediaSessionPlugin from 'wavesurfer.mediasession.js';\n *\n * // commonjs\n * var MediaSessionPlugin = require('wavesurfer.mediasession.js');\n *\n * // if you are using <script> tags\n * var MediaSessionPlugin = window.WaveSurfer.mediasession;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MediaSessionPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class MediaSessionPlugin {\n /**\n * MediaSession plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MediaSessionPluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'mediasession',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: MediaSessionPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n\n if ('mediaSession' in navigator) {\n // update metadata\n this.metadata = this.params.metadata;\n this.update();\n\n // update metadata when playback starts\n this.wavesurfer.on('play', () => {\n this.update();\n });\n\n // set playback action handlers\n navigator.mediaSession.setActionHandler('play', () => {\n this.wavesurfer.play();\n });\n navigator.mediaSession.setActionHandler('pause', () => {\n this.wavesurfer.playPause();\n });\n navigator.mediaSession.setActionHandler('seekbackward', () => {\n this.wavesurfer.skipBackward();\n });\n navigator.mediaSession.setActionHandler('seekforward', () => {\n this.wavesurfer.skipForward();\n });\n }\n }\n\n init() {}\n\n destroy() {}\n\n update() {\n if (typeof MediaMetadata === typeof Function) {\n // set metadata\n navigator.mediaSession.metadata = new MediaMetadata(this.metadata);\n }\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/plugin/mediasession/index.js\");\n"],"sourceRoot":""}
1
+ {"version":3,"file":"wavesurfer.mediasession.js","mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;ACVA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACqBA;AAmBjB,8BAAYC,MAAZ,EAAoBC,EAApB,EAAwB;AAAA;;AAAA;;AACpB,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,UAAL,GAAkBD,EAAlB;;AAEA,QAAI,kBAAkBE,SAAtB,EAAiC;AAC7B;AACA,WAAKC,QAAL,GAAgB,KAAKJ,MAAL,CAAYI,QAA5B;AACA,WAAKC,MAAL,GAH6B,CAK7B;;AACA,WAAKH,UAAL,CAAgBI,EAAhB,CAAmB,MAAnB,EAA2B,YAAM;AAC7B,aAAI,CAACD,MAAL;AACH,OAFD,EAN6B,CAU7B;;AACAF,MAAAA,SAAS,CAACI,YAAV,CAAuBC,gBAAvB,CAAwC,MAAxC,EAAgD,YAAM;AAClD,aAAI,CAACN,UAAL,CAAgBO,IAAhB;AACH,OAFD;AAGAN,MAAAA,SAAS,CAACI,YAAV,CAAuBC,gBAAvB,CAAwC,OAAxC,EAAiD,YAAM;AACnD,aAAI,CAACN,UAAL,CAAgBQ,SAAhB;AACH,OAFD;AAGAP,MAAAA,SAAS,CAACI,YAAV,CAAuBC,gBAAvB,CAAwC,cAAxC,EAAwD,YAAM;AAC1D,aAAI,CAACN,UAAL,CAAgBS,YAAhB;AACH,OAFD;AAGAR,MAAAA,SAAS,CAACI,YAAV,CAAuBC,gBAAvB,CAAwC,aAAxC,EAAuD,YAAM;AACzD,aAAI,CAACN,UAAL,CAAgBU,WAAhB;AACH,OAFD;AAGH;AACJ;;;;WAED,gBAAO,CAAE;;;WAET,mBAAU,CAAE;;;WAEZ,kBAAS;AACL,UAAI,QAAOC,aAAP,yCAAOA,aAAP,eAAgCC,QAAhC,yCAAgCA,QAAhC,EAAJ,EAA8C;AAC1C;AACAX,QAAAA,SAAS,CAACI,YAAV,CAAuBH,QAAvB,GAAkC,IAAIS,aAAJ,CAAkB,KAAKT,QAAvB,CAAlC;AACH;AACJ;;;;AAzDD;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACI,oBAAcJ,MAAd,EAAsB;AAClB,aAAO;AACHe,QAAAA,IAAI,EAAE,cADH;AAEHC,QAAAA,SAAS,EAAEhB,MAAM,IAAIA,MAAM,CAACgB,SAAjB,GAA6BhB,MAAM,CAACgB,SAApC,GAAgD,KAFxD;AAGHhB,QAAAA,MAAM,EAAEA,MAHL;AAIHiB,QAAAA,QAAQ,EAAElB;AAJP,OAAP;AAMH;;;;;;;;;;;;;UCrDL;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UEtBA;UACA;UACA;UACA","sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/mediasession/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/before-startup","webpack://WaveSurfer.[name]/webpack/startup","webpack://WaveSurfer.[name]/webpack/after-startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"mediasession\"] = factory();\n})(self, function() {\nreturn ","/*global MediaMetadata*/\n\n/**\n * @typedef {Object} MediaSessionPluginParams\n * @property {MediaMetadata} metadata A MediaMetadata object: a representation\n * of the metadata associated with a MediaSession that can be used by user agents\n * to provide a customized user interface.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('mediasession')`\n */\n\n/**\n * Visualize MediaSession information for a wavesurfer instance.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import MediaSessionPlugin from 'wavesurfer.mediasession.js';\n *\n * // commonjs\n * var MediaSessionPlugin = require('wavesurfer.mediasession.js');\n *\n * // if you are using <script> tags\n * var MediaSessionPlugin = window.WaveSurfer.mediasession;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MediaSessionPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class MediaSessionPlugin {\n /**\n * MediaSession plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MediaSessionPluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'mediasession',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: MediaSessionPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n\n if ('mediaSession' in navigator) {\n // update metadata\n this.metadata = this.params.metadata;\n this.update();\n\n // update metadata when playback starts\n this.wavesurfer.on('play', () => {\n this.update();\n });\n\n // set playback action handlers\n navigator.mediaSession.setActionHandler('play', () => {\n this.wavesurfer.play();\n });\n navigator.mediaSession.setActionHandler('pause', () => {\n this.wavesurfer.playPause();\n });\n navigator.mediaSession.setActionHandler('seekbackward', () => {\n this.wavesurfer.skipBackward();\n });\n navigator.mediaSession.setActionHandler('seekforward', () => {\n this.wavesurfer.skipForward();\n });\n }\n }\n\n init() {}\n\n destroy() {}\n\n update() {\n if (typeof MediaMetadata === typeof Function) {\n // set metadata\n navigator.mediaSession.metadata = new MediaMetadata(this.metadata);\n }\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/plugin/mediasession/index.js\");\n",""],"names":["MediaSessionPlugin","params","ws","wavesurfer","navigator","metadata","update","on","mediaSession","setActionHandler","play","playPause","skipBackward","skipForward","MediaMetadata","Function","name","deferInit","instance"],"sourceRoot":""}
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * wavesurfer.js mediasession plugin 5.1.0 (2021-06-20)
2
+ * wavesurfer.js mediasession plugin 5.2.0 (2021-08-16)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
6
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.mediasession=t())}(this,(function(){return(()=>{"use strict";var e={511:(e,t)=>{function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=function(){function e(t,n){var a=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=t,this.wavesurfer=n,"mediaSession"in navigator&&(this.metadata=this.params.metadata,this.update(),this.wavesurfer.on("play",(function(){a.update()})),navigator.mediaSession.setActionHandler("play",(function(){a.wavesurfer.play()})),navigator.mediaSession.setActionHandler("pause",(function(){a.wavesurfer.playPause()})),navigator.mediaSession.setActionHandler("seekbackward",(function(){a.wavesurfer.skipBackward()})),navigator.mediaSession.setActionHandler("seekforward",(function(){a.wavesurfer.skipForward()})))}var t,r,o;return t=e,o=[{key:"create",value:function(t){return{name:"mediasession",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,instance:e}}}],(r=[{key:"init",value:function(){}},{key:"destroy",value:function(){}},{key:"update",value:function(){("undefined"==typeof MediaMetadata?"undefined":n(MediaMetadata))===("undefined"==typeof Function?"undefined":n(Function))&&(navigator.mediaSession.metadata=new MediaMetadata(this.metadata))}}])&&a(t.prototype,r),o&&a(t,o),e}();t.default=r,e.exports=t.default}},t={};return function n(a){var r=t[a];if(void 0!==r)return r.exports;var o=t[a]={exports:{}};return e[a](o,o.exports,n),o.exports}(511)})()}));
6
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.mediasession=t())}(self,(function(){return(()=>{"use strict";var e={511:(e,t)=>{function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=function(){function e(t,n){var a=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=t,this.wavesurfer=n,"mediaSession"in navigator&&(this.metadata=this.params.metadata,this.update(),this.wavesurfer.on("play",(function(){a.update()})),navigator.mediaSession.setActionHandler("play",(function(){a.wavesurfer.play()})),navigator.mediaSession.setActionHandler("pause",(function(){a.wavesurfer.playPause()})),navigator.mediaSession.setActionHandler("seekbackward",(function(){a.wavesurfer.skipBackward()})),navigator.mediaSession.setActionHandler("seekforward",(function(){a.wavesurfer.skipForward()})))}var t,r,o;return t=e,o=[{key:"create",value:function(t){return{name:"mediasession",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,instance:e}}}],(r=[{key:"init",value:function(){}},{key:"destroy",value:function(){}},{key:"update",value:function(){("undefined"==typeof MediaMetadata?"undefined":n(MediaMetadata))===("undefined"==typeof Function?"undefined":n(Function))&&(navigator.mediaSession.metadata=new MediaMetadata(this.metadata))}}])&&a(t.prototype,r),o&&a(t,o),e}();t.default=r,e.exports=t.default}},t={};return function n(a){var r=t[a];if(void 0!==r)return r.exports;var o=t[a]={exports:{}};return e[a](o,o.exports,n),o.exports}(511)})()}));
7
7
  //# sourceMappingURL=wavesurfer.mediasession.min.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/mediasession/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"names":["root","factory","exports","module","define","amd","this","MediaSessionPlugin","params","ws","wavesurfer","navigator","metadata","update","on","mediaSession","setActionHandler","play","playPause","skipBackward","skipForward","name","deferInit","instance","MediaMetadata","Function","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,QAAoB,WAAID,KAExBD,EAAiB,WAAIA,EAAiB,YAAK,GAAIA,EAAiB,WAAgB,aAAIC,KARtF,CASGK,MAAM,WACT,M,ufC0BqBC,E,WAmBjB,WAAYC,EAAQC,GAAI,Y,4FAAA,SACpBH,KAAKE,OAASA,EACdF,KAAKI,WAAaD,EAEd,iBAAkBE,YAElBL,KAAKM,SAAWN,KAAKE,OAAOI,SAC5BN,KAAKO,SAGLP,KAAKI,WAAWI,GAAG,QAAQ,WACvB,EAAKD,YAITF,UAAUI,aAAaC,iBAAiB,QAAQ,WAC5C,EAAKN,WAAWO,UAEpBN,UAAUI,aAAaC,iBAAiB,SAAS,WAC7C,EAAKN,WAAWQ,eAEpBP,UAAUI,aAAaC,iBAAiB,gBAAgB,WACpD,EAAKN,WAAWS,kBAEpBR,UAAUI,aAAaC,iBAAiB,eAAe,WACnD,EAAKN,WAAWU,kB,4CAlC5B,SAAcZ,GACV,MAAO,CACHa,KAAM,eACNC,aAAWd,IAAUA,EAAOc,YAAYd,EAAOc,UAC/Cd,OAAQA,EACRe,SAAUhB,O,qBAkClB,c,qBAEA,c,oBAEA,YACQ,oBAAOiB,cAAP,cAAOA,mBAAP,oBAAgCC,SAAhC,cAAgCA,aAEhCd,UAAUI,aAAaH,SAAW,IAAIY,cAAclB,KAAKM,gB,kEC3FjEc,EAA2B,G,OAG/B,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAa3B,QAGrB,IAAIC,EAASuB,EAAyBE,GAAY,CAGjD1B,QAAS,IAOV,OAHA6B,EAAoBH,GAAUzB,EAAQA,EAAOD,QAASyB,GAG/CxB,EAAOD,QClBWyB,CAAoB,M","file":"wavesurfer.mediasession.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"mediasession\"] = factory();\n})(this, function() {\nreturn ","/*global MediaMetadata*/\n\n/**\n * @typedef {Object} MediaSessionPluginParams\n * @property {MediaMetadata} metadata A MediaMetadata object: a representation\n * of the metadata associated with a MediaSession that can be used by user agents\n * to provide a customized user interface.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('mediasession')`\n */\n\n/**\n * Visualize MediaSession information for a wavesurfer instance.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import MediaSessionPlugin from 'wavesurfer.mediasession.js';\n *\n * // commonjs\n * var MediaSessionPlugin = require('wavesurfer.mediasession.js');\n *\n * // if you are using <script> tags\n * var MediaSessionPlugin = window.WaveSurfer.mediasession;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MediaSessionPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class MediaSessionPlugin {\n /**\n * MediaSession plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MediaSessionPluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'mediasession',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: MediaSessionPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n\n if ('mediaSession' in navigator) {\n // update metadata\n this.metadata = this.params.metadata;\n this.update();\n\n // update metadata when playback starts\n this.wavesurfer.on('play', () => {\n this.update();\n });\n\n // set playback action handlers\n navigator.mediaSession.setActionHandler('play', () => {\n this.wavesurfer.play();\n });\n navigator.mediaSession.setActionHandler('pause', () => {\n this.wavesurfer.playPause();\n });\n navigator.mediaSession.setActionHandler('seekbackward', () => {\n this.wavesurfer.skipBackward();\n });\n navigator.mediaSession.setActionHandler('seekforward', () => {\n this.wavesurfer.skipForward();\n });\n }\n }\n\n init() {}\n\n destroy() {}\n\n update() {\n if (typeof MediaMetadata === typeof Function) {\n // set metadata\n navigator.mediaSession.metadata = new MediaMetadata(this.metadata);\n }\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(511);\n"],"sourceRoot":""}
1
+ {"version":3,"file":"wavesurfer.mediasession.min.js","mappings":";;;;;CAA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AoB,MHO9C","sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/mediasession/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"mediasession\"] = factory();\n})(self, function() {\nreturn ","/*global MediaMetadata*/\n\n/**\n * @typedef {Object} MediaSessionPluginParams\n * @property {MediaMetadata} metadata A MediaMetadata object: a representation\n * of the metadata associated with a MediaSession that can be used by user agents\n * to provide a customized user interface.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('mediasession')`\n */\n\n/**\n * Visualize MediaSession information for a wavesurfer instance.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import MediaSessionPlugin from 'wavesurfer.mediasession.js';\n *\n * // commonjs\n * var MediaSessionPlugin = require('wavesurfer.mediasession.js');\n *\n * // if you are using <script> tags\n * var MediaSessionPlugin = window.WaveSurfer.mediasession;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MediaSessionPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class MediaSessionPlugin {\n /**\n * MediaSession plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MediaSessionPluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'mediasession',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: MediaSessionPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n\n if ('mediaSession' in navigator) {\n // update metadata\n this.metadata = this.params.metadata;\n this.update();\n\n // update metadata when playback starts\n this.wavesurfer.on('play', () => {\n this.update();\n });\n\n // set playback action handlers\n navigator.mediaSession.setActionHandler('play', () => {\n this.wavesurfer.play();\n });\n navigator.mediaSession.setActionHandler('pause', () => {\n this.wavesurfer.playPause();\n });\n navigator.mediaSession.setActionHandler('seekbackward', () => {\n this.wavesurfer.skipBackward();\n });\n navigator.mediaSession.setActionHandler('seekforward', () => {\n this.wavesurfer.skipForward();\n });\n }\n }\n\n init() {}\n\n destroy() {}\n\n update() {\n if (typeof MediaMetadata === typeof Function) {\n // set metadata\n navigator.mediaSession.metadata = new MediaMetadata(this.metadata);\n }\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(511);\n"],"names":["root","factory","exports","module","define","amd","self","MediaSessionPlugin","params","ws","this","wavesurfer","navigator","metadata","update","on","mediaSession","setActionHandler","play","playPause","skipBackward","skipForward","name","deferInit","instance","MediaMetadata","Function","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js microphone plugin 5.1.0 (2021-06-20)
2
+ * wavesurfer.js microphone plugin 5.2.0 (2021-08-16)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -12,7 +12,7 @@
12
12
  exports["WaveSurfer"] = factory();
13
13
  else
14
14
  root["WaveSurfer"] = root["WaveSurfer"] || {}, root["WaveSurfer"]["microphone"] = factory();
15
- })(this, function() {
15
+ })(self, function() {
16
16
  return /******/ (() => { // webpackBootstrap
17
17
  /******/ "use strict";
18
18
  /******/ var __webpack_modules__ = ({
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/microphone/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"names":["MicrophonePlugin","params","ws","wavesurfer","active","paused","browser","detectBrowser","reloadBufferFunction","e","reloadBuffer","promisifiedOldGUM","constraints","successCallback","errorCallback","getUserMedia","navigator","webkitGetUserMedia","mozGetUserMedia","msGetUserMedia","Promise","reject","Error","call","mediaDevices","undefined","video","audio","bufferSize","numberOfInputChannels","numberOfOutputChannels","_onBackendCreated","micContext","backend","getAudioContext","on","un","stop","then","data","gotStream","catch","deviceError","start","pause","play","connect","disconnect","stopDevice","empty","stream","getTracks","forEach","localAudioBuffer","createBuffer","sampleRate","mediaStreamSource","createMediaStreamSource","levelChecker","createScriptProcessor","destination","onaudioprocess","event","channel","l","Math","min","numberOfChannels","inputBuffer","getChannelData","set","loadDecodedBuffer","fireEvent","code","uastring","expr","pos","match","length","parseInt","result","version","minVersion","window","extractVersion","userAgent","RTCPeerConnection","name","deferInit","instance"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD,O;;;;;;;;;;;;;;;;;;;;;;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AAC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;AACA;AACA;AACA;AACA;AACI,oBAAc/E,MAAd,EAAsB;AAClB,aAAO;AACHsF,YAAI,EAAE,YADH;AAEHC,iBAAS,EAAEvF,MAAM,IAAIA,MAAM,CAACuF,SAAjB,GAA6BvF,MAAM,CAACuF,SAApC,GAAgD,KAFxD;AAGHvF,cAAM,EAAEA,MAHL;AAIHwF,gBAAQ,EAAEzF;AAJP,OAAP;AAMH;;;;;;;;;;;;;UC1DL;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UCtBA;UACA;UACA;UACA","file":"wavesurfer.microphone.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"microphone\"] = factory();\n})(this, function() {\nreturn ","/**\n * @typedef {Object} MicrophonePluginParams\n * @property {MediaStreamConstraints} constraints The constraints parameter is a\n * MediaStreamConstaints object with two members: video and audio, describing\n * the media types requested. Either or both must be specified.\n * @property {number} bufferSize=4096 The buffer size in units of sample-frames.\n * If specified, the bufferSize must be one of the following values: `256`,\n * `512`, `1024`, `2048`, `4096`, `8192`, `16384`\n * @property {number} numberOfInputChannels=1 Integer specifying the number of\n * channels for this node's input. Values of up to 32 are supported.\n * @property {number} numberOfOutputChannels=1 Integer specifying the number of\n * channels for this node's output.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('microphone')`\n */\n\n/**\n * Visualize microphone input in a wavesurfer instance.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import MicrophonePlugin from 'wavesurfer.microphone.js';\n *\n * // commonjs\n * var MicrophonePlugin = require('wavesurfer.microphone.js');\n *\n * // if you are using <script> tags\n * var MicrophonePlugin = window.WaveSurfer.microphone;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MicrophonePlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class MicrophonePlugin {\n /**\n * Microphone plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MicrophonePluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'microphone',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: MicrophonePlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n\n this.active = false;\n this.paused = false;\n this.browser = this.detectBrowser();\n this.reloadBufferFunction = e => this.reloadBuffer(e);\n\n // cross-browser getUserMedia\n const promisifiedOldGUM = (\n constraints,\n successCallback,\n errorCallback\n ) => {\n // get a hold of getUserMedia, if present\n const getUserMedia =\n navigator.getUserMedia ||\n navigator.webkitGetUserMedia ||\n navigator.mozGetUserMedia ||\n navigator.msGetUserMedia;\n // Some browsers just don't implement it - return a rejected\n // promise with an error to keep a consistent interface\n if (!getUserMedia) {\n return Promise.reject(\n new Error('getUserMedia is not implemented in this browser')\n );\n }\n // otherwise, wrap the call to the old navigator.getUserMedia with\n // a Promise\n return new Promise((successCallback, errorCallback) => {\n getUserMedia.call(\n navigator,\n constraints,\n successCallback,\n errorCallback\n );\n });\n };\n // Older browsers might not implement mediaDevices at all, so we set an\n // empty object first\n if (navigator.mediaDevices === undefined) {\n navigator.mediaDevices = {};\n }\n // Some browsers partially implement mediaDevices. We can't just assign\n // an object with getUserMedia as it would overwrite existing\n // properties. Here, we will just add the getUserMedia property if it's\n // missing.\n if (navigator.mediaDevices.getUserMedia === undefined) {\n navigator.mediaDevices.getUserMedia = promisifiedOldGUM;\n }\n this.constraints = this.params.constraints || {\n video: false,\n audio: true\n };\n this.bufferSize = this.params.bufferSize || 4096;\n this.numberOfInputChannels = this.params.numberOfInputChannels || 1;\n this.numberOfOutputChannels = this.params.numberOfOutputChannels || 1;\n\n this._onBackendCreated = () => {\n // wavesurfer's AudioContext where we'll route the mic signal to\n this.micContext = this.wavesurfer.backend.getAudioContext();\n };\n }\n\n init() {\n this.wavesurfer.on('backend-created', this._onBackendCreated);\n if (this.wavesurfer.backend) {\n this._onBackendCreated();\n }\n }\n\n /**\n * Destroy the microphone plugin.\n */\n destroy() {\n // make sure the buffer is not redrawn during\n // cleanup and demolition of this plugin.\n this.paused = true;\n\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n this.stop();\n }\n\n /**\n * Allow user to select audio input device, e.g. microphone, and\n * start the visualization.\n */\n start() {\n navigator.mediaDevices\n .getUserMedia(this.constraints)\n .then(data => this.gotStream(data))\n .catch(data => this.deviceError(data));\n }\n\n /**\n * Pause/resume visualization.\n */\n togglePlay() {\n if (!this.active) {\n // start it first\n this.start();\n } else {\n // toggle paused\n this.paused = !this.paused;\n\n if (this.paused) {\n this.pause();\n } else {\n this.play();\n }\n }\n }\n\n /**\n * Play visualization.\n */\n play() {\n this.paused = false;\n\n this.connect();\n }\n\n /**\n * Pause visualization.\n */\n pause() {\n this.paused = true;\n\n // disconnect sources so they can be used elsewhere\n // (eg. during audio playback)\n this.disconnect();\n }\n\n /**\n * Stop the device stream and remove any remaining waveform drawing from\n * the wavesurfer canvas.\n */\n stop() {\n if (this.active) {\n // stop visualization and device\n this.stopDevice();\n\n // empty last frame\n this.wavesurfer.empty();\n }\n }\n\n /**\n * Stop the device and the visualization.\n */\n stopDevice() {\n this.active = false;\n\n // stop visualization\n this.disconnect();\n\n // stop stream from device\n if (this.stream && this.stream.getTracks) {\n this.stream.getTracks().forEach(stream => stream.stop());\n }\n }\n\n /**\n * Connect the media sources that feed the visualization.\n */\n connect() {\n if (this.stream !== undefined) {\n // Create a local buffer for data to be copied to the Wavesurfer buffer for Edge\n if (this.browser.browser === 'edge') {\n this.localAudioBuffer = this.micContext.createBuffer(\n this.numberOfInputChannels,\n this.bufferSize,\n this.micContext.sampleRate\n );\n }\n\n // Create an AudioNode from the stream.\n this.mediaStreamSource = this.micContext.createMediaStreamSource(\n this.stream\n );\n\n this.levelChecker = this.micContext.createScriptProcessor(\n this.bufferSize,\n this.numberOfInputChannels,\n this.numberOfOutputChannels\n );\n this.mediaStreamSource.connect(this.levelChecker);\n\n this.levelChecker.connect(this.micContext.destination);\n this.levelChecker.onaudioprocess = this.reloadBufferFunction;\n }\n }\n\n /**\n * Disconnect the media sources that feed the visualization.\n */\n disconnect() {\n if (this.mediaStreamSource !== undefined) {\n this.mediaStreamSource.disconnect();\n }\n\n if (this.levelChecker !== undefined) {\n this.levelChecker.disconnect();\n this.levelChecker.onaudioprocess = undefined;\n }\n\n if (this.localAudioBuffer !== undefined) {\n this.localAudioBuffer = undefined;\n }\n }\n\n /**\n * Redraw the waveform.\n *\n * @param {object} event Audioprocess event\n */\n reloadBuffer(event) {\n if (!this.paused) {\n this.wavesurfer.empty();\n\n if (this.browser.browser === 'edge') {\n // copy audio data to a local audio buffer,\n // from https://github.com/audiojs/audio-buffer-utils\n let channel, l;\n for (\n channel = 0,\n l = Math.min(\n this.localAudioBuffer.numberOfChannels,\n event.inputBuffer.numberOfChannels\n );\n channel < l;\n channel++\n ) {\n this.localAudioBuffer\n .getChannelData(channel)\n .set(event.inputBuffer.getChannelData(channel));\n }\n\n this.wavesurfer.loadDecodedBuffer(this.localAudioBuffer);\n } else {\n this.wavesurfer.loadDecodedBuffer(event.inputBuffer);\n }\n }\n }\n\n /**\n * Audio input device is ready.\n *\n * @param {MediaStream} stream The microphone's media stream.\n */\n gotStream(stream) {\n this.stream = stream;\n this.active = true;\n\n // start visualization\n this.play();\n\n // notify listeners\n this.fireEvent('deviceReady', stream);\n }\n\n /**\n * Device error callback.\n *\n * @param {string} code Error message\n */\n deviceError(code) {\n // notify listeners\n this.fireEvent('deviceError', code);\n }\n\n /**\n * Extract browser version out of the provided user agent string.\n * @param {!string} uastring userAgent string.\n * @param {!string} expr Regular expression used as match criteria.\n * @param {!number} pos position in the version string to be returned.\n * @return {!number} browser version.\n */\n extractVersion(uastring, expr, pos) {\n const match = uastring.match(expr);\n return match && match.length >= pos && parseInt(match[pos], 10);\n }\n\n /**\n * Browser detector.\n * @return {object} result containing browser, version and minVersion\n * properties.\n */\n detectBrowser() {\n // Returned result object.\n const result = {};\n result.browser = null;\n result.version = null;\n result.minVersion = null;\n\n // Non supported browser.\n if (typeof window === 'undefined' || !window.navigator) {\n result.browser = 'Not a supported browser.';\n return result;\n }\n\n if (navigator.mozGetUserMedia) {\n // Firefox\n result.browser = 'firefox';\n result.version = this.extractVersion(\n navigator.userAgent,\n /Firefox\\/(\\d+)\\./,\n 1\n );\n result.minVersion = 31;\n return result;\n } else if (navigator.webkitGetUserMedia) {\n // Chrome/Chromium/Webview/Opera\n result.browser = 'chrome';\n result.version = this.extractVersion(\n navigator.userAgent,\n /Chrom(e|ium)\\/(\\d+)\\./,\n 2\n );\n result.minVersion = 38;\n return result;\n } else if (\n navigator.mediaDevices &&\n navigator.userAgent.match(/Edge\\/(\\d+).(\\d+)$/)\n ) {\n // Edge\n result.browser = 'edge';\n result.version = this.extractVersion(\n navigator.userAgent,\n /Edge\\/(\\d+).(\\d+)$/,\n 2\n );\n result.minVersion = 10547;\n return result;\n } else if (\n window.RTCPeerConnection &&\n navigator.userAgent.match(/AppleWebKit\\/(\\d+)\\./)\n ) {\n // Safari\n result.browser = 'safari';\n result.minVersion = 11;\n result.version = this.extractVersion(\n navigator.userAgent,\n /AppleWebKit\\/(\\d+)\\./,\n 1\n );\n return result;\n }\n\n // Non supported browser default.\n result.browser = 'Not a supported browser.';\n return result;\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/plugin/microphone/index.js\");\n"],"sourceRoot":""}
1
+ {"version":3,"file":"wavesurfer.microphone.js","mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD;;;;;;;;;;;;;;;;;;;;;;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACqBA;AAmBjB,4BAAYC,MAAZ,EAAoBC,EAApB,EAAwB;AAAA;;AAAA;;AACpB,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,UAAL,GAAkBD,EAAlB;AAEA,SAAKE,MAAL,GAAc,KAAd;AACA,SAAKC,MAAL,GAAc,KAAd;AACA,SAAKC,OAAL,GAAe,KAAKC,aAAL,EAAf;;AACA,SAAKC,oBAAL,GAA4B,UAAAC,CAAC;AAAA,aAAI,KAAI,CAACC,YAAL,CAAkBD,CAAlB,CAAJ;AAAA,KAA7B,CAPoB,CASpB;;;AACA,QAAME,iBAAiB,GAAG,SAApBA,iBAAoB,CACtBC,WADsB,EAEtBC,eAFsB,EAGtBC,aAHsB,EAIrB;AACD;AACA,UAAMC,YAAY,GACdC,SAAS,CAACD,YAAV,IACAC,SAAS,CAAC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er.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/microphone/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/before-startup","webpack://WaveSurfer.[name]/webpack/startup","webpack://WaveSurfer.[name]/webpack/after-startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"microphone\"] = factory();\n})(self, function() {\nreturn ","/**\n * @typedef {Object} MicrophonePluginParams\n * @property {MediaStreamConstraints} constraints The constraints parameter is a\n * MediaStreamConstaints object with two members: video and audio, describing\n * the media types requested. Either or both must be specified.\n * @property {number} bufferSize=4096 The buffer size in units of sample-frames.\n * If specified, the bufferSize must be one of the following values: `256`,\n * `512`, `1024`, `2048`, `4096`, `8192`, `16384`\n * @property {number} numberOfInputChannels=1 Integer specifying the number of\n * channels for this node's input. Values of up to 32 are supported.\n * @property {number} numberOfOutputChannels=1 Integer specifying the number of\n * channels for this node's output.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('microphone')`\n */\n\n/**\n * Visualize microphone input in a wavesurfer instance.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import MicrophonePlugin from 'wavesurfer.microphone.js';\n *\n * // commonjs\n * var MicrophonePlugin = require('wavesurfer.microphone.js');\n *\n * // if you are using <script> tags\n * var MicrophonePlugin = window.WaveSurfer.microphone;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MicrophonePlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class MicrophonePlugin {\n /**\n * Microphone plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MicrophonePluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'microphone',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: MicrophonePlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n\n this.active = false;\n this.paused = false;\n this.browser = this.detectBrowser();\n this.reloadBufferFunction = e => this.reloadBuffer(e);\n\n // cross-browser getUserMedia\n const promisifiedOldGUM = (\n constraints,\n successCallback,\n errorCallback\n ) => {\n // get a hold of getUserMedia, if present\n const getUserMedia =\n navigator.getUserMedia ||\n navigator.webkitGetUserMedia ||\n navigator.mozGetUserMedia ||\n navigator.msGetUserMedia;\n // Some browsers just don't implement it - return a rejected\n // promise with an error to keep a consistent interface\n if (!getUserMedia) {\n return Promise.reject(\n new Error('getUserMedia is not implemented in this browser')\n );\n }\n // otherwise, wrap the call to the old navigator.getUserMedia with\n // a Promise\n return new Promise((successCallback, errorCallback) => {\n getUserMedia.call(\n navigator,\n constraints,\n successCallback,\n errorCallback\n );\n });\n };\n // Older browsers might not implement mediaDevices at all, so we set an\n // empty object first\n if (navigator.mediaDevices === undefined) {\n navigator.mediaDevices = {};\n }\n // Some browsers partially implement mediaDevices. We can't just assign\n // an object with getUserMedia as it would overwrite existing\n // properties. Here, we will just add the getUserMedia property if it's\n // missing.\n if (navigator.mediaDevices.getUserMedia === undefined) {\n navigator.mediaDevices.getUserMedia = promisifiedOldGUM;\n }\n this.constraints = this.params.constraints || {\n video: false,\n audio: true\n };\n this.bufferSize = this.params.bufferSize || 4096;\n this.numberOfInputChannels = this.params.numberOfInputChannels || 1;\n this.numberOfOutputChannels = this.params.numberOfOutputChannels || 1;\n\n this._onBackendCreated = () => {\n // wavesurfer's AudioContext where we'll route the mic signal to\n this.micContext = this.wavesurfer.backend.getAudioContext();\n };\n }\n\n init() {\n this.wavesurfer.on('backend-created', this._onBackendCreated);\n if (this.wavesurfer.backend) {\n this._onBackendCreated();\n }\n }\n\n /**\n * Destroy the microphone plugin.\n */\n destroy() {\n // make sure the buffer is not redrawn during\n // cleanup and demolition of this plugin.\n this.paused = true;\n\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n this.stop();\n }\n\n /**\n * Allow user to select audio input device, e.g. microphone, and\n * start the visualization.\n */\n start() {\n navigator.mediaDevices\n .getUserMedia(this.constraints)\n .then(data => this.gotStream(data))\n .catch(data => this.deviceError(data));\n }\n\n /**\n * Pause/resume visualization.\n */\n togglePlay() {\n if (!this.active) {\n // start it first\n this.start();\n } else {\n // toggle paused\n this.paused = !this.paused;\n\n if (this.paused) {\n this.pause();\n } else {\n this.play();\n }\n }\n }\n\n /**\n * Play visualization.\n */\n play() {\n this.paused = false;\n\n this.connect();\n }\n\n /**\n * Pause visualization.\n */\n pause() {\n this.paused = true;\n\n // disconnect sources so they can be used elsewhere\n // (eg. during audio playback)\n this.disconnect();\n }\n\n /**\n * Stop the device stream and remove any remaining waveform drawing from\n * the wavesurfer canvas.\n */\n stop() {\n if (this.active) {\n // stop visualization and device\n this.stopDevice();\n\n // empty last frame\n this.wavesurfer.empty();\n }\n }\n\n /**\n * Stop the device and the visualization.\n */\n stopDevice() {\n this.active = false;\n\n // stop visualization\n this.disconnect();\n\n // stop stream from device\n if (this.stream && this.stream.getTracks) {\n this.stream.getTracks().forEach(stream => stream.stop());\n }\n }\n\n /**\n * Connect the media sources that feed the visualization.\n */\n connect() {\n if (this.stream !== undefined) {\n // Create a local buffer for data to be copied to the Wavesurfer buffer for Edge\n if (this.browser.browser === 'edge') {\n this.localAudioBuffer = this.micContext.createBuffer(\n this.numberOfInputChannels,\n this.bufferSize,\n this.micContext.sampleRate\n );\n }\n\n // Create an AudioNode from the stream.\n this.mediaStreamSource = this.micContext.createMediaStreamSource(\n this.stream\n );\n\n this.levelChecker = this.micContext.createScriptProcessor(\n this.bufferSize,\n this.numberOfInputChannels,\n this.numberOfOutputChannels\n );\n this.mediaStreamSource.connect(this.levelChecker);\n\n this.levelChecker.connect(this.micContext.destination);\n this.levelChecker.onaudioprocess = this.reloadBufferFunction;\n }\n }\n\n /**\n * Disconnect the media sources that feed the visualization.\n */\n disconnect() {\n if (this.mediaStreamSource !== undefined) {\n this.mediaStreamSource.disconnect();\n }\n\n if (this.levelChecker !== undefined) {\n this.levelChecker.disconnect();\n this.levelChecker.onaudioprocess = undefined;\n }\n\n if (this.localAudioBuffer !== undefined) {\n this.localAudioBuffer = undefined;\n }\n }\n\n /**\n * Redraw the waveform.\n *\n * @param {object} event Audioprocess event\n */\n reloadBuffer(event) {\n if (!this.paused) {\n this.wavesurfer.empty();\n\n if (this.browser.browser === 'edge') {\n // copy audio data to a local audio buffer,\n // from https://github.com/audiojs/audio-buffer-utils\n let channel, l;\n for (\n channel = 0,\n l = Math.min(\n this.localAudioBuffer.numberOfChannels,\n event.inputBuffer.numberOfChannels\n );\n channel < l;\n channel++\n ) {\n this.localAudioBuffer\n .getChannelData(channel)\n .set(event.inputBuffer.getChannelData(channel));\n }\n\n this.wavesurfer.loadDecodedBuffer(this.localAudioBuffer);\n } else {\n this.wavesurfer.loadDecodedBuffer(event.inputBuffer);\n }\n }\n }\n\n /**\n * Audio input device is ready.\n *\n * @param {MediaStream} stream The microphone's media stream.\n */\n gotStream(stream) {\n this.stream = stream;\n this.active = true;\n\n // start visualization\n this.play();\n\n // notify listeners\n this.fireEvent('deviceReady', stream);\n }\n\n /**\n * Device error callback.\n *\n * @param {string} code Error message\n */\n deviceError(code) {\n // notify listeners\n this.fireEvent('deviceError', code);\n }\n\n /**\n * Extract browser version out of the provided user agent string.\n * @param {!string} uastring userAgent string.\n * @param {!string} expr Regular expression used as match criteria.\n * @param {!number} pos position in the version string to be returned.\n * @return {!number} browser version.\n */\n extractVersion(uastring, expr, pos) {\n const match = uastring.match(expr);\n return match && match.length >= pos && parseInt(match[pos], 10);\n }\n\n /**\n * Browser detector.\n * @return {object} result containing browser, version and minVersion\n * properties.\n */\n detectBrowser() {\n // Returned result object.\n const result = {};\n result.browser = null;\n result.version = null;\n result.minVersion = null;\n\n // Non supported browser.\n if (typeof window === 'undefined' || !window.navigator) {\n result.browser = 'Not a supported browser.';\n return result;\n }\n\n if (navigator.mozGetUserMedia) {\n // Firefox\n result.browser = 'firefox';\n result.version = this.extractVersion(\n navigator.userAgent,\n /Firefox\\/(\\d+)\\./,\n 1\n );\n result.minVersion = 31;\n return result;\n } else if (navigator.webkitGetUserMedia) {\n // Chrome/Chromium/Webview/Opera\n result.browser = 'chrome';\n result.version = this.extractVersion(\n navigator.userAgent,\n /Chrom(e|ium)\\/(\\d+)\\./,\n 2\n );\n result.minVersion = 38;\n return result;\n } else if (\n navigator.mediaDevices &&\n navigator.userAgent.match(/Edge\\/(\\d+).(\\d+)$/)\n ) {\n // Edge\n result.browser = 'edge';\n result.version = this.extractVersion(\n navigator.userAgent,\n /Edge\\/(\\d+).(\\d+)$/,\n 2\n );\n result.minVersion = 10547;\n return result;\n } else if (\n window.RTCPeerConnection &&\n navigator.userAgent.match(/AppleWebKit\\/(\\d+)\\./)\n ) {\n // Safari\n result.browser = 'safari';\n result.minVersion = 11;\n result.version = this.extractVersion(\n navigator.userAgent,\n /AppleWebKit\\/(\\d+)\\./,\n 1\n );\n return result;\n }\n\n // Non supported browser default.\n result.browser = 'Not a supported browser.';\n return result;\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/plugin/microphone/index.js\");\n",""],"names":["MicrophonePlugin","params","ws","wavesurfer","active","paused","browser","detectBrowser","reloadBufferFunction","e","reloadBuffer","promisifiedOldGUM","constraints","successCallback","errorCallback","getUserMedia","navigator","webkitGetUserMedia","mozGetUserMedia","msGetUserMedia","Promise","reject","Error","call","mediaDevices","undefined","video","audio","bufferSize","numberOfInputChannels","numberOfOutputChannels","_onBackendCreated","micContext","backend","getAudioContext","on","un","stop","then","data","gotStream","catch","deviceError","start","pause","play","connect","disconnect","stopDevice","empty","stream","getTracks","forEach","localAudioBuffer","createBuffer","sampleRate","mediaStreamSource","createMediaStreamSource","levelChecker","createScriptProcessor","destination","onaudioprocess","event","channel","l","Math","min","numberOfChannels","inputBuffer","getChannelData","set","loadDecodedBuffer","fireEvent","code","uastring","expr","pos","match","length","parseInt","result","version","minVersion","window","extractVersion","userAgent","RTCPeerConnection","name","deferInit","instance"],"sourceRoot":""}
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * wavesurfer.js microphone plugin 5.1.0 (2021-06-20)
2
+ * wavesurfer.js microphone plugin 5.2.0 (2021-08-16)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
6
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.microphone=t())}(this,(function(){return(()=>{"use strict";var e={872:(e,t)=>{function r(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)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(){function e(t,r){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=t,this.wavesurfer=r,this.active=!1,this.paused=!1,this.browser=this.detectBrowser(),this.reloadBufferFunction=function(e){return i.reloadBuffer(e)};void 0===navigator.mediaDevices&&(navigator.mediaDevices={}),void 0===navigator.mediaDevices.getUserMedia&&(navigator.mediaDevices.getUserMedia=function(e,t,r){var i=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;return i?new Promise((function(t,r){i.call(navigator,e,t,r)})):Promise.reject(new Error("getUserMedia is not implemented in this browser"))}),this.constraints=this.params.constraints||{video:!1,audio:!0},this.bufferSize=this.params.bufferSize||4096,this.numberOfInputChannels=this.params.numberOfInputChannels||1,this.numberOfOutputChannels=this.params.numberOfOutputChannels||1,this._onBackendCreated=function(){i.micContext=i.wavesurfer.backend.getAudioContext()}}var t,i,n;return t=e,n=[{key:"create",value:function(t){return{name:"microphone",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,instance:e}}}],(i=[{key:"init",value:function(){this.wavesurfer.on("backend-created",this._onBackendCreated),this.wavesurfer.backend&&this._onBackendCreated()}},{key:"destroy",value:function(){this.paused=!0,this.wavesurfer.un("backend-created",this._onBackendCreated),this.stop()}},{key:"start",value:function(){var e=this;navigator.mediaDevices.getUserMedia(this.constraints).then((function(t){return e.gotStream(t)})).catch((function(t){return e.deviceError(t)}))}},{key:"togglePlay",value:function(){this.active?(this.paused=!this.paused,this.paused?this.pause():this.play()):this.start()}},{key:"play",value:function(){this.paused=!1,this.connect()}},{key:"pause",value:function(){this.paused=!0,this.disconnect()}},{key:"stop",value:function(){this.active&&(this.stopDevice(),this.wavesurfer.empty())}},{key:"stopDevice",value:function(){this.active=!1,this.disconnect(),this.stream&&this.stream.getTracks&&this.stream.getTracks().forEach((function(e){return e.stop()}))}},{key:"connect",value:function(){void 0!==this.stream&&("edge"===this.browser.browser&&(this.localAudioBuffer=this.micContext.createBuffer(this.numberOfInputChannels,this.bufferSize,this.micContext.sampleRate)),this.mediaStreamSource=this.micContext.createMediaStreamSource(this.stream),this.levelChecker=this.micContext.createScriptProcessor(this.bufferSize,this.numberOfInputChannels,this.numberOfOutputChannels),this.mediaStreamSource.connect(this.levelChecker),this.levelChecker.connect(this.micContext.destination),this.levelChecker.onaudioprocess=this.reloadBufferFunction)}},{key:"disconnect",value:function(){void 0!==this.mediaStreamSource&&this.mediaStreamSource.disconnect(),void 0!==this.levelChecker&&(this.levelChecker.disconnect(),this.levelChecker.onaudioprocess=void 0),void 0!==this.localAudioBuffer&&(this.localAudioBuffer=void 0)}},{key:"reloadBuffer",value:function(e){if(!this.paused)if(this.wavesurfer.empty(),"edge"===this.browser.browser){var t,r;for(t=0,r=Math.min(this.localAudioBuffer.numberOfChannels,e.inputBuffer.numberOfChannels);t<r;t++)this.localAudioBuffer.getChannelData(t).set(e.inputBuffer.getChannelData(t));this.wavesurfer.loadDecodedBuffer(this.localAudioBuffer)}else this.wavesurfer.loadDecodedBuffer(e.inputBuffer)}},{key:"gotStream",value:function(e){this.stream=e,this.active=!0,this.play(),this.fireEvent("deviceReady",e)}},{key:"deviceError",value:function(e){this.fireEvent("deviceError",e)}},{key:"extractVersion",value:function(e,t,r){var i=e.match(t);return i&&i.length>=r&&parseInt(i[r],10)}},{key:"detectBrowser",value:function(){var e={browser:null,version:null,minVersion:null};return"undefined"!=typeof window&&window.navigator?navigator.mozGetUserMedia?(e.browser="firefox",e.version=this.extractVersion(navigator.userAgent,/Firefox\/(\d+)\./,1),e.minVersion=31,e):navigator.webkitGetUserMedia?(e.browser="chrome",e.version=this.extractVersion(navigator.userAgent,/Chrom(e|ium)\/(\d+)\./,2),e.minVersion=38,e):navigator.mediaDevices&&navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)?(e.browser="edge",e.version=this.extractVersion(navigator.userAgent,/Edge\/(\d+).(\d+)$/,2),e.minVersion=10547,e):window.RTCPeerConnection&&navigator.userAgent.match(/AppleWebKit\/(\d+)\./)?(e.browser="safari",e.minVersion=11,e.version=this.extractVersion(navigator.userAgent,/AppleWebKit\/(\d+)\./,1),e):(e.browser="Not a supported browser.",e):(e.browser="Not a supported browser.",e)}}])&&r(t.prototype,i),n&&r(t,n),e}();t.default=i,e.exports=t.default}},t={};return function r(i){var n=t[i];if(void 0!==n)return n.exports;var s=t[i]={exports:{}};return e[i](s,s.exports,r),s.exports}(872)})()}));
6
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.microphone=t())}(self,(function(){return(()=>{"use strict";var e={872:(e,t)=>{function r(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)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(){function e(t,r){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=t,this.wavesurfer=r,this.active=!1,this.paused=!1,this.browser=this.detectBrowser(),this.reloadBufferFunction=function(e){return i.reloadBuffer(e)};void 0===navigator.mediaDevices&&(navigator.mediaDevices={}),void 0===navigator.mediaDevices.getUserMedia&&(navigator.mediaDevices.getUserMedia=function(e,t,r){var i=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;return i?new Promise((function(t,r){i.call(navigator,e,t,r)})):Promise.reject(new Error("getUserMedia is not implemented in this browser"))}),this.constraints=this.params.constraints||{video:!1,audio:!0},this.bufferSize=this.params.bufferSize||4096,this.numberOfInputChannels=this.params.numberOfInputChannels||1,this.numberOfOutputChannels=this.params.numberOfOutputChannels||1,this._onBackendCreated=function(){i.micContext=i.wavesurfer.backend.getAudioContext()}}var t,i,n;return t=e,n=[{key:"create",value:function(t){return{name:"microphone",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,instance:e}}}],(i=[{key:"init",value:function(){this.wavesurfer.on("backend-created",this._onBackendCreated),this.wavesurfer.backend&&this._onBackendCreated()}},{key:"destroy",value:function(){this.paused=!0,this.wavesurfer.un("backend-created",this._onBackendCreated),this.stop()}},{key:"start",value:function(){var e=this;navigator.mediaDevices.getUserMedia(this.constraints).then((function(t){return e.gotStream(t)})).catch((function(t){return e.deviceError(t)}))}},{key:"togglePlay",value:function(){this.active?(this.paused=!this.paused,this.paused?this.pause():this.play()):this.start()}},{key:"play",value:function(){this.paused=!1,this.connect()}},{key:"pause",value:function(){this.paused=!0,this.disconnect()}},{key:"stop",value:function(){this.active&&(this.stopDevice(),this.wavesurfer.empty())}},{key:"stopDevice",value:function(){this.active=!1,this.disconnect(),this.stream&&this.stream.getTracks&&this.stream.getTracks().forEach((function(e){return e.stop()}))}},{key:"connect",value:function(){void 0!==this.stream&&("edge"===this.browser.browser&&(this.localAudioBuffer=this.micContext.createBuffer(this.numberOfInputChannels,this.bufferSize,this.micContext.sampleRate)),this.mediaStreamSource=this.micContext.createMediaStreamSource(this.stream),this.levelChecker=this.micContext.createScriptProcessor(this.bufferSize,this.numberOfInputChannels,this.numberOfOutputChannels),this.mediaStreamSource.connect(this.levelChecker),this.levelChecker.connect(this.micContext.destination),this.levelChecker.onaudioprocess=this.reloadBufferFunction)}},{key:"disconnect",value:function(){void 0!==this.mediaStreamSource&&this.mediaStreamSource.disconnect(),void 0!==this.levelChecker&&(this.levelChecker.disconnect(),this.levelChecker.onaudioprocess=void 0),void 0!==this.localAudioBuffer&&(this.localAudioBuffer=void 0)}},{key:"reloadBuffer",value:function(e){if(!this.paused)if(this.wavesurfer.empty(),"edge"===this.browser.browser){var t,r;for(t=0,r=Math.min(this.localAudioBuffer.numberOfChannels,e.inputBuffer.numberOfChannels);t<r;t++)this.localAudioBuffer.getChannelData(t).set(e.inputBuffer.getChannelData(t));this.wavesurfer.loadDecodedBuffer(this.localAudioBuffer)}else this.wavesurfer.loadDecodedBuffer(e.inputBuffer)}},{key:"gotStream",value:function(e){this.stream=e,this.active=!0,this.play(),this.fireEvent("deviceReady",e)}},{key:"deviceError",value:function(e){this.fireEvent("deviceError",e)}},{key:"extractVersion",value:function(e,t,r){var i=e.match(t);return i&&i.length>=r&&parseInt(i[r],10)}},{key:"detectBrowser",value:function(){var e={browser:null,version:null,minVersion:null};return"undefined"!=typeof window&&window.navigator?navigator.mozGetUserMedia?(e.browser="firefox",e.version=this.extractVersion(navigator.userAgent,/Firefox\/(\d+)\./,1),e.minVersion=31,e):navigator.webkitGetUserMedia?(e.browser="chrome",e.version=this.extractVersion(navigator.userAgent,/Chrom(e|ium)\/(\d+)\./,2),e.minVersion=38,e):navigator.mediaDevices&&navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)?(e.browser="edge",e.version=this.extractVersion(navigator.userAgent,/Edge\/(\d+).(\d+)$/,2),e.minVersion=10547,e):window.RTCPeerConnection&&navigator.userAgent.match(/AppleWebKit\/(\d+)\./)?(e.browser="safari",e.minVersion=11,e.version=this.extractVersion(navigator.userAgent,/AppleWebKit\/(\d+)\./,1),e):(e.browser="Not a supported browser.",e):(e.browser="Not a supported browser.",e)}}])&&r(t.prototype,i),n&&r(t,n),e}();t.default=i,e.exports=t.default}},t={};return function r(i){var n=t[i];if(void 0!==n)return n.exports;var s=t[i]={exports:{}};return e[i](s,s.exports,r),s.exports}(872)})()}));
7
7
  //# sourceMappingURL=wavesurfer.microphone.min.js.map