wavesurfer.js 6.3.0 → 6.5.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/LICENSE +1 -1
- package/README.md +36 -47
- package/dist/plugin/wavesurfer.cursor.js +45 -54
- package/dist/plugin/wavesurfer.cursor.js.map +1 -1
- package/dist/plugin/wavesurfer.cursor.min.js +2 -2
- package/dist/plugin/wavesurfer.cursor.min.js.map +1 -1
- package/dist/plugin/wavesurfer.elan.js +24 -51
- package/dist/plugin/wavesurfer.elan.js.map +1 -1
- package/dist/plugin/wavesurfer.elan.min.js +2 -2
- package/dist/plugin/wavesurfer.elan.min.js.map +1 -1
- package/dist/plugin/wavesurfer.markers.js +62 -74
- 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 +8 -16
- package/dist/plugin/wavesurfer.mediasession.js.map +1 -1
- package/dist/plugin/wavesurfer.mediasession.min.js +2 -2
- package/dist/plugin/wavesurfer.mediasession.min.js.map +1 -1
- package/dist/plugin/wavesurfer.microphone.js +48 -63
- package/dist/plugin/wavesurfer.microphone.js.map +1 -1
- package/dist/plugin/wavesurfer.microphone.min.js +2 -2
- package/dist/plugin/wavesurfer.microphone.min.js.map +1 -1
- package/dist/plugin/wavesurfer.minimap.js +20 -69
- package/dist/plugin/wavesurfer.minimap.js.map +1 -1
- package/dist/plugin/wavesurfer.minimap.min.js +2 -2
- package/dist/plugin/wavesurfer.minimap.min.js.map +1 -1
- package/dist/plugin/wavesurfer.playhead.js +6 -30
- package/dist/plugin/wavesurfer.playhead.js.map +1 -1
- package/dist/plugin/wavesurfer.playhead.min.js +2 -2
- package/dist/plugin/wavesurfer.playhead.min.js.map +1 -1
- package/dist/plugin/wavesurfer.regions.js +203 -260
- 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 +55 -147
- 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 +53 -88
- package/dist/plugin/wavesurfer.timeline.js.map +1 -1
- package/dist/plugin/wavesurfer.timeline.min.js +2 -2
- package/dist/plugin/wavesurfer.timeline.min.js.map +1 -1
- package/dist/wavesurfer-html-init.js +34 -54
- package/dist/wavesurfer-html-init.js.map +1 -1
- package/dist/wavesurfer-html-init.min.js +2 -2
- package/dist/wavesurfer-html-init.min.js.map +1 -1
- package/dist/wavesurfer.js +490 -1003
- 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 +11 -11
- package/src/mediaelement.js +3 -0
- package/src/plugin/cursor/index.js +15 -3
- package/src/plugin/markers/index.js +40 -1
- package/src/plugin/regions/index.js +4 -0
- package/src/plugin/regions/region.js +76 -1
- package/src/util/silence-mode.js +7 -0
- package/src/wavesurfer.js +4 -0
- package/CHANGES.md +0 -482
|
@@ -1 +1 @@
|
|
|
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,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ources":["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,+yBCCA,IAyBqBC,EAAa,WAoB9B,SAAAA,EAAYC,EAAQC,GAAI,IAAAC,EAAA,KAqBpB,G,4FArBoBC,CAAA,KAAAJ,GACpBK,KAAKJ,OAASK,OAAOC,OACjB,CAAC,EACDL,EAAGD,OACH,CACIO,aAAa,EACbC,kBAAmBR,EAAOQ,mBAAqB,UAC/CC,cAAc,EACdC,oBAAqB,QACrBC,mBAAoB,EAEpBC,WAAW,EACXC,OAAQC,KAAKC,IAAID,KAAKE,MAAMf,EAAGD,OAAOa,OAAS,GAAI,KAEvDb,EACA,CACIiB,cAAc,EACdC,YAAY,IAIY,iBAArBlB,EAAOY,UAAwB,CACtC,IAAMO,EAAKC,SAASC,cAAcrB,EAAOY,WACpCO,GACDG,QAAQC,KAAK,gCAADC,OACwBxB,EAAOY,UAAS,mFAGxDR,KAAKJ,OAAOY,UAAYO,CAC5B,CAEKnB,EAAOY,YACRR,KAAKJ,OAAOY,UAAYX,EAAGwB,KAAKC,MAC5BN,SAASO,cAAc,WACvB,CACIC,QAAS,WAIrBxB,KAAKyB,OAAS,IAAI5B,EAAG6B,OAAO1B,KAAKJ,OAAOY,UAAWR,KAAKJ,QACxDI,KAAK2B,WAAa9B,EAClBG,KAAKqB,KAAOxB,EAAGwB,KACfrB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I,KAAKyB,OAAOjB,UAAUgI,YAAcxI,KAAK0D,MAC9D1D,KAAKyI,iBAAmB,EACxBzI,KAAKwD,mBACDxD,KAAK2B,WAAWF,OAAOsC,QAAQN,WAAazD,KAAK0D,OAErD1D,KAAKqB,KAAKC,MAAMtB,KAAK8B,eAAgB,CACjCmE,MAAOjG,KAAKuI,cAAgB,OAGxC,GAAC,CAAA/D,IAAA,qBAAAC,MAED,SAAmBiE,GACXA,EAAS,EACT1I,KAAKyI,iBAAmB,EAExBC,EAAS1I,KAAKuI,cACdvI,KAAKyB,OAAOjB,UAAUgI,YAEtBxI,KAAKyI,iBAAmBC,EAExB1I,KAAKyI,iBACDzI,KAAKyB,OAAOjB,UAAUgI,YAAcxI,KAAKuI,cAEjDvI,KAAKqB,KAAKC,MAAMtB,KAAK8B,eAAgB,CACjCuE,KAAMrG,KAAKyI,iBAAmB,OAE9BzI,KAAKmD,mBACLnD,KAAK2B,WAAWF,OAAOsC,QAAQN,WAC3BzD,KAAKyI,iBAAmBzI,KAAK0D,MAEzC,GAAC,CAAAc,IAAA,WAAAC,MAED,WACI,OAAOzE,KAAKyB,OAAOwE,MAAQjG,KAAKJ,OAAO+I,UAC3C,M,8EA3VChJ,CAAA,CAlB6B,GAkB7BL,EAAAA,QAAAK,EAAAJ,EAAAD,QAAAA,EAAAsJ,O,GCrDDC,EAA2B,CAAC,ECEhC,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAa3J,QAGrB,IAAIC,EAASsJ,EAAyBG,GAAY,CAGjD1J,QAAS,CAAC,GAOX,OAHA6J,EAAoBH,GAAUzJ,EAAQA,EAAOD,QAASyJ,GAG/CxJ,EAAOD,OACf,CCnB0ByJ,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","_classCallCheck","this","Object","assign","showRegions","regionsPluginName","showOverview","overviewBorderColor","overviewBorderSize","container","height","Math","max","round","scrollParent","fillParent","el","document","querySelector","console","warn","concat","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","key","value","name","deferInit","staticProps","instance","isReady","window","removeEventListener","un","destroy","unAll","_this2","regions","region","id","renderRegions","i","_this3","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","_this4","positionMouseDown","clientX","clientY","relativePositionX","seek","interact","event","fireEvent","handleEvent","seekAndCenter","domElement","layerX","getBoundingClientRect","peaks","getPeaks","waveShowedWidth","waveWidth","overviewWidth","offsetWidth","overviewPosition","pixels","pixelRatio","default","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wavesurfer.js playhead plugin 6.
|
|
2
|
+
* wavesurfer.js playhead plugin 6.5.0 (2023-03-11)
|
|
3
3
|
* https://wavesurfer-js.org
|
|
4
4
|
* @license BSD-3-Clause
|
|
5
5
|
*/
|
|
@@ -29,13 +29,12 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
29
29
|
value: true
|
|
30
30
|
}));
|
|
31
31
|
exports["default"] = void 0;
|
|
32
|
-
|
|
32
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
33
33
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
34
|
-
|
|
35
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
36
|
-
|
|
34
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
37
35
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
38
|
-
|
|
36
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
37
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
39
38
|
/**
|
|
40
39
|
* The playhead plugin separates the notion of the currently playing position from
|
|
41
40
|
* a 'play-start' position. Having a playhead enables a listening pattern
|
|
@@ -62,14 +61,12 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
62
61
|
* ]
|
|
63
62
|
* });
|
|
64
63
|
*/
|
|
65
|
-
var DEFAULT_FILL_COLOR = '#CF2F00';
|
|
66
64
|
|
|
65
|
+
var DEFAULT_FILL_COLOR = '#CF2F00';
|
|
67
66
|
var PlayheadPlugin = /*#__PURE__*/function () {
|
|
68
67
|
function PlayheadPlugin(params, ws) {
|
|
69
68
|
var _this = this;
|
|
70
|
-
|
|
71
69
|
_classCallCheck(this, PlayheadPlugin);
|
|
72
|
-
|
|
73
70
|
this.params = params;
|
|
74
71
|
this.options = {};
|
|
75
72
|
['draw', 'moveOnSeek', 'returnOnPause'].forEach(function (opt) {
|
|
@@ -86,33 +83,25 @@ var PlayheadPlugin = /*#__PURE__*/function () {
|
|
|
86
83
|
this.markerHeight = 16;
|
|
87
84
|
this.playheadTime = 0;
|
|
88
85
|
this.unFuns = [];
|
|
89
|
-
|
|
90
86
|
this._onResize = function () {
|
|
91
87
|
_this._updatePlayheadPosition();
|
|
92
88
|
};
|
|
93
|
-
|
|
94
89
|
this._onReady = function () {
|
|
95
90
|
_this.wrapper = _this.wavesurfer.drawer.wrapper;
|
|
96
|
-
|
|
97
91
|
_this._updatePlayheadPosition();
|
|
98
92
|
};
|
|
99
93
|
}
|
|
100
|
-
|
|
101
94
|
_createClass(PlayheadPlugin, [{
|
|
102
95
|
key: "_onBackendCreated",
|
|
103
96
|
value: function _onBackendCreated() {
|
|
104
97
|
var _this2 = this;
|
|
105
|
-
|
|
106
98
|
this.wrapper = this.wavesurfer.drawer.wrapper;
|
|
107
|
-
|
|
108
99
|
if (this.options.draw) {
|
|
109
100
|
this._createPlayheadElement();
|
|
110
|
-
|
|
111
101
|
window.addEventListener('resize', this._onResize, true);
|
|
112
102
|
window.addEventListener('orientationchange', this._onResize, true);
|
|
113
103
|
this.wavesurferOn('zoom', this._onResize);
|
|
114
104
|
}
|
|
115
|
-
|
|
116
105
|
this.wavesurferOn('pause', function () {
|
|
117
106
|
if (_this2.options.returnOnPause) {
|
|
118
107
|
_this2.wavesurfer.setCurrentTime(_this2.playheadTime);
|
|
@@ -121,7 +110,6 @@ var PlayheadPlugin = /*#__PURE__*/function () {
|
|
|
121
110
|
this.wavesurferOn('seek', function () {
|
|
122
111
|
if (_this2.options.moveOnSeek) {
|
|
123
112
|
_this2.playheadTime = _this2.wavesurfer.getCurrentTime();
|
|
124
|
-
|
|
125
113
|
_this2._updatePlayheadPosition();
|
|
126
114
|
}
|
|
127
115
|
});
|
|
@@ -131,7 +119,6 @@ var PlayheadPlugin = /*#__PURE__*/function () {
|
|
|
131
119
|
key: "wavesurferOn",
|
|
132
120
|
value: function wavesurferOn(ev, fn) {
|
|
133
121
|
var _this3 = this;
|
|
134
|
-
|
|
135
122
|
var ret = this.wavesurfer.on(ev, fn);
|
|
136
123
|
this.unFuns.push(function () {
|
|
137
124
|
_this3.wavesurfer.un(ev, fn);
|
|
@@ -142,10 +129,8 @@ var PlayheadPlugin = /*#__PURE__*/function () {
|
|
|
142
129
|
key: "init",
|
|
143
130
|
value: function init() {
|
|
144
131
|
var _this4 = this;
|
|
145
|
-
|
|
146
132
|
if (this.wavesurfer.isReady) {
|
|
147
133
|
this._onBackendCreated();
|
|
148
|
-
|
|
149
134
|
this._onReady();
|
|
150
135
|
} else {
|
|
151
136
|
var r;
|
|
@@ -172,11 +157,9 @@ var PlayheadPlugin = /*#__PURE__*/function () {
|
|
|
172
157
|
key: "setPlayheadTime",
|
|
173
158
|
value: function setPlayheadTime(time) {
|
|
174
159
|
this.playheadTime = time;
|
|
175
|
-
|
|
176
160
|
if (!this.wavesurfer.isPlaying()) {
|
|
177
161
|
this.wavesurfer.setCurrentTime(time);
|
|
178
162
|
}
|
|
179
|
-
|
|
180
163
|
this._updatePlayheadPosition();
|
|
181
164
|
}
|
|
182
165
|
}, {
|
|
@@ -202,7 +185,6 @@ var PlayheadPlugin = /*#__PURE__*/function () {
|
|
|
202
185
|
key: "_createPlayheadElement",
|
|
203
186
|
value: function _createPlayheadElement() {
|
|
204
187
|
var _this5 = this;
|
|
205
|
-
|
|
206
188
|
var el = document.createElement('playhead');
|
|
207
189
|
el.className = 'wavesurfer-playhead';
|
|
208
190
|
this.style(el, {
|
|
@@ -211,13 +193,10 @@ var PlayheadPlugin = /*#__PURE__*/function () {
|
|
|
211
193
|
display: 'flex',
|
|
212
194
|
'flex-direction': 'column'
|
|
213
195
|
});
|
|
214
|
-
|
|
215
196
|
var pointer = this._createPointerSVG();
|
|
216
|
-
|
|
217
197
|
el.appendChild(pointer);
|
|
218
198
|
pointer.addEventListener('click', function (e) {
|
|
219
199
|
e.stopPropagation();
|
|
220
|
-
|
|
221
200
|
_this5.wavesurfer.setCurrentTime(_this5.playheadTime);
|
|
222
201
|
});
|
|
223
202
|
var line = document.createElement('div');
|
|
@@ -238,7 +217,6 @@ var PlayheadPlugin = /*#__PURE__*/function () {
|
|
|
238
217
|
if (!this.element) {
|
|
239
218
|
return;
|
|
240
219
|
}
|
|
241
|
-
|
|
242
220
|
var duration = this.wavesurfer.getDuration();
|
|
243
221
|
var elementWidth = this.wavesurfer.drawer.width / this.wavesurfer.params.pixelRatio;
|
|
244
222
|
var positionPct = this.playheadTime / duration;
|
|
@@ -275,10 +253,8 @@ var PlayheadPlugin = /*#__PURE__*/function () {
|
|
|
275
253
|
};
|
|
276
254
|
}
|
|
277
255
|
}]);
|
|
278
|
-
|
|
279
256
|
return PlayheadPlugin;
|
|
280
257
|
}();
|
|
281
|
-
|
|
282
258
|
exports["default"] = PlayheadPlugin;
|
|
283
259
|
module.exports = exports.default;
|
|
284
260
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wavesurfer.playhead.js","mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD;;;;;;;;;;;;;;;;;;;;;;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,IAAMA,kBAAkB,GAAG,SAA3B;;IAEqBC;EA2BjB,wBAAYC,MAAZ,EAAoBC,EAApB,EAAwB;IAAA;;IAAA;;IACpB,KAAKD,MAAL,GAAcA,MAAd;IACA,KAAKE,OAAL,GAAe,EAAf;IAEA,CAAC,MAAD,EAAS,YAAT,EAAuB,eAAvB,EAAwCC,OAAxC,CAAgD,UAAAC,GAAG,EAAI;MACnD,IAAIA,GAAG,IAAIJ,MAAX,EAAmB;QACf,KAAI,CAACE,OAAL,CAAaE,GAAb,IAAoBJ,MAAM,CAACI,GAAD,CAA1B;MACH,CAFD,MAEO;QACH,KAAI,CAACF,OAAL,CAAaE,GAAb,IAAoB,IAApB;MACH;IACJ,CAND;IASA,KAAKC,UAAL,GAAkBJ,EAAlB;IACA,KAAKK,IAAL,GAAYL,EAAE,CAACK,IAAf;IACA,KAAKC,KAAL,GAAa,KAAKD,IAAL,CAAUC,KAAvB;IACA,KAAKC,WAAL,GAAmB,EAAnB;IACA,KAAKC,YAAL,GAAoB,EAApB;IACA,KAAKC,YAAL,GAAoB,CAApB;IACA,KAAKC,MAAL,GAAc,EAAd;;IAEA,KAAKC,SAAL,GAAiB,YAAM;MACnB,KAAI,CAACC,uBAAL;IACH,CAFD;;IAIA,KAAKC,QAAL,GAAgB,YAAM;MAClB,KAAI,CAACC,OAAL,GAAe,KAAI,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AH,CAAeY,IAAf;MAEA,KAAKtB,OAAL,GAAeK,EAAf;MACA,KAAK5B,OAAL,CAAaiC,WAAb,CAAyBL,EAAzB;IACH;;;WAED,mCAA0B;MACtB,IAAI,CAAC,KAAKL,OAAV,EAAmB;QACf;MACH;;MAED,IAAMyB,QAAQ,GAAG,KAAK1D,UAAL,CAAgB2D,WAAhB,EAAjB;MACA,IAAMC,YAAY,GACd,KAAK5D,UAAL,CAAgBW,MAAhB,CAAuBiC,KAAvB,GACA,KAAK5C,UAAL,CAAgBL,MAAhB,CAAuBkE,UAF3B;MAIA,IAAMC,WAAW,GAAG,KAAKzD,YAAL,GAAoBqD,QAAxC;MACA,KAAKxD,KAAL,CAAW,KAAK+B,OAAhB,EAAyB;QACrB8B,IAAI,EAAIH,YAAY,GAAGE,WAAhB,GAAgC,KAAK3D,WAAL,GAAmB,CAApD,GAA0D;MAD3C,CAAzB;IAGH;;;;IAjMD;AACJ;AACA;AACA;AACA;AACA;;IAEI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACI,gBAAcR,MAAd,EAAsB;MAClB,OAAO;QACHqE,IAAI,EAAE,UADH;QAEHC,SAAS,EAAEtE,MAAM,IAAIA,MAAM,CAACsE,SAAjB,GAA6BtE,MAAM,CAACsE,SAApC,GAAgD,KAFxD;QAGHtE,MAAM,EAAEA,MAHL;QAIHuE,QAAQ,EAAExE;MAJP,CAAP;IAMH;;;;;;;;;;;;;UCvDL;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UEtBA;UACA;UACA;UACA","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/playhead/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/before-startup","webpack://WaveSurfer/webpack/startup","webpack://WaveSurfer/webpack/after-startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"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__(\"./src/plugin/playhead/index.js\");\n",""],"names":["DEFAULT_FILL_COLOR","PlayheadPlugin","params","ws","options","forEach","opt","wavesurfer","util","style","markerWidth","markerHeight","playheadTime","unFuns","_onResize","_updatePlayheadPosition","_onReady","wrapper","drawer","draw","_createPlayheadElement","window","addEventListener","wavesurferOn","returnOnPause","setCurrentTime","moveOnSeek","getCurrentTime","ev","fn","ret","on","push","un","isReady","_onBackendCreated","r","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","name","deferInit","instance"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"wavesurfer.playhead.js","mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD;;;;;;;;;;;;;;;;;;;;;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAMA,kBAAkB,GAAG,SAAS;AAAC,IAEhBC,cAAc;EA2B/B,SAAAA,eAAYC,MAAM,EAAEC,EAAE,EAAE;IAAA,IAAAC,KAAA;IAAAC,eAAA,OAAAJ,cAAA;IACpB,IAAI,CAACC,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACI,OAAO,GAAG,CAAC,CAAC;IAEjB,CAAC,MAAM,EAAE,YAAY,EAAE,eAAe,CAAC,CAACC,OAAO,CAAC,UAAAC,GAAG,EAAI;MACnD,IAAIA,GAAG,IAAIN,MAAM,EAAE;QACfE,KAAI,C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ACA;UACA;;;;UEtBA;UACA;UACA;UACA","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/playhead/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/before-startup","webpack://WaveSurfer/webpack/startup","webpack://WaveSurfer/webpack/after-startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"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__(\"./src/plugin/playhead/index.js\");\n",""],"names":["DEFAULT_FILL_COLOR","PlayheadPlugin","params","ws","_this","_classCallCheck","options","forEach","opt","wavesurfer","util","style","markerWidth","markerHeight","playheadTime","unFuns","_onResize","_updatePlayheadPosition","_onReady","wrapper","drawer","_createClass","key","value","_onBackendCreated","_this2","draw","_createPlayheadElement","window","addEventListener","wavesurferOn","returnOnPause","setCurrentTime","moveOnSeek","getCurrentTime","ev","fn","_this3","ret","on","push","un","init","_this4","isReady","r","once","destroy","f","removeChild","element","removeEventListener","setPlayheadTime","time","isPlaying","_createPointerSVG","svgNS","el","document","createElementNS","path","setAttribute","appendChild","width","height","cursor","_this5","createElement","className","position","display","pointer","e","stopPropagation","line","background","opacity","duration","getDuration","elementWidth","pixelRatio","positionPct","left","create","name","deferInit","instance","exports","default","module"],"sourceRoot":""}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wavesurfer.js playhead plugin 6.
|
|
2
|
+
* wavesurfer.js playhead plugin 6.5.0 (2023-03-11)
|
|
3
3
|
* https://wavesurfer-js.org
|
|
4
4
|
* @license BSD-3-Clause
|
|
5
5
|
*/
|
|
6
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.playhead=t())}(self,(()=>(()=>{"use strict";var e={374:(e,t)=>{function r(e,t){for(var
|
|
6
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.playhead=t())}(self,(()=>(()=>{"use strict";var e={374:(e,t)=>{function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function i(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(a=n.key,s=void 0,s=function(e,t){if("object"!==r(e)||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!==r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(a,"string"),"symbol"===r(s)?s:String(s)),n)}var a,s}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=function(){function e(t,r){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=t,this.options={},["draw","moveOnSeek","returnOnPause"].forEach((function(e){i.options[e]=!(e in t)||t[e]})),this.wavesurfer=r,this.util=r.util,this.style=this.util.style,this.markerWidth=21,this.markerHeight=16,this.playheadTime=0,this.unFuns=[],this._onResize=function(){i._updatePlayheadPosition()},this._onReady=function(){i.wrapper=i.wavesurfer.drawer.wrapper,i._updatePlayheadPosition()}}var t,r,n;return t=e,n=[{key:"create",value:function(t){return{name:"playhead",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,instance:e}}}],(r=[{key:"_onBackendCreated",value:function(){var e=this;this.wrapper=this.wavesurfer.drawer.wrapper,this.options.draw&&(this._createPlayheadElement(),window.addEventListener("resize",this._onResize,!0),window.addEventListener("orientationchange",this._onResize,!0),this.wavesurferOn("zoom",this._onResize)),this.wavesurferOn("pause",(function(){e.options.returnOnPause&&e.wavesurfer.setCurrentTime(e.playheadTime)})),this.wavesurferOn("seek",(function(){e.options.moveOnSeek&&(e.playheadTime=e.wavesurfer.getCurrentTime(),e._updatePlayheadPosition())})),this.playheadTime=this.wavesurfer.getCurrentTime()}},{key:"wavesurferOn",value:function(e,t){var r=this,i=this.wavesurfer.on(e,t);return this.unFuns.push((function(){r.wavesurfer.un(e,t)})),i}},{key:"init",value:function(){var e=this;this.wavesurfer.isReady?(this._onBackendCreated(),this._onReady()):(this.wavesurfer.once("ready",(function(){return e._onReady()})),this.wavesurfer.once("backend-created",(function(){return e._onBackendCreated()})))}},{key:"destroy",value:function(){this.unFuns.forEach((function(e){return e()})),this.unFuns=[],this.wrapper.removeChild(this.element),window.removeEventListener("resize",this._onResize,!0),window.removeEventListener("orientationchange",this._onResize,!0)}},{key:"setPlayheadTime",value:function(e){this.playheadTime=e,this.wavesurfer.isPlaying()||this.wavesurfer.setCurrentTime(e),this._updatePlayheadPosition()}},{key:"_createPointerSVG",value:function(){var e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"svg"),r=document.createElementNS(e,"path");return t.setAttribute("viewBox","0 0 33 30"),r.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"),r.setAttribute("stroke","#979797"),r.setAttribute("fill","#CF2F00"),t.appendChild(r),this.style(t,{width:this.markerWidth+"px",height:this.markerHeight+"px",cursor:"pointer","z-index":5}),t}},{key:"_createPlayheadElement",value:function(){var e=this,t=document.createElement("playhead");t.className="wavesurfer-playhead",this.style(t,{position:"absolute",height:"100%",display:"flex","flex-direction":"column"});var r=this._createPointerSVG();t.appendChild(r),r.addEventListener("click",(function(t){t.stopPropagation(),e.wavesurfer.setCurrentTime(e.playheadTime)}));var i=document.createElement("div");this.style(i,{"flex-grow":1,"margin-left":this.markerWidth/2-.5+"px",background:"black",width:"1px",opacity:.1}),t.appendChild(i),this.element=t,this.wrapper.appendChild(t)}},{key:"_updatePlayheadPosition",value:function(){if(this.element){var e=this.wavesurfer.getDuration(),t=this.wavesurfer.drawer.width/this.wavesurfer.params.pixelRatio,r=this.playheadTime/e;this.style(this.element,{left:t*r-this.markerWidth/2+"px"})}}}])&&i(t.prototype,r),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=n,e.exports=t.default}},t={};var r=function r(i){var n=t[i];if(void 0!==n)return n.exports;var a=t[i]={exports:{}};return e[i](a,a.exports,r),a.exports}(374);return r})()));
|
|
7
7
|
//# sourceMappingURL=wavesurfer.playhead.min.js.map
|
|
@@ -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,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,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AAcpE,KAAKS,aAAeuD,EACxChE,KAAKM,MAAMN,KAAKuC,QAAS,CACrB8B,KAAQH,EAAeE,EAAgBpE,KAAKO,YAAc,EAAM,MATnE,CAWJ,M,gFAlMgBV,G,kCC7BjByE,EAA2B,CAAC,ECEhC,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAalF,QAGrB,IAAIC,EAAS6E,EAAyBG,GAAY,CAGjDjF,QAAS,CAAC,GAOX,OAHAoF,EAAoBH,GAAUhF,EAAQA,EAAOD,QAASgF,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
|
+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AA,CAzB8B,GAyB9BL,EAAAA,QAAAK,EAAAJ,EAAAD,QAAAA,EAAAsF,O,GCtDDC,EAA2B,CAAC,ECEhC,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAa3F,QAGrB,IAAIC,EAASsF,EAAyBG,GAAY,CAGjD1F,QAAS,CAAC,GAOX,OAHA6F,EAAoBH,GAAUzF,EAAQA,EAAOD,QAASyF,GAG/CxF,EAAOD,OACf,CCnB0ByF,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","_classCallCheck","this","options","forEach","opt","wavesurfer","util","style","markerWidth","markerHeight","playheadTime","unFuns","_onResize","_updatePlayheadPosition","_onReady","wrapper","drawer","key","value","name","deferInit","instance","_this2","draw","_createPlayheadElement","window","addEventListener","wavesurferOn","returnOnPause","setCurrentTime","moveOnSeek","getCurrentTime","ev","fn","_this3","ret","on","push","un","_this4","isReady","_onBackendCreated","once","f","removeChild","element","removeEventListener","time","isPlaying","svgNS","el","document","createElementNS","path","setAttribute","appendChild","width","height","cursor","_this5","createElement","className","position","display","pointer","_createPointerSVG","e","stopPropagation","line","background","opacity","duration","getDuration","elementWidth","pixelRatio","positionPct","left","default","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
|