wavesurfer.js 6.2.0 → 6.3.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.
- package/CHANGES.md +8 -0
- package/LICENSE +1 -1
- package/README.md +0 -10
- package/dist/plugin/wavesurfer.cursor.js +1 -1
- package/dist/plugin/wavesurfer.cursor.min.js +1 -1
- package/dist/plugin/wavesurfer.cursor.min.js.map +1 -1
- package/dist/plugin/wavesurfer.elan.js +1 -1
- package/dist/plugin/wavesurfer.elan.min.js +1 -1
- package/dist/plugin/wavesurfer.elan.min.js.map +1 -1
- package/dist/plugin/wavesurfer.markers.js +41 -6
- package/dist/plugin/wavesurfer.markers.js.map +1 -1
- package/dist/plugin/wavesurfer.markers.min.js +2 -2
- package/dist/plugin/wavesurfer.markers.min.js.map +1 -1
- package/dist/plugin/wavesurfer.mediasession.js +1 -1
- package/dist/plugin/wavesurfer.mediasession.min.js +1 -1
- package/dist/plugin/wavesurfer.mediasession.min.js.map +1 -1
- package/dist/plugin/wavesurfer.microphone.js +1 -1
- package/dist/plugin/wavesurfer.microphone.min.js +1 -1
- package/dist/plugin/wavesurfer.microphone.min.js.map +1 -1
- package/dist/plugin/wavesurfer.minimap.js +1 -1
- package/dist/plugin/wavesurfer.minimap.min.js +1 -1
- package/dist/plugin/wavesurfer.minimap.min.js.map +1 -1
- package/dist/plugin/wavesurfer.playhead.js +1 -1
- package/dist/plugin/wavesurfer.playhead.min.js +1 -1
- package/dist/plugin/wavesurfer.playhead.min.js.map +1 -1
- package/dist/plugin/wavesurfer.regions.js +2 -2
- package/dist/plugin/wavesurfer.regions.js.map +1 -1
- package/dist/plugin/wavesurfer.regions.min.js +2 -2
- package/dist/plugin/wavesurfer.regions.min.js.map +1 -1
- package/dist/plugin/wavesurfer.spectrogram.js +2 -2
- package/dist/plugin/wavesurfer.spectrogram.js.map +1 -1
- package/dist/plugin/wavesurfer.spectrogram.min.js +2 -2
- package/dist/plugin/wavesurfer.spectrogram.min.js.map +1 -1
- package/dist/plugin/wavesurfer.timeline.js +1 -1
- package/dist/plugin/wavesurfer.timeline.min.js +1 -1
- package/dist/plugin/wavesurfer.timeline.min.js.map +1 -1
- package/dist/wavesurfer-html-init.js +1 -1
- package/dist/wavesurfer-html-init.js.map +1 -1
- package/dist/wavesurfer-html-init.min.js +1 -1
- package/dist/wavesurfer-html-init.min.js.map +1 -1
- package/dist/wavesurfer.js +32 -29
- package/dist/wavesurfer.js.map +1 -1
- package/dist/wavesurfer.min.js +2 -2
- package/dist/wavesurfer.min.js.map +1 -1
- package/package.json +18 -19
- package/src/drawer.multicanvas.js +4 -4
- package/src/plugin/markers/index.js +31 -5
- package/src/plugin/regions/index.js +1 -1
- package/src/plugin/spectrogram/index.js +1 -1
- package/src/wavesurfer.js +12 -9
|
@@ -1 +1 @@
|
|
|
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,QAAoB,WAAID,KAExBD,EAAiB,WAAIA,EAAiB,YAAK,GAAIA,EAAiB,WAAW,QAAIC,KARjF,CASGK,MAAM,IACT,M,wQCyBA,IAGqBC,EAAAA,WAuCjB,WAAYC,EAAQC,GAAI,Y,4FAAA,SACpBC,KAAKF,OAASA,EACdE,KAAKC,WAAaF,EAClBC,KAAKE,KAAOH,EAAGG,KACfF,KAAKG,MAAQH,KAAKE,KAAKC,MACvBH,KAAKI,gBAAkB,EACvBJ,KAAKK,YAAc,GACnBL,KAAKM,aAAe,GACpBN,KAAKO,UAAW,EAGhBP,KAAKQ,UAAY,WACb,EAAKC,0BAGTT,KAAKU,kBAAoB,WACrB,EAAKC,QAAU,EAAKV,WAAWW,OAAOD,QAClC,EAAKb,OAAOe,SACZ,EAAKf,OAAOe,QAAQC,SAAQ,SAAA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AAO+C,MACvB3D,KAAKC,WAAWH,OAAOuF,WAGrBC,EAAWF,EADGG,KAAKC,IAAI1F,EAAO4C,KAAOwC,EAAU,GACNpF,EAAOoE,OACtDlE,KAAKG,MAAML,EAAOgD,GAAI,CAClB,KAAQwC,EAAS,KACjB,YAAcF,EAAeE,EAAU,S,0BAa/C,SAAaG,GACJzF,KAAK8E,iBAGL9E,KAAKO,WACNP,KAAKO,UAAW,EAChBP,KAAKC,WAAW4E,UAAU,cAAe7E,KAAK8E,eAAgBW,IAElEzF,KAAK8E,eAAepC,KAAO1C,KAAKC,WAAWW,OAAO8E,YAAYD,GAASzF,KAAKC,WAAWkF,cACvFnF,KAAKS,4B,wBAUT,SAAWgF,GAAO,WAQd,GAPIzF,KAAK8E,gBACLa,YAAW,WACP,EAAKb,gBAAiB,EACtB,EAAKvE,UAAW,IACjB,GAGFP,KAAKO,SAAV,CAIAkF,EAAMd,kBACN,IAAMO,EAAWlF,KAAKC,WAAWkF,cACjCnF,KAAK8E,eAAepC,KAAO1C,KAAKC,WAAWW,OAAO8E,YAAYD,GAASP,EACvElF,KAAKS,yBACLT,KAAKC,WAAW4E,UAAU,cAAe7E,KAAK8E,eAAgBW,M,mBAMlE,WACI,KAAQzF,KAAKa,QAAQmE,OAAS,GAC1BhF,KAAK4F,OAAO,Q,gFAzUH/F,G,kCCrCjBgG,EAA2B,GCE/B,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAazG,QAGrB,IAAIC,EAASoG,EAAyBG,GAAY,CAGjDxG,QAAS,IAOV,OAHA2G,EAAoBH,GAAUvG,EAAQA,EAAOD,QAASuG,GAG/CtG,EAAOD,QClBWuG,CAAoB,K,UHO9C","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/markers/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/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, () => {\nreturn ","/**\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 * @property {?draggable} boolean Set marker as draggable, defaults to false\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 * @fires MarkersPlugin#marker-drag\n * @fires MarkersPlugin#marker-drop\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.markerLineWidth = 1;\n this.markerWidth = 11;\n this.markerHeight = 22;\n this.dragging = false;\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 if (!this.markers.find(marker => marker.draggable)){\n return;\n }\n\n this.onMouseMove = (e) => this._onMouseMove(e);\n window.addEventListener('mousemove', this.onMouseMove);\n\n this.onMouseUp = (e) => this._onMouseUp(e);\n window.addEventListener(\"mouseup\", this.onMouseUp);\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 if (this.onMouseMove) {\n window.removeEventListener('mousemove', this.onMouseMove);\n }\n if (this.onMouseUp) {\n window.removeEventListener(\"mouseup\", this.onMouseUp);\n }\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 draggable: !!params.draggable\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\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 const width = markerElement ? markerElement.width : this.markerWidth;\n marker.offset = (width - this.markerLineWidth) / 2;\n this.style(line, {\n \"flex-grow\": 1,\n \"margin-left\": marker.offset + \"px\",\n background: \"black\",\n width: this.markerLineWidth + \"px\",\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 if (marker.draggable){\n point.draggable = false;\n }\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 // Click event is caught when the marker-drop event was dispatched.\n // Drop event was dispatched at this moment, but this.dragging\n // is waiting for the next tick to set as false\n if (this.dragging){\n return;\n }\n this.wavesurfer.setCurrentTime(marker.time);\n this.wavesurfer.fireEvent(\"marker-click\", marker, e);\n });\n\n if (marker.draggable) {\n labelDiv.addEventListener(\"mousedown\", e => {\n this.selectedMarker = marker;\n });\n }\n return el;\n }\n\n _updateMarkerPositions() {\n for ( let i = 0 ; i < this.markers.length; i++ ) {\n let marker = this.markers[i];\n this._updateMarkerPosition(marker);\n }\n }\n\n /**\n * Update a marker position based on its time property.\n *\n * @private\n * @param {MarkerParams} params The marker to update.\n * @returns {void}\n */\n _updateMarkerPosition(params) {\n const duration = this.wavesurfer.getDuration();\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n\n const positionPct = Math.min(params.time / duration, 1);\n const leftPx = ((elementWidth * positionPct) - params.offset);\n this.style(params.el, {\n \"left\": leftPx + \"px\",\n \"max-width\": (elementWidth - leftPx) + \"px\"\n });\n }\n\n /**\n * Fires `marker-drag` event, update the `time` property for the\n * selected marker based on the mouse position, and calls to update\n * its position.\n *\n * @private\n * @param {MouseEvent} event The mouse event.\n * @returns {void}\n */\n _onMouseMove(event) {\n if (!this.selectedMarker){\n return;\n }\n if (!this.dragging){\n this.dragging = true;\n this.wavesurfer.fireEvent(\"marker-drag\", this.selectedMarker, event);\n }\n this.selectedMarker.time = this.wavesurfer.drawer.handleEvent(event) * this.wavesurfer.getDuration();\n this._updateMarkerPositions();\n }\n\n /**\n * Fires `marker-drop` event and unselect the dragged marker.\n *\n * @private\n * @param {MouseEvent} event The mouse event.\n * @returns {void}\n */\n _onMouseUp(event) {\n if (this.selectedMarker) {\n setTimeout(() => {\n this.selectedMarker = false;\n this.dragging = false;\n }, 0);\n }\n\n if (!this.dragging) {\n return;\n }\n\n event.stopPropagation();\n const duration = this.wavesurfer.getDuration();\n this.selectedMarker.time = this.wavesurfer.drawer.handleEvent(event) * duration;\n this._updateMarkerPositions();\n this.wavesurfer.fireEvent(\"marker-drop\", this.selectedMarker, event);\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","markerLineWidth","markerWidth","markerHeight","dragging","_onResize","_updateMarkerPositions","_onBackendCreated","wrapper","drawer","markers","forEach","marker","add","window","addEventListener","on","find","draggable","onMouseMove","e","_onMouseMove","onMouseUp","_onMouseUp","_onReady","name","deferInit","staticProps","addMarker","options","initialisedPluginList","initPlugin","clearMarkers","clear","instance","isReady","once","un","removeEventListener","time","label","color","position","el","_createMarkerElement","markerElement","appendChild","push","index","removeChild","splice","svgNS","document","createElementNS","polygon","setAttribute","width","height","createElement","className","display","overflow","line","offset","background","opacity","labelDiv","point","_createPointerSVG","labelEl","innerText","cursor","stopPropagation","setCurrentTime","fireEvent","selectedMarker","i","length","_updateMarkerPosition","duration","getDuration","elementWidth","pixelRatio","leftPx","Math","min","event","handleEvent","setTimeout","remove","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"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,QAAoB,WAAID,KAExBD,EAAiB,WAAIA,EAAiB,YAAK,CAAC,EAAGA,EAAiB,WAAW,QAAIC,IAChF,CATD,CASGK,MAAM,IACT,M,wQC2BA,IAGqBC,EAAAA,WAuCjB,WAAYC,EAAQC,GAAI,Y,4FAAA,SACpBC,KAAKF,OAASA,EACdE,KAAKC,WAAaF,EAClBC,KAAKE,KAAOH,EAAGG,KACfF,KAAKG,MAAQH,KAAKE,KAAKC,MACvBH,KAAKI,gBAAkB,EACvBJ,KAAKK,YAAc,GACnBL,KAAKM,aAAe,GACpBN,KAAKO,UAAW,EAGhBP,KAAKQ,UAAY,WACb,EAAKC,wBACR,EAEDT,KAAKU,kBAAoB,WACrB,EAAKC,QAAU,EAAKV,WAAWW,OAAOD,QAClC,EAAKb,OAAOe,SACZ,EAAKf,OAAOe,QAAQC,SAAQ,SAAAC,GAAM,OAAI,EAAKC,IAAID,EAAb,IAEtCE,OAAOC,iBAAiB,SAAU,EAAKV,WAAW,GAClDS,OAAOC,iBAAiB,oBAAqB,EAAKV,WAAW,GAC7D,EAAKP,WAAWkB,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qF,eAAgBW,EAN7D,CAOJ,G,mBAKD,WACI,KAAQhG,KAAKa,QAAQ0E,OAAS,GAC1BvF,KAAKmG,OAAO,EAEnB,M,gFAnWgBtG,G,kCCvCjBuG,EAA2B,CAAC,ECEhC,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAahH,QAGrB,IAAIC,EAAS2G,EAAyBG,GAAY,CAGjD/G,QAAS,CAAC,GAOX,OAHAkH,EAAoBH,GAAU9G,EAAQA,EAAOD,QAAS8G,GAG/C7G,EAAOD,OACf,CCnB0B8G,CAAoB,K,UHO9C","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/markers/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/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, () => {\nreturn ","/**\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 * @property {?draggable} boolean Set marker as draggable, defaults to false\n * @property {?boolean} preventContextMenu Determines whether the context menu\n * is prevented from being opened, defaults to false\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 * @fires MarkersPlugin#marker-drag\n * @fires MarkersPlugin#marker-drop\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.markerLineWidth = 1;\n this.markerWidth = 11;\n this.markerHeight = 22;\n this.dragging = false;\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 if (!this.markers.find(marker => marker.draggable)){\n return;\n }\n\n this.onMouseMove = (e) => this._onMouseMove(e);\n window.addEventListener('mousemove', this.onMouseMove);\n\n this.onMouseUp = (e) => this._onMouseUp(e);\n window.addEventListener(\"mouseup\", this.onMouseUp);\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 if (this.onMouseMove) {\n window.removeEventListener('mousemove', this.onMouseMove);\n }\n if (this.onMouseUp) {\n window.removeEventListener(\"mouseup\", this.onMouseUp);\n }\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 draggable: !!params.draggable,\n preventContextMenu: !!params.preventContextMenu\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 let label = marker.el.getElementsByClassName(\"marker-label\")[0];\n if (label) {\n if (label._onContextMenu) {\n label.removeEventListener(\"contextmenu\", label._onContextMenu);\n }\n if (label._onClick) {\n label.removeEventListener(\"click\", label._onClick);\n }\n if (label._onMouseDown) {\n label.removeEventListener(\"mousedown\", label._onMouseDown);\n }\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\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 const width = markerElement ? markerElement.width : this.markerWidth;\n marker.offset = (width - this.markerLineWidth) / 2;\n this.style(line, {\n \"flex-grow\": 1,\n \"margin-left\": marker.offset + \"px\",\n background: \"black\",\n width: this.markerLineWidth + \"px\",\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 if (marker.draggable){\n point.draggable = false;\n }\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 labelDiv.classList.add(\"marker-label\");\n\n el.appendChild(labelDiv);\n\n labelDiv._onClick = (e) => {\n e.stopPropagation();\n // Click event is caught when the marker-drop event was dispatched.\n // Drop event was dispatched at this moment, but this.dragging\n // is waiting for the next tick to set as false\n if (this.dragging){\n return;\n }\n this.wavesurfer.setCurrentTime(marker.time);\n this.wavesurfer.fireEvent(\"marker-click\", marker, e);\n };\n labelDiv.addEventListener(\"click\", labelDiv._onClick);\n\n labelDiv._onContextMenu = (e) => {\n if (marker.preventContextMenu) {\n e.preventDefault();\n }\n this.wavesurfer.fireEvent(\"marker-contextmenu\", marker, e);\n };\n labelDiv.addEventListener(\"contextmenu\", labelDiv._onContextMenu);\n\n if (marker.draggable) {\n labelDiv._onMouseDown = () => {\n this.selectedMarker = marker;\n };\n labelDiv.addEventListener(\"mousedown\", labelDiv._onMouseDown);\n }\n return el;\n }\n\n _updateMarkerPositions() {\n for ( let i = 0 ; i < this.markers.length; i++ ) {\n let marker = this.markers[i];\n this._updateMarkerPosition(marker);\n }\n }\n\n /**\n * Update a marker position based on its time property.\n *\n * @private\n * @param {MarkerParams} params The marker to update.\n * @returns {void}\n */\n _updateMarkerPosition(params) {\n const duration = this.wavesurfer.getDuration();\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n\n const positionPct = Math.min(params.time / duration, 1);\n const leftPx = ((elementWidth * positionPct) - params.offset);\n this.style(params.el, {\n \"left\": leftPx + \"px\",\n \"max-width\": (elementWidth - leftPx) + \"px\"\n });\n }\n\n /**\n * Fires `marker-drag` event, update the `time` property for the\n * selected marker based on the mouse position, and calls to update\n * its position.\n *\n * @private\n * @param {MouseEvent} event The mouse event.\n * @returns {void}\n */\n _onMouseMove(event) {\n if (!this.selectedMarker){\n return;\n }\n if (!this.dragging){\n this.dragging = true;\n this.wavesurfer.fireEvent(\"marker-drag\", this.selectedMarker, event);\n }\n this.selectedMarker.time = this.wavesurfer.drawer.handleEvent(event) * this.wavesurfer.getDuration();\n this._updateMarkerPositions();\n }\n\n /**\n * Fires `marker-drop` event and unselect the dragged marker.\n *\n * @private\n * @param {MouseEvent} event The mouse event.\n * @returns {void}\n */\n _onMouseUp(event) {\n if (this.selectedMarker) {\n setTimeout(() => {\n this.selectedMarker = false;\n this.dragging = false;\n }, 0);\n }\n\n if (!this.dragging) {\n return;\n }\n\n event.stopPropagation();\n const duration = this.wavesurfer.getDuration();\n this.selectedMarker.time = this.wavesurfer.drawer.handleEvent(event) * duration;\n this._updateMarkerPositions();\n this.wavesurfer.fireEvent(\"marker-drop\", this.selectedMarker, event);\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","markerLineWidth","markerWidth","markerHeight","dragging","_onResize","_updateMarkerPositions","_onBackendCreated","wrapper","drawer","markers","forEach","marker","add","window","addEventListener","on","find","draggable","onMouseMove","e","_onMouseMove","onMouseUp","_onMouseUp","_onReady","name","deferInit","staticProps","addMarker","options","initialisedPluginList","initPlugin","clearMarkers","clear","instance","isReady","once","un","removeEventListener","time","label","color","position","preventContextMenu","el","_createMarkerElement","markerElement","appendChild","push","index","getElementsByClassName","_onContextMenu","_onClick","_onMouseDown","removeChild","splice","svgNS","document","createElementNS","polygon","setAttribute","width","height","createElement","className","display","overflow","line","offset","background","opacity","labelDiv","point","_createPointerSVG","labelEl","innerText","cursor","classList","stopPropagation","setCurrentTime","fireEvent","preventDefault","selectedMarker","i","length","_updateMarkerPosition","duration","getDuration","elementWidth","pixelRatio","leftPx","Math","min","event","handleEvent","setTimeout","remove","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wavesurfer.mediasession.min.js","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,
|
|
1
|
+
{"version":3,"file":"wavesurfer.mediasession.min.js","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,CAAC,EAAGA,EAAiB,WAAgB,aAAIC,IACrF,CATD,CASGK,MAAM,IACT,M,kfCwBqBC,EAAAA,WAmBjB,WAAYC,EAAQC,GAAI,Y,4FAAA,SACpBC,KAAKF,OAASA,EACdE,KAAKC,WAAaF,EAEd,iBAAkBG,YAElBF,KAAKG,SAAWH,KAAKF,OAAOK,SAC5BH,KAAKI,SAGLJ,KAAKC,WAAWI,GAAG,QAAQ,WACvB,EAAKD,QACR,IAGDF,UAAUI,aAAaC,iBAAiB,QAAQ,WAC5C,EAAKN,WAAWO,MACnB,IACDN,UAAUI,aAAaC,iBAAiB,SAAS,WAC7C,EAAKN,WAAWQ,WACnB,IACDP,UAAUI,aAAaC,iBAAiB,gBAAgB,WACpD,EAAKN,WAAWS,cACnB,IACDR,UAAUI,aAAaC,iBAAiB,eAAe,WACnD,EAAKN,WAAWU,aACnB,IAER,C,4CArCD,SAAcb,GACV,MAAO,CACHc,KAAM,eACNC,aAAWf,IAAUA,EAAOe,YAAYf,EAAOe,UAC/Cf,OAAQA,EACRgB,SAAUjB,EAEjB,K,qBAgCD,WAAS,G,qBAET,WAAY,G,oBAEZ,YACQ,oBAAOkB,cAAP,cAAOA,mBAAP,oBAAgCC,SAAhC,cAAgCA,aAEhCd,UAAUI,aAAaH,SAAW,IAAIY,cAAcf,KAAKG,UAEhE,M,gFA1DgBN,G,kCCjCjBoB,EAA2B,CAAC,ECEhC,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAa7B,QAGrB,IAAIC,EAASwB,EAAyBG,GAAY,CAGjD5B,QAAS,CAAC,GAOX,OAHA+B,EAAoBH,GAAU3B,EAAQA,EAAOD,QAAS2B,GAG/C1B,EAAOD,OACf,CCnB0B2B,CAAoB,K,UHO9C","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/mediasession/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/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, () => {\nreturn ","/**\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_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wavesurfer.microphone.min.js","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,WAAc,WAAIC,KARpF,CASGK,MAAM,IACT,M,4QC+BqBC,EAAAA,WAmBjB,WAAYC,EAAQC,GAAI,Y,4FAAA,SACpBC,KAAKF,OAASA,EACdE,KAAKC,WAAaF,EAElBC,KAAKE,QAAS,EACdF,KAAKG,QAAS,EACdH,KAAKI,QAAUJ,KAAKK,gBACpBL,KAAKM,qBAAuB,SAAAC,GAAC,OAAI,EAAKC,aAAaD,SAkCpBE,IAA3BC,UAAUC,eACVD,UAAUC,aAAe,SAMeF,IAAxCC,UAAUC,aAAaC,eACvBF,UAAUC,aAAaC,aAvCD,SACtBC,EACAC,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F,GAAUjG,EAAQA,EAAOD,QAASiG,GAG/ChG,EAAOD,QClBWiG,CAAoB,K,UHO9C","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/microphone/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/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\"][\"microphone\"] = factory();\n})(self, () => {\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__(872);\n"],"names":["root","factory","exports","module","define","amd","self","MicrophonePlugin","params","ws","this","wavesurfer","active","paused","browser","detectBrowser","reloadBufferFunction","e","reloadBuffer","undefined","navigator","mediaDevices","getUserMedia","constraints","successCallback","errorCallback","webkitGetUserMedia","mozGetUserMedia","msGetUserMedia","Promise","call","reject","Error","video","audio","bufferSize","numberOfInputChannels","numberOfOutputChannels","_onBackendCreated","micContext","backend","getAudioContext","name","deferInit","instance","on","un","stop","then","data","gotStream","catch","deviceError","pause","play","start","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","window","version","extractVersion","userAgent","minVersion","RTCPeerConnection","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","__webpack_modules__"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"wavesurfer.microphone.min.js","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,CAAC,EAAGA,EAAiB,WAAc,WAAIC,IACnF,CATD,CASGK,MAAM,IACT,M,4QC+BqBC,EAAAA,WAmBjB,WAAYC,EAAQC,GAAI,Y,4FAAA,SACpBC,KAAKF,OAASA,EACdE,KAAKC,WAAaF,EAElBC,KAAKE,QAAS,EACdF,KAAKG,QAAS,EACdH,KAAKI,QAAUJ,KAAKK,gBACpBL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UACV,uBACA,GAEGJ,IAIXA,EAAO5E,QAAU,2BACV4E,IAtDHA,EAAO5E,QAAU,2BACV4E,EAsDd,M,gFApXgBnF,G,kCCxCjB0F,EAA2B,CAAC,ECEhC,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBjF,IAAjBkF,EACH,OAAOA,EAAanG,QAGrB,IAAIC,EAAS8F,EAAyBG,GAAY,CAGjDlG,QAAS,CAAC,GAOX,OAHAoG,EAAoBF,GAAUjG,EAAQA,EAAOD,QAASiG,GAG/ChG,EAAOD,OACf,CCnB0BiG,CAAoB,K,UHO9C","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/microphone/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/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\"][\"microphone\"] = factory();\n})(self, () => {\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__(872);\n"],"names":["root","factory","exports","module","define","amd","self","MicrophonePlugin","params","ws","this","wavesurfer","active","paused","browser","detectBrowser","reloadBufferFunction","e","reloadBuffer","undefined","navigator","mediaDevices","getUserMedia","constraints","successCallback","errorCallback","webkitGetUserMedia","mozGetUserMedia","msGetUserMedia","Promise","call","reject","Error","video","audio","bufferSize","numberOfInputChannels","numberOfOutputChannels","_onBackendCreated","micContext","backend","getAudioContext","name","deferInit","instance","on","un","stop","then","data","gotStream","catch","deviceError","pause","play","start","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","window","version","extractVersion","userAgent","minVersion","RTCPeerConnection","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","__webpack_modules__"],"sourceRoot":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wavesurfer.minimap.min.js","mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG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AAQA,EAAOD,QAASgJ,GAG/C/I,EAAOD,QClBWgJ,CAAoB,K,UHO9C","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/minimap/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/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\"][\"minimap\"] = factory();\n})(self, () => {\nreturn ","/*eslint no-console: [\"error\", { allow: [\"warn\"] }] */\n/**\n * @typedef {Object} MinimapPluginParams\n * @desc Extends the `WavesurferParams` wavesurfer was initialised with\n * @property {?string|HTMLElement} container CSS selector or HTML element where\n * the map should be rendered. By default it is simply appended\n * after the waveform.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('minimap')`\n */\n\n/**\n * Renders a smaller version waveform as a minimap of the main waveform.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import MinimapPlugin from 'wavesurfer.minimap.js';\n *\n * // commonjs\n * var MinimapPlugin = require('wavesurfer.minimap.js');\n *\n * // if you are using <script> tags\n * var MinimapPlugin = window.WaveSurfer.minimap;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MinimapPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class MinimapPlugin {\n /**\n * Minimap 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 {MinimapPluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'minimap',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {},\n instance: MinimapPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = Object.assign(\n {},\n ws.params,\n {\n showRegions: false,\n regionsPluginName: params.regionsPluginName || 'regions',\n showOverview: false,\n overviewBorderColor: 'green',\n overviewBorderSize: 2,\n // the container should be different\n container: false,\n height: Math.max(Math.round(ws.params.height / 4), 20)\n },\n params,\n {\n scrollParent: false,\n fillParent: true\n }\n );\n // if container is a selector, get the element\n if (typeof params.container === 'string') {\n const el = document.querySelector(params.container);\n if (!el) {\n console.warn(\n `Wavesurfer minimap container ${params.container} was not found! The minimap will be automatically appended below the waveform.`\n );\n }\n this.params.container = el;\n }\n // if no container is specified add a new element and insert it\n if (!params.container) {\n this.params.container = ws.util.style(\n document.createElement('minimap'),\n {\n display: 'block'\n }\n );\n }\n this.drawer = new ws.Drawer(this.params.container, this.params);\n this.wavesurfer = ws;\n this.util = ws.util;\n this.cleared = false;\n this.renderEvent = 'redraw';\n this.overviewRegion = null;\n this.regionsPlugin = this.wavesurfer[this.params.regionsPluginName];\n\n this.drawer.createWrapper();\n this.createElements();\n let isInitialised = false;\n\n // ws ready event listener\n this._onShouldRender = () => {\n // only bind the events in the first run\n if (!isInitialised) {\n this.bindWavesurferEvents();\n this.bindMinimapEvents();\n isInitialised = true;\n }\n // if there is no such element, append it to the container (below\n // the waveform)\n if (!document.body.contains(this.params.container)) {\n ws.container.insertBefore(this.params.container, null);\n }\n\n if (this.regionsPlugin && this.params.showRegions) {\n this.drawRegions();\n }\n this.render();\n };\n\n this._onAudioprocess = currentTime => {\n this.drawer.progress(this.wavesurfer.backend.getPlayedPercents());\n };\n\n // ws seek event listener\n this._onSeek = () =>\n this.drawer.progress(ws.backend.getPlayedPercents());\n\n // event listeners for the overview region\n this._onScroll = e => {\n if (!this.draggingOverview) {\n const orientedTarget = this.util.withOrientation(e.target, this.wavesurfer.params.vertical);\n this.moveOverviewRegion(orientedTarget.scrollLeft / this.ratio);\n }\n };\n this._onMouseover = e => {\n if (this.draggingOverview) {\n this.draggingOverview = false;\n }\n };\n let prevWidth = 0;\n this._onResize = ws.util.debounce(() => {\n if (prevWidth != this.drawer.wrapper.clientWidth) {\n prevWidth = this.drawer.wrapper.clientWidth;\n this.render();\n this.drawer.progress(\n this.wavesurfer.backend.getPlayedPercents()\n );\n }\n });\n this._onLoading = percent => {\n if (percent >= 100) {\n this.cleared = false;\n return;\n }\n if (this.cleared === true) {\n return;\n }\n const len = this.drawer.getWidth();\n this.drawer.drawPeaks([0], len, 0, len);\n this.cleared = true;\n };\n this._onZoom = e => {\n this.render();\n };\n this.wavesurfer.on('zoom', this._onZoom);\n }\n\n init() {\n if (this.wavesurfer.isReady) {\n this._onShouldRender();\n }\n this.wavesurfer.on(this.renderEvent, this._onShouldRender);\n }\n\n destroy() {\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.drawer.wrapper.removeEventListener(\n 'mouseover',\n this._onMouseover\n );\n this.wavesurfer.un(this.renderEvent, this._onShouldRender);\n this.wavesurfer.un('seek', this._onSeek);\n this.wavesurfer.un('scroll', this._onScroll);\n this.wavesurfer.un('audioprocess', this._onAudioprocess);\n this.wavesurfer.un('zoom', this._onZoom);\n this.wavesurfer.un('loading', this._onLoading);\n this.drawer.destroy();\n this.overviewRegion = null;\n this.unAll();\n }\n\n drawRegions() {\n this.regions = {};\n\n this.wavesurfer.on('region-created', region => {\n this.regions[region.id] = region;\n this.drawer.wrapper && this.renderRegions();\n });\n\n this.wavesurfer.on('region-updated', region => {\n this.regions[region.id] = region;\n this.drawer.wrapper && this.renderRegions();\n });\n\n this.wavesurfer.on('region-removed', region => {\n delete this.regions[region.id];\n this.drawer.wrapper && this.renderRegions();\n });\n }\n\n renderRegions() {\n const regionElements = this.drawer.wrapper.querySelectorAll('region');\n let i;\n for (i = 0; i < regionElements.length; ++i) {\n this.drawer.wrapper.removeChild(regionElements[i]);\n }\n\n Object.keys(this.regions).forEach(id => {\n const region = this.regions[id];\n const width =\n this.getWidth() *\n ((region.end - region.start) / this.wavesurfer.getDuration());\n const left =\n this.getWidth() *\n (region.start / this.wavesurfer.getDuration());\n const regionElement = this.util.style(\n document.createElement('region'),\n {\n height: 'inherit',\n backgroundColor: region.color,\n width: width + 'px',\n left: left + 'px',\n display: 'block',\n position: 'absolute'\n }\n );\n regionElement.classList.add(id);\n this.drawer.wrapper.appendChild(regionElement);\n });\n }\n\n createElements() {\n this.drawer.createElements();\n if (this.params.showOverview) {\n this.overviewRegion = this.util.withOrientation(\n this.drawer.wrapper.appendChild(document.createElement('overview')),\n this.wavesurfer.params.vertical\n );\n\n this.util.style(\n this.overviewRegion,\n {\n top: 0,\n bottom: 0,\n width: '0px',\n display: 'block',\n position: 'absolute',\n cursor: 'move',\n border:\n this.params.overviewBorderSize +\n 'px solid ' +\n this.params.overviewBorderColor,\n zIndex: 2,\n opacity: this.params.overviewOpacity\n }\n );\n }\n }\n\n bindWavesurferEvents() {\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.on('audioprocess', this._onAudioprocess);\n this.wavesurfer.on('seek', this._onSeek);\n this.wavesurfer.on('loading', this._onLoading);\n if (this.params.showOverview) {\n this.wavesurfer.on('scroll', this._onScroll);\n this.wavesurfer.drawer.wrapper.addEventListener(\n 'mouseover',\n this._onMouseover\n );\n }\n }\n\n bindMinimapEvents() {\n const positionMouseDown = {\n clientX: 0,\n clientY: 0\n };\n let relativePositionX = 0;\n let seek = true;\n\n // the following event listeners will be destroyed by using\n // this.unAll() and nullifying the DOM node references after\n // removing them\n if (this.params.interact) {\n this.drawer.wrapper.addEventListener('click', event => {\n this.fireEvent('click', event, this.drawer.handleEvent(event));\n });\n\n this.on('click', (event, position) => {\n if (seek) {\n this.drawer.progress(position);\n this.wavesurfer.seekAndCenter(position);\n } else {\n seek = true;\n }\n });\n }\n\n if (this.params.showOverview) {\n this.overviewRegion.domElement.addEventListener('mousedown', e => {\n const event = this.util.withOrientation(e, this.wavesurfer.params.vertical);\n this.draggingOverview = true;\n relativePositionX = event.layerX;\n positionMouseDown.clientX = event.clientX;\n positionMouseDown.clientY = event.clientY;\n });\n\n this.drawer.wrapper.addEventListener('mousemove', e => {\n if (this.draggingOverview) {\n const event = this.util.withOrientation(e, this.wavesurfer.params.vertical);\n this.moveOverviewRegion(\n event.clientX -\n this.drawer.container.getBoundingClientRect().left -\n relativePositionX\n );\n }\n });\n\n this.drawer.wrapper.addEventListener('mouseup', e => {\n const event = this.util.withOrientation(e, this.wavesurfer.params.vertical);\n if (\n positionMouseDown.clientX - event.clientX === 0 &&\n positionMouseDown.clientX - event.clientX === 0\n ) {\n seek = true;\n this.draggingOverview = false;\n } else if (this.draggingOverview) {\n seek = false;\n this.draggingOverview = false;\n }\n });\n }\n }\n\n render() {\n const len = this.drawer.getWidth();\n const peaks = this.wavesurfer.backend.getPeaks(len, 0, len);\n this.drawer.drawPeaks(peaks, len, 0, len);\n this.drawer.progress(this.wavesurfer.backend.getPlayedPercents());\n\n if (this.params.showOverview) {\n //get proportional width of overview region considering the respective\n //width of the drawers\n this.ratio = this.wavesurfer.drawer.width / this.drawer.width;\n this.waveShowedWidth = this.wavesurfer.drawer.width / this.ratio;\n this.waveWidth = this.wavesurfer.drawer.width;\n this.overviewWidth = this.drawer.container.offsetWidth / this.ratio;\n this.overviewPosition = 0;\n this.moveOverviewRegion(\n this.wavesurfer.drawer.wrapper.scrollLeft / this.ratio\n );\n this.util.style(this.overviewRegion, {\n width: this.overviewWidth + 'px'\n });\n }\n }\n\n moveOverviewRegion(pixels) {\n if (pixels < 0) {\n this.overviewPosition = 0;\n } else if (\n pixels + this.overviewWidth <\n this.drawer.container.offsetWidth\n ) {\n this.overviewPosition = pixels;\n } else {\n this.overviewPosition =\n this.drawer.container.offsetWidth - this.overviewWidth;\n }\n this.util.style(this.overviewRegion, {\n left: this.overviewPosition + 'px'\n });\n if (this.draggingOverview) {\n this.wavesurfer.drawer.wrapper.scrollLeft =\n this.overviewPosition * this.ratio;\n }\n }\n\n getWidth() {\n return this.drawer.width / this.params.pixelRatio;\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__(521);\n"],"names":["root","factory","exports","module","define","amd","self","MinimapPlugin","params","ws","this","Object","assign","showRegions","regionsPluginName","showOverview","overviewBorderColor","overviewBorderSize","container","height","Math","max","round","scrollParent","fillParent","el","document","querySelector","console","warn","util","style","createElement","display","drawer","Drawer","wavesurfer","cleared","renderEvent","overviewRegion","regionsPlugin","createWrapper","createElements","isInitialised","_onShouldRender","bindWavesurferEvents","bindMinimapEvents","body","contains","insertBefore","drawRegions","render","_onAudioprocess","currentTime","progress","backend","getPlayedPercents","_onSeek","_onScroll","e","draggingOverview","orientedTarget","withOrientation","target","vertical","moveOverviewRegion","scrollLeft","ratio","_onMouseover","prevWidth","_onResize","debounce","wrapper","clientWidth","_onLoading","percent","len","getWidth","drawPeaks","_onZoom","on","name","deferInit","staticProps","instance","isReady","window","removeEventListener","un","destroy","unAll","regions","region","id","renderRegions","i","regionElements","querySelectorAll","length","removeChild","keys","forEach","width","end","start","getDuration","left","regionElement","backgroundColor","color","position","classList","add","appendChild","top","bottom","cursor","border","zIndex","opacity","overviewOpacity","addEventListener","positionMouseDown","clientX","clientY","relativePositionX","seek","interact","event","fireEvent","handleEvent","seekAndCenter","domElement","layerX","getBoundingClientRect","peaks","getPeaks","waveShowedWidth","waveWidth","overviewWidth","offsetWidth","overviewPosition","pixels","pixelRatio","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"wavesurfer.minimap.min.js","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,CAAC,EAAGA,EAAiB,WAAW,QAAIC,IAChF,CATD,CASGK,MAAM,IACT,M,4QC0BqBC,EAAAA,WAoBjB,WAAYC,EAAQC,GAAI,WAqBpB,G,4FArBoB,SACpBC,KAAKF,OAASG,OAAOC,OACjB,CAAC,EACDH,EAAGD,OACH,CACIK,aAAa,EACbC,kBAAmBN,EAAOM,mBAAqB,UAC/CC,cAAc,EACdC,oBAAqB,QACrBC,mBAAoB,EAEpBC,WAAW,EACXC,OAAQC,KAAKC,IAAID,KAAKE,MAAMb,EAAGD,OAAOW,OAAS,GAAI,KAEvDX,EACA,CACIe,cAAc,EACdC,YAAY,IAIY,iBAArBhB,EAAOU,UAAwB,CACtC,IAAMO,EAAKC,SAASC,cAAcnB,EAAOU,WACpCO,GACDG,QAAQC,KAAR,uCACoCrB,EAAOU,UAD3C,mFAIJR,KAAKF,OAAOU,UAAYO,CAC3B,CAEIjB,EAAOU,YACRR,KAAKF,OAAOU,UAAYT,EAAGqB,KAAKC,MAC5BL,SAASM,cAAc,WACvB,CACIC,QAAS,WAIrBvB,KAAKwB,OAAS,IAAIzB,EAAG0B,OAAOzB,KAAKF,OAAOU,UAAWR,KAAKF,QACxDE,KAAK0B,WAAa3B,EAClBC,KAAKoB,KAAOrB,EAAG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,KAAKwB,OAAOhB,UAAU0H,YAAclI,KAAKiI,cAEjDjI,KAAKoB,KAAKC,MAAMrB,KAAK6B,eAAgB,CACjCmE,KAAMhG,KAAKmI,iBAAmB,OAE9BnI,KAAKkD,mBACLlD,KAAK0B,WAAWF,OAAOsC,QAAQN,WAC3BxD,KAAKmI,iBAAmBnI,KAAKyD,MAExC,G,sBAED,WACI,OAAOzD,KAAKwB,OAAOoE,MAAQ5F,KAAKF,OAAOuI,UAC1C,M,gFA7WgBxI,G,kCCnCjByI,EAA2B,CAAC,ECEhC,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAalJ,QAGrB,IAAIC,EAAS6I,EAAyBG,GAAY,CAGjDjJ,QAAS,CAAC,GAOX,OAHAoJ,EAAoBH,GAAUhJ,EAAQA,EAAOD,QAASgJ,GAG/C/I,EAAOD,OACf,CCnB0BgJ,CAAoB,K,UHO9C","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/minimap/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/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\"][\"minimap\"] = factory();\n})(self, () => {\nreturn ","/*eslint no-console: [\"error\", { allow: [\"warn\"] }] */\n/**\n * @typedef {Object} MinimapPluginParams\n * @desc Extends the `WavesurferParams` wavesurfer was initialised with\n * @property {?string|HTMLElement} container CSS selector or HTML element where\n * the map should be rendered. By default it is simply appended\n * after the waveform.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('minimap')`\n */\n\n/**\n * Renders a smaller version waveform as a minimap of the main waveform.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import MinimapPlugin from 'wavesurfer.minimap.js';\n *\n * // commonjs\n * var MinimapPlugin = require('wavesurfer.minimap.js');\n *\n * // if you are using <script> tags\n * var MinimapPlugin = window.WaveSurfer.minimap;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MinimapPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class MinimapPlugin {\n /**\n * Minimap 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 {MinimapPluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'minimap',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {},\n instance: MinimapPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = Object.assign(\n {},\n ws.params,\n {\n showRegions: false,\n regionsPluginName: params.regionsPluginName || 'regions',\n showOverview: false,\n overviewBorderColor: 'green',\n overviewBorderSize: 2,\n // the container should be different\n container: false,\n height: Math.max(Math.round(ws.params.height / 4), 20)\n },\n params,\n {\n scrollParent: false,\n fillParent: true\n }\n );\n // if container is a selector, get the element\n if (typeof params.container === 'string') {\n const el = document.querySelector(params.container);\n if (!el) {\n console.warn(\n `Wavesurfer minimap container ${params.container} was not found! The minimap will be automatically appended below the waveform.`\n );\n }\n this.params.container = el;\n }\n // if no container is specified add a new element and insert it\n if (!params.container) {\n this.params.container = ws.util.style(\n document.createElement('minimap'),\n {\n display: 'block'\n }\n );\n }\n this.drawer = new ws.Drawer(this.params.container, this.params);\n this.wavesurfer = ws;\n this.util = ws.util;\n this.cleared = false;\n this.renderEvent = 'redraw';\n this.overviewRegion = null;\n this.regionsPlugin = this.wavesurfer[this.params.regionsPluginName];\n\n this.drawer.createWrapper();\n this.createElements();\n let isInitialised = false;\n\n // ws ready event listener\n this._onShouldRender = () => {\n // only bind the events in the first run\n if (!isInitialised) {\n this.bindWavesurferEvents();\n this.bindMinimapEvents();\n isInitialised = true;\n }\n // if there is no such element, append it to the container (below\n // the waveform)\n if (!document.body.contains(this.params.container)) {\n ws.container.insertBefore(this.params.container, null);\n }\n\n if (this.regionsPlugin && this.params.showRegions) {\n this.drawRegions();\n }\n this.render();\n };\n\n this._onAudioprocess = currentTime => {\n this.drawer.progress(this.wavesurfer.backend.getPlayedPercents());\n };\n\n // ws seek event listener\n this._onSeek = () =>\n this.drawer.progress(ws.backend.getPlayedPercents());\n\n // event listeners for the overview region\n this._onScroll = e => {\n if (!this.draggingOverview) {\n const orientedTarget = this.util.withOrientation(e.target, this.wavesurfer.params.vertical);\n this.moveOverviewRegion(orientedTarget.scrollLeft / this.ratio);\n }\n };\n this._onMouseover = e => {\n if (this.draggingOverview) {\n this.draggingOverview = false;\n }\n };\n let prevWidth = 0;\n this._onResize = ws.util.debounce(() => {\n if (prevWidth != this.drawer.wrapper.clientWidth) {\n prevWidth = this.drawer.wrapper.clientWidth;\n this.render();\n this.drawer.progress(\n this.wavesurfer.backend.getPlayedPercents()\n );\n }\n });\n this._onLoading = percent => {\n if (percent >= 100) {\n this.cleared = false;\n return;\n }\n if (this.cleared === true) {\n return;\n }\n const len = this.drawer.getWidth();\n this.drawer.drawPeaks([0], len, 0, len);\n this.cleared = true;\n };\n this._onZoom = e => {\n this.render();\n };\n this.wavesurfer.on('zoom', this._onZoom);\n }\n\n init() {\n if (this.wavesurfer.isReady) {\n this._onShouldRender();\n }\n this.wavesurfer.on(this.renderEvent, this._onShouldRender);\n }\n\n destroy() {\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.drawer.wrapper.removeEventListener(\n 'mouseover',\n this._onMouseover\n );\n this.wavesurfer.un(this.renderEvent, this._onShouldRender);\n this.wavesurfer.un('seek', this._onSeek);\n this.wavesurfer.un('scroll', this._onScroll);\n this.wavesurfer.un('audioprocess', this._onAudioprocess);\n this.wavesurfer.un('zoom', this._onZoom);\n this.wavesurfer.un('loading', this._onLoading);\n this.drawer.destroy();\n this.overviewRegion = null;\n this.unAll();\n }\n\n drawRegions() {\n this.regions = {};\n\n this.wavesurfer.on('region-created', region => {\n this.regions[region.id] = region;\n this.drawer.wrapper && this.renderRegions();\n });\n\n this.wavesurfer.on('region-updated', region => {\n this.regions[region.id] = region;\n this.drawer.wrapper && this.renderRegions();\n });\n\n this.wavesurfer.on('region-removed', region => {\n delete this.regions[region.id];\n this.drawer.wrapper && this.renderRegions();\n });\n }\n\n renderRegions() {\n const regionElements = this.drawer.wrapper.querySelectorAll('region');\n let i;\n for (i = 0; i < regionElements.length; ++i) {\n this.drawer.wrapper.removeChild(regionElements[i]);\n }\n\n Object.keys(this.regions).forEach(id => {\n const region = this.regions[id];\n const width =\n this.getWidth() *\n ((region.end - region.start) / this.wavesurfer.getDuration());\n const left =\n this.getWidth() *\n (region.start / this.wavesurfer.getDuration());\n const regionElement = this.util.style(\n document.createElement('region'),\n {\n height: 'inherit',\n backgroundColor: region.color,\n width: width + 'px',\n left: left + 'px',\n display: 'block',\n position: 'absolute'\n }\n );\n regionElement.classList.add(id);\n this.drawer.wrapper.appendChild(regionElement);\n });\n }\n\n createElements() {\n this.drawer.createElements();\n if (this.params.showOverview) {\n this.overviewRegion = this.util.withOrientation(\n this.drawer.wrapper.appendChild(document.createElement('overview')),\n this.wavesurfer.params.vertical\n );\n\n this.util.style(\n this.overviewRegion,\n {\n top: 0,\n bottom: 0,\n width: '0px',\n display: 'block',\n position: 'absolute',\n cursor: 'move',\n border:\n this.params.overviewBorderSize +\n 'px solid ' +\n this.params.overviewBorderColor,\n zIndex: 2,\n opacity: this.params.overviewOpacity\n }\n );\n }\n }\n\n bindWavesurferEvents() {\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.on('audioprocess', this._onAudioprocess);\n this.wavesurfer.on('seek', this._onSeek);\n this.wavesurfer.on('loading', this._onLoading);\n if (this.params.showOverview) {\n this.wavesurfer.on('scroll', this._onScroll);\n this.wavesurfer.drawer.wrapper.addEventListener(\n 'mouseover',\n this._onMouseover\n );\n }\n }\n\n bindMinimapEvents() {\n const positionMouseDown = {\n clientX: 0,\n clientY: 0\n };\n let relativePositionX = 0;\n let seek = true;\n\n // the following event listeners will be destroyed by using\n // this.unAll() and nullifying the DOM node references after\n // removing them\n if (this.params.interact) {\n this.drawer.wrapper.addEventListener('click', event => {\n this.fireEvent('click', event, this.drawer.handleEvent(event));\n });\n\n this.on('click', (event, position) => {\n if (seek) {\n this.drawer.progress(position);\n this.wavesurfer.seekAndCenter(position);\n } else {\n seek = true;\n }\n });\n }\n\n if (this.params.showOverview) {\n this.overviewRegion.domElement.addEventListener('mousedown', e => {\n const event = this.util.withOrientation(e, this.wavesurfer.params.vertical);\n this.draggingOverview = true;\n relativePositionX = event.layerX;\n positionMouseDown.clientX = event.clientX;\n positionMouseDown.clientY = event.clientY;\n });\n\n this.drawer.wrapper.addEventListener('mousemove', e => {\n if (this.draggingOverview) {\n const event = this.util.withOrientation(e, this.wavesurfer.params.vertical);\n this.moveOverviewRegion(\n event.clientX -\n this.drawer.container.getBoundingClientRect().left -\n relativePositionX\n );\n }\n });\n\n this.drawer.wrapper.addEventListener('mouseup', e => {\n const event = this.util.withOrientation(e, this.wavesurfer.params.vertical);\n if (\n positionMouseDown.clientX - event.clientX === 0 &&\n positionMouseDown.clientX - event.clientX === 0\n ) {\n seek = true;\n this.draggingOverview = false;\n } else if (this.draggingOverview) {\n seek = false;\n this.draggingOverview = false;\n }\n });\n }\n }\n\n render() {\n const len = this.drawer.getWidth();\n const peaks = this.wavesurfer.backend.getPeaks(len, 0, len);\n this.drawer.drawPeaks(peaks, len, 0, len);\n this.drawer.progress(this.wavesurfer.backend.getPlayedPercents());\n\n if (this.params.showOverview) {\n //get proportional width of overview region considering the respective\n //width of the drawers\n this.ratio = this.wavesurfer.drawer.width / this.drawer.width;\n this.waveShowedWidth = this.wavesurfer.drawer.width / this.ratio;\n this.waveWidth = this.wavesurfer.drawer.width;\n this.overviewWidth = this.drawer.container.offsetWidth / this.ratio;\n this.overviewPosition = 0;\n this.moveOverviewRegion(\n this.wavesurfer.drawer.wrapper.scrollLeft / this.ratio\n );\n this.util.style(this.overviewRegion, {\n width: this.overviewWidth + 'px'\n });\n }\n }\n\n moveOverviewRegion(pixels) {\n if (pixels < 0) {\n this.overviewPosition = 0;\n } else if (\n pixels + this.overviewWidth <\n this.drawer.container.offsetWidth\n ) {\n this.overviewPosition = pixels;\n } else {\n this.overviewPosition =\n this.drawer.container.offsetWidth - this.overviewWidth;\n }\n this.util.style(this.overviewRegion, {\n left: this.overviewPosition + 'px'\n });\n if (this.draggingOverview) {\n this.wavesurfer.drawer.wrapper.scrollLeft =\n this.overviewPosition * this.ratio;\n }\n }\n\n getWidth() {\n return this.drawer.width / this.params.pixelRatio;\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__(521);\n"],"names":["root","factory","exports","module","define","amd","self","MinimapPlugin","params","ws","this","Object","assign","showRegions","regionsPluginName","showOverview","overviewBorderColor","overviewBorderSize","container","height","Math","max","round","scrollParent","fillParent","el","document","querySelector","console","warn","util","style","createElement","display","drawer","Drawer","wavesurfer","cleared","renderEvent","overviewRegion","regionsPlugin","createWrapper","createElements","isInitialised","_onShouldRender","bindWavesurferEvents","bindMinimapEvents","body","contains","insertBefore","drawRegions","render","_onAudioprocess","currentTime","progress","backend","getPlayedPercents","_onSeek","_onScroll","e","draggingOverview","orientedTarget","withOrientation","target","vertical","moveOverviewRegion","scrollLeft","ratio","_onMouseover","prevWidth","_onResize","debounce","wrapper","clientWidth","_onLoading","percent","len","getWidth","drawPeaks","_onZoom","on","name","deferInit","staticProps","instance","isReady","window","removeEventListener","un","destroy","unAll","regions","region","id","renderRegions","i","regionElements","querySelectorAll","length","removeChild","keys","forEach","width","end","start","getDuration","left","regionElement","backgroundColor","color","position","classList","add","appendChild","top","bottom","cursor","border","zIndex","opacity","overviewOpacity","addEventListener","positionMouseDown","clientX","clientY","relativePositionX","seek","interact","event","fireEvent","handleEvent","seekAndCenter","domElement","layerX","getBoundingClientRect","peaks","getPeaks","waveShowedWidth","waveWidth","overviewWidth","offsetWidth","overviewPosition","pixels","pixelRatio","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wavesurfer.playhead.min.js","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,WAAY,SAAIC,KARlF,CASGK,MAAM,IACT,M,wQCkBA,IAEqBC,EAAAA,WA2BjB,WAAYC,EAAQC,GAAI,Y,4FAAA,SACpBC,KAAKF,OAASA,EACdE,KAAKC,QAAU,GAEf,CAAC,OAAQ,aAAc,iBAAiBC,SAAQ,SAAAC,GAEx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L,K,qCAG7B,WACI,GAAK5C,KAAKuC,QAAV,CAIA,IAAMyB,EAAWhE,KAAKI,WAAW6D,cAC3BC,EACFlE,KAAKI,WAAWW,OAAOmC,MACvBlD,KAAKI,WAAWN,OAAOqE,WAErBC,EAAcpE,KAAKS,aAAeuD,EACxChE,KAAKM,MAAMN,KAAKuC,QAAS,CACrB8B,KAAQH,EAAeE,EAAgBpE,KAAKO,YAAc,EAAM,a,gFAhMvDV,G,kCC7BjByE,EAA2B,GCE/B,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAalF,QAGrB,IAAIC,EAAS6E,EAAyBG,GAAY,CAGjDjF,QAAS,IAOV,OAHAoF,EAAoBH,GAAUhF,EAAQA,EAAOD,QAASgF,GAG/C/E,EAAOD,QClBWgF,CAAoB,K,UHO9C","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/playhead/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/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\"][\"playhead\"] = factory();\n})(self, () => {\nreturn ","\n/**\n * The playhead plugin separates the notion of the currently playing position from\n * a 'play-start' position. Having a playhead enables a listening pattern\n * (commonly found in DAWs) that involves listening to a section of a track\n * repeatedly, rather than listening to an entire track in a linear fashion.\n *\n * @implements {PluginClass}\n *\n * @example\n * import PlayheadPlugin from 'wavesurfer.playhead.js';\n *\n * // if you are using <script> tags\n * var PlayheadPlugin = window.WaveSurfer.playhead;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * PlayheadPlugin.create({\n * movePlayheadOnSeek: true,\n * drawPlayhead: false,\n * movePlayheadOnPause: false\n * })\n * ]\n * });\n */\n\nconst DEFAULT_FILL_COLOR = '#CF2F00';\n\nexport default class PlayheadPlugin {\n /**\n * @typedef {Object} PlayheadPluginParams\n * @property {?boolean} draw=true Draw the playhead as a triangle/line\n * @property {?boolean} moveOnSeek=true Seeking (via clicking) while playing moves the playhead\n * @property {?boolean} returnOnPause=true Pausing the track returns the seek position to the playhead\n */\n\n /**\n * Playhead 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 {PlayheadPluginParams} params parameters use to initialise the plugin\n * @since 5.0.0\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'playhead',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: PlayheadPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.options = {};\n\n ['draw', 'moveOnSeek', 'returnOnPause'].forEach(opt => {\n if (opt in params) {\n this.options[opt] = params[opt];\n } else {\n this.options[opt] = true;\n }\n });\n\n\n this.wavesurfer = ws;\n this.util = ws.util;\n this.style = this.util.style;\n this.markerWidth = 21;\n this.markerHeight = 16;\n this.playheadTime = 0;\n this.unFuns = [];\n\n this._onResize = () => {\n this._updatePlayheadPosition();\n };\n\n this._onReady = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this._updatePlayheadPosition();\n };\n }\n\n _onBackendCreated() {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n\n if (this.options.draw) {\n this._createPlayheadElement();\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n\n this.wavesurferOn('zoom', this._onResize);\n }\n\n this.wavesurferOn('pause', () => {\n if ( this.options.returnOnPause ) {\n this.wavesurfer.setCurrentTime(this.playheadTime);\n }\n });\n\n this.wavesurferOn('seek', () => {\n if ( this.options.moveOnSeek ) {\n this.playheadTime = this.wavesurfer.getCurrentTime();\n this._updatePlayheadPosition();\n }\n });\n\n this.playheadTime = this.wavesurfer.getCurrentTime();\n }\n\n wavesurferOn(ev, fn) {\n let ret = this.wavesurfer.on(ev, fn);\n this.unFuns.push(() => {\n this.wavesurfer.un(ev, fn);\n });\n return ret;\n }\n\n init() {\n if (this.wavesurfer.isReady) {\n this._onBackendCreated();\n this._onReady();\n } else {\n let r;\n\n this.wavesurfer.once('ready', () => this._onReady());\n this.wavesurfer.once('backend-created', () => this._onBackendCreated());\n }\n }\n\n destroy() {\n this.unFuns.forEach(f => f());\n this.unFuns = [];\n\n this.wrapper.removeChild(this.element);\n\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n }\n\n setPlayheadTime(time) {\n this.playheadTime = time;\n\n if (!this.wavesurfer.isPlaying()) {\n this.wavesurfer.setCurrentTime(time);\n }\n this._updatePlayheadPosition();\n }\n\n _createPointerSVG() {\n const svgNS = 'http://www.w3.org/2000/svg';\n\n const el = document.createElementNS(svgNS, 'svg');\n const path = document.createElementNS(svgNS, 'path');\n\n el.setAttribute('viewBox', '0 0 33 30');\n path.setAttribute('d', 'M16.75 31 31.705 5.566A3 3 0 0 0 29.146 1H4.354a3 3 0 0 0-2.56 4.566L16.75 31z');\n path.setAttribute('stroke', '#979797');\n path.setAttribute('fill', DEFAULT_FILL_COLOR);\n\n el.appendChild(path);\n\n this.style(el, {\n width: this.markerWidth + 'px',\n height: this.markerHeight + 'px',\n cursor: 'pointer',\n 'z-index': 5\n });\n return el;\n }\n\n _createPlayheadElement() {\n const el = document.createElement('playhead');\n el.className = 'wavesurfer-playhead';\n\n this.style(el, {\n position: 'absolute',\n height: '100%',\n display: 'flex',\n 'flex-direction': 'column'\n });\n\n const pointer = this._createPointerSVG();\n el.appendChild(pointer);\n\n pointer.addEventListener('click', e => {\n e.stopPropagation();\n this.wavesurfer.setCurrentTime(this.playheadTime);\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\n el.appendChild(line);\n\n this.element = el;\n this.wrapper.appendChild(el);\n }\n\n _updatePlayheadPosition() {\n if (!this.element) {\n return;\n }\n\n const duration = this.wavesurfer.getDuration();\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n\n const positionPct = this.playheadTime / duration;\n this.style(this.element, {\n left: ((elementWidth * positionPct) - (this.markerWidth / 2)) + 'px'\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__(374);\n"],"names":["root","factory","exports","module","define","amd","self","PlayheadPlugin","params","ws","this","options","forEach","opt","wavesurfer","util","style","markerWidth","markerHeight","playheadTime","unFuns","_onResize","_updatePlayheadPosition","_onReady","wrapper","drawer","name","deferInit","instance","draw","_createPlayheadElement","window","addEventListener","wavesurferOn","returnOnPause","setCurrentTime","moveOnSeek","getCurrentTime","ev","fn","ret","on","push","un","isReady","_onBackendCreated","once","f","removeChild","element","removeEventListener","time","isPlaying","svgNS","el","document","createElementNS","path","setAttribute","appendChild","width","height","cursor","createElement","className","position","display","pointer","_createPointerSVG","e","stopPropagation","line","background","opacity","duration","getDuration","elementWidth","pixelRatio","positionPct","left","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"wavesurfer.playhead.min.js","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,CAAC,EAAGA,EAAiB,WAAY,SAAIC,IACjF,CATD,CASGK,MAAM,IACT,M,wQCkBA,IAEqBC,EAAAA,WA2BjB,WAAYC,EAAQC,GAAI,Y,4FAAA,SACpBC,KAAKF,OAASA,EACdE,KAAKC,QAAU,CAAC,EAEhB,CAAC,OAAQ,aAAc,iBAAiBC,SAAQ,SAAAC,GAExC,EAAKF,QAAQE,KADbA,KAAOL,IACaA,EAAOK,EAIlC,IAGDH,KAAKI,WAAaL,EAClBC,KAAKK,KAAON,EAAGM,KACfL,KAAKM,MAAQN,KAAKK,KAAKC,MACvBN,KAAKO,YAAc,GACnBP,KAAKQ,aAAe,GACpBR,KAAKS,aAAe,EACpBT,KAAKU,OAAS,GAEdV,KAAKW,UAAY,WACb,EAAKC,yBACR,EAEDZ,KAAKa,SAAW,WACZ,EAAKC,QAAU,EAAKV,WAAWW,OAAOD,QACtC,EAAKF,yBACR,CACJ,C,4CAtCD,SAAcd,GACV,MAAO,CACHkB,KAAM,WACNC,aAAWnB,IAAUA,EAAOmB,YAAYnB,EAAOmB,UAC/CnB,OAAQA,EACRoB,SAAUrB,EAEjB,K,kCAiCD,WAAoB,WAChBG,KAAKc,QAAUd,KAAKI,WAAWW,OAAOD,QAElCd,KAAKC,QAAQkB,OACbnB,KAAKoB,yBACLC,OAAOC,iBAAiB,SAAUtB,KAAKW,WAAW,GAClDU,OAAOC,iBAAi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ASgF,GAG/C/E,EAAOD,OACf,CCnB0BgF,CAAoB,K,UHO9C","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/playhead/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/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\"][\"playhead\"] = factory();\n})(self, () => {\nreturn ","\n/**\n * The playhead plugin separates the notion of the currently playing position from\n * a 'play-start' position. Having a playhead enables a listening pattern\n * (commonly found in DAWs) that involves listening to a section of a track\n * repeatedly, rather than listening to an entire track in a linear fashion.\n *\n * @implements {PluginClass}\n *\n * @example\n * import PlayheadPlugin from 'wavesurfer.playhead.js';\n *\n * // if you are using <script> tags\n * var PlayheadPlugin = window.WaveSurfer.playhead;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * PlayheadPlugin.create({\n * movePlayheadOnSeek: true,\n * drawPlayhead: false,\n * movePlayheadOnPause: false\n * })\n * ]\n * });\n */\n\nconst DEFAULT_FILL_COLOR = '#CF2F00';\n\nexport default class PlayheadPlugin {\n /**\n * @typedef {Object} PlayheadPluginParams\n * @property {?boolean} draw=true Draw the playhead as a triangle/line\n * @property {?boolean} moveOnSeek=true Seeking (via clicking) while playing moves the playhead\n * @property {?boolean} returnOnPause=true Pausing the track returns the seek position to the playhead\n */\n\n /**\n * Playhead 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 {PlayheadPluginParams} params parameters use to initialise the plugin\n * @since 5.0.0\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'playhead',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: PlayheadPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.options = {};\n\n ['draw', 'moveOnSeek', 'returnOnPause'].forEach(opt => {\n if (opt in params) {\n this.options[opt] = params[opt];\n } else {\n this.options[opt] = true;\n }\n });\n\n\n this.wavesurfer = ws;\n this.util = ws.util;\n this.style = this.util.style;\n this.markerWidth = 21;\n this.markerHeight = 16;\n this.playheadTime = 0;\n this.unFuns = [];\n\n this._onResize = () => {\n this._updatePlayheadPosition();\n };\n\n this._onReady = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this._updatePlayheadPosition();\n };\n }\n\n _onBackendCreated() {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n\n if (this.options.draw) {\n this._createPlayheadElement();\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n\n this.wavesurferOn('zoom', this._onResize);\n }\n\n this.wavesurferOn('pause', () => {\n if ( this.options.returnOnPause ) {\n this.wavesurfer.setCurrentTime(this.playheadTime);\n }\n });\n\n this.wavesurferOn('seek', () => {\n if ( this.options.moveOnSeek ) {\n this.playheadTime = this.wavesurfer.getCurrentTime();\n this._updatePlayheadPosition();\n }\n });\n\n this.playheadTime = this.wavesurfer.getCurrentTime();\n }\n\n wavesurferOn(ev, fn) {\n let ret = this.wavesurfer.on(ev, fn);\n this.unFuns.push(() => {\n this.wavesurfer.un(ev, fn);\n });\n return ret;\n }\n\n init() {\n if (this.wavesurfer.isReady) {\n this._onBackendCreated();\n this._onReady();\n } else {\n let r;\n\n this.wavesurfer.once('ready', () => this._onReady());\n this.wavesurfer.once('backend-created', () => this._onBackendCreated());\n }\n }\n\n destroy() {\n this.unFuns.forEach(f => f());\n this.unFuns = [];\n\n this.wrapper.removeChild(this.element);\n\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n }\n\n setPlayheadTime(time) {\n this.playheadTime = time;\n\n if (!this.wavesurfer.isPlaying()) {\n this.wavesurfer.setCurrentTime(time);\n }\n this._updatePlayheadPosition();\n }\n\n _createPointerSVG() {\n const svgNS = 'http://www.w3.org/2000/svg';\n\n const el = document.createElementNS(svgNS, 'svg');\n const path = document.createElementNS(svgNS, 'path');\n\n el.setAttribute('viewBox', '0 0 33 30');\n path.setAttribute('d', 'M16.75 31 31.705 5.566A3 3 0 0 0 29.146 1H4.354a3 3 0 0 0-2.56 4.566L16.75 31z');\n path.setAttribute('stroke', '#979797');\n path.setAttribute('fill', DEFAULT_FILL_COLOR);\n\n el.appendChild(path);\n\n this.style(el, {\n width: this.markerWidth + 'px',\n height: this.markerHeight + 'px',\n cursor: 'pointer',\n 'z-index': 5\n });\n return el;\n }\n\n _createPlayheadElement() {\n const el = document.createElement('playhead');\n el.className = 'wavesurfer-playhead';\n\n this.style(el, {\n position: 'absolute',\n height: '100%',\n display: 'flex',\n 'flex-direction': 'column'\n });\n\n const pointer = this._createPointerSVG();\n el.appendChild(pointer);\n\n pointer.addEventListener('click', e => {\n e.stopPropagation();\n this.wavesurfer.setCurrentTime(this.playheadTime);\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\n el.appendChild(line);\n\n this.element = el;\n this.wrapper.appendChild(el);\n }\n\n _updatePlayheadPosition() {\n if (!this.element) {\n return;\n }\n\n const duration = this.wavesurfer.getDuration();\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n\n const positionPct = this.playheadTime / duration;\n this.style(this.element, {\n left: ((elementWidth * positionPct) - (this.markerWidth / 2)) + 'px'\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__(374);\n"],"names":["root","factory","exports","module","define","amd","self","PlayheadPlugin","params","ws","this","options","forEach","opt","wavesurfer","util","style","markerWidth","markerHeight","playheadTime","unFuns","_onResize","_updatePlayheadPosition","_onReady","wrapper","drawer","name","deferInit","instance","draw","_createPlayheadElement","window","addEventListener","wavesurferOn","returnOnPause","setCurrentTime","moveOnSeek","getCurrentTime","ev","fn","ret","on","push","un","isReady","_onBackendCreated","once","f","removeChild","element","removeEventListener","time","isPlaying","svgNS","el","document","createElementNS","path","setAttribute","appendChild","width","height","cursor","createElement","className","position","display","pointer","_createPointerSVG","e","stopPropagation","line","background","opacity","duration","getDuration","elementWidth","pixelRatio","positionPct","left","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wavesurfer.js regions plugin 6.
|
|
2
|
+
* wavesurfer.js regions plugin 6.3.0 (2022-10-03)
|
|
3
3
|
* https://wavesurfer-js.org
|
|
4
4
|
* @license BSD-3-Clause
|
|
5
5
|
*/
|
|
@@ -272,7 +272,7 @@ var RegionsPlugin = /*#__PURE__*/function () {
|
|
|
272
272
|
maxScroll = _this4.wrapper.scrollWidth - _this4.wrapper.clientWidth;
|
|
273
273
|
wrapperRect = _this4.util.withOrientation(_this4.wrapper.getBoundingClientRect(), _this4.vertical); // set the region channel index based on the clicked area
|
|
274
274
|
|
|
275
|
-
if (_this4.wavesurfer.params.splitChannels) {
|
|
275
|
+
if (_this4.wavesurfer.params.splitChannels && _this4.wavesurfer.params.splitChannelsOptions.splitDragSelection) {
|
|
276
276
|
var y = (e.touches ? e.touches[0].clientY : e.clientY) - wrapperRect.top;
|
|
277
277
|
var channelCount = _this4.wavesurfer.backend.buffer != null ? _this4.wavesurfer.backend.buffer.numberOfChannels : 1;
|
|
278
278
|
var channelHeight = _this4.wrapper.clientHeight / channelCount;
|