wavesurfer.js 5.1.0 → 6.0.2
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 +47 -0
- package/README.md +10 -0
- package/dist/plugin/wavesurfer.cursor.js +53 -51
- 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 +10 -7
- 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 +142 -26
- 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 +6 -6
- 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 +5 -5
- 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 +26 -23
- 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 +5 -5
- 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 +88 -21
- 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 +71 -58
- 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 +52 -54
- 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 +6 -6
- 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 +302 -133
- 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 +23 -23
- package/src/drawer.canvasentry.js +33 -6
- package/src/drawer.js +1 -0
- package/src/drawer.multicanvas.js +19 -8
- package/src/mediaelement.js +1 -1
- package/src/plugin/cursor/index.js +68 -70
- package/src/plugin/markers/index.js +112 -23
- package/src/plugin/minimap/index.js +24 -21
- package/src/plugin/regions/index.js +31 -4
- package/src/plugin/regions/region.js +45 -8
- package/src/plugin/spectrogram/index.js +65 -50
- package/src/plugin/timeline/index.js +11 -9
- package/src/util/index.js +1 -0
- package/src/util/silence-mode.js +35 -0
- package/src/wavesurfer.js +54 -23
- package/src/webaudio.js +10 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/playhead/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"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"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD,O;;;;;;;;;;;;;;;;;;;;;;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,IAAMA,kBAAkB,GAAG,SAA3B;;IAEqBC,c;AA2BjB,0BAAYC,MAAZ,EAAoBC,EAApB,EAAwB;AAAA;;AAAA;;AACpB,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,OAAL,GAAe,EAAf;AAEA,KAAC,MAAD,EAAS,YAAT,EAAuB,eAAvB,EAAwCC,OAAxC,CAAgD,UAAAC,GAAG,EAAI;AACnD,UAAIA,GAAG,IAAIJ,MAAX,EAAmB;AACf,aAAI,CAACE,OAAL,CAAaE,GAAb,IAAoBJ,MAAM,CAACI,GAAD,CAA1B;AACH,OAFD,MAEO;AACH,aAAI,CAACF,OAAL,CAAaE,GAAb,IAAoB,IAApB;AACH;AACJ,KAND;AASA,SAAKC,UAAL,GAAkBJ,EAAlB;AACA,SAAKK,IAAL,GAAYL,EAAE,CAACK,IAAf;AACA,SAAKC,KAAL,GAAa,KAAKD,IAAL,CAAUC,KAAvB;AACA,SAAKC,WAAL,GAAmB,EAAnB;AACA,SAAKC,YAAL,GAAoB,EAApB;AACA,SAAKC,YAAL,GAAoB,CAAp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js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"playhead\"] = factory();\n})(this, function() {\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"],"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,SAA3B;;IAEqBC;AA2BjB,0BAAYC,MAAZ,EAAoBC,EAApB,EAAwB;AAAA;;AAAA;;AACpB,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,OAAL,GAAe,EAAf;AAEA,KAAC,MAAD,EAAS,YAAT,EAAuB,eAAvB,EAAwCC,OAAxC,CAAgD,UAAAC,GAAG,EAAI;AACnD,UAAIA,GAAG,IAAIJ,MAAX,EAAmB;AACf,aAAI,CAACE,OAAL,CAAaE,GAAb,IAAoBJ,MAAM,CAACI,GAAD,CAA1B;AACH,OAFD,MAEO;AACH,aAAI,CAACF,OAAL,CAAaE,GAAb,IAAoB,IAApB;AACH;AACJ,KAND;AASA,SAAKC,UAAL,GAAkBJ,EAAlB;AACA,SAAKK,IAAL,GAAYL,EAAE,CAACK,IAAf;AACA,SAAKC,KAAL,GAAa,KAAKD,IAAL,CAAUC,KAAvB;AACA,SAAKC,WAAL,GAAmB,EAAnB;AACA,SAAKC,YAAL,GAAoB,EAApB;AACA,SAAKC,YAAL,GAAoB,CAApB;AACA,SAAKC,MAAL,GAAc,EAAd;;AAEA,SAAKC,SAAL,GAAiB,YAAM;AACnB,W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UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UEtBA;UACA;UACA;UACA","sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/playhead/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/before-startup","webpack://WaveSurfer.[name]/webpack/startup","webpack://WaveSurfer.[name]/webpack/after-startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"playhead\"] = factory();\n})(self, function() {\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,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wavesurfer.js playhead plugin
|
|
2
|
+
* wavesurfer.js playhead plugin 6.0.2 (2022-02-20)
|
|
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())}(
|
|
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,(function(){return(()=>{"use strict";var e={374:(e,t)=>{function r(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(){function e(t,r){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=t,this.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,i,n;return t=e,n=[{key:"create",value:function(t){return{name:"playhead",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,instance:e}}}],(i=[{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"})}}}])&&r(t.prototype,i),n&&r(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=i,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,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/playhead/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"names":["root","factory","exports","module","define","amd","this","PlayheadPlugin","params","ws","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_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,QAAoB,WAAID,KAExBD,EAAiB,WAAIA,EAAiB,YAAK,GAAIA,EAAiB,WAAY,SAAIC,KARlF,CASGK,MAAM,WACT,M,8QCkBA,IAEqBC,E,WA2BjB,WAAYC,EAAQC,GAAI,Y,4FAAA,SACpBH,KAAKE,OAASA,EACdF,KAAKI,QAAU,GAEf,CAAC,OAAQ,aAAc,iBAAiBC,SAAQ,SAAAC,GAExC,EAAKF,QAAQE,KADbA,KAAOJ,IACaA,EAAO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C,KAAK0C,QAAV,CAIA,IAAMyB,EAAWnE,KAAKO,WAAW6D,cAC3BC,EACFrE,KAAKO,WAAWW,OAAOmC,MACvBrD,KAAKO,WAAWL,OAAOoE,WAErBC,EAAcvE,KAAKY,aAAeuD,EACxCnE,KAAKS,MAAMT,KAAK0C,QAAS,CACrB8B,KAAQH,EAAeE,EAAgBvE,KAAKU,YAAc,EAAM,a,kEC7NxE+D,EAA2B,G,OAG/B,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAahF,QAGrB,IAAIC,EAAS4E,EAAyBE,GAAY,CAGjD/E,QAAS,IAOV,OAHAkF,EAAoBH,GAAU9E,EAAQA,EAAOD,QAAS8E,GAG/C7E,EAAOD,QClBW8E,CAAoB,M","file":"wavesurfer.playhead.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"playhead\"] = factory();\n})(this, function() {\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"],"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,GAAIA,EAAiB,WAAY,SAAIC,KARlF,CASGK,MAAM,WACT,Y,wQCkBA,IAEqBC,EAAAA,WA2BjB,WAAYC,EAAQC,GAAI,Y,4FAAA,SACpBC,KAAKF,OAASA,EACdE,KAAKC,QAAU,GAEf,CAAC,OAAQ,aAAc,iBAAiBC,SAAQ,SAAAC,GAExC,EAAKF,QAAQE,KADbA,KAAOL,IACaA,EAAOK,MAOn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AAMyB,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.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/playhead/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"playhead\"] = factory();\n})(self, function() {\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
|
|
2
|
+
* wavesurfer.js regions plugin 6.0.2 (2022-02-20)
|
|
3
3
|
* https://wavesurfer-js.org
|
|
4
4
|
* @license BSD-3-Clause
|
|
5
5
|
*/
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
exports["WaveSurfer"] = factory();
|
|
13
13
|
else
|
|
14
14
|
root["WaveSurfer"] = root["WaveSurfer"] || {}, root["WaveSurfer"]["regions"] = factory();
|
|
15
|
-
})(
|
|
15
|
+
})(self, function() {
|
|
16
16
|
return /******/ (() => { // webpackBootstrap
|
|
17
17
|
/******/ "use strict";
|
|
18
18
|
/******/ var __webpack_modules__ = ({
|
|
@@ -28,13 +28,13 @@ return /******/ (() => { // webpackBootstrap
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", ({
|
|
29
29
|
value: true
|
|
30
30
|
}));
|
|
31
|
-
exports
|
|
31
|
+
exports["default"] = void 0;
|
|
32
32
|
|
|
33
33
|
var _region = __webpack_require__(/*! ./region.js */ "./src/plugin/regions/region.js");
|
|
34
34
|
|
|
35
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
35
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
36
36
|
|
|
37
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
37
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
38
38
|
|
|
39
39
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
40
40
|
|
|
@@ -42,7 +42,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
42
42
|
|
|
43
43
|
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); } }
|
|
44
44
|
|
|
45
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
45
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* Regions are visual overlays on waveform that can be used to play and loop
|
|
@@ -95,18 +95,17 @@ var RegionsPlugin = /*#__PURE__*/function () {
|
|
|
95
95
|
_region.Region.prototype[key] = _this.util.Observer.prototype[key];
|
|
96
96
|
});
|
|
97
97
|
this.wavesurfer.Region = _region.Region; // By default, scroll the container if the user drags a region
|
|
98
|
-
// within 5% of its edge
|
|
98
|
+
// within 5% (based on its initial size) of its edge
|
|
99
99
|
|
|
100
100
|
var scrollWidthProportion = 0.05;
|
|
101
101
|
|
|
102
102
|
this._onBackendCreated = function () {
|
|
103
103
|
_this.wrapper = _this.wavesurfer.drawer.wrapper;
|
|
104
104
|
_this.orientation = _this.wavesurfer.drawer.orientation;
|
|
105
|
+
_this.defaultEdgeScrollWidth = _this.wrapper.clientWidth * scrollWidthProportion;
|
|
105
106
|
|
|
106
107
|
if (_this.params.regions) {
|
|
107
108
|
_this.params.regions.forEach(function (region) {
|
|
108
|
-
region.edgeScrollWidth = _this.params.edgeScrollWidth || _this.wrapper.clientWidth * scrollWidthProportion;
|
|
109
|
-
|
|
110
109
|
_this.add(region);
|
|
111
110
|
});
|
|
112
111
|
}
|
|
@@ -146,7 +145,12 @@ var RegionsPlugin = /*#__PURE__*/function () {
|
|
|
146
145
|
key: "destroy",
|
|
147
146
|
value: function destroy() {
|
|
148
147
|
this.wavesurfer.un('ready', this._onReady);
|
|
149
|
-
this.wavesurfer.un('backend-created', this._onBackendCreated);
|
|
148
|
+
this.wavesurfer.un('backend-created', this._onBackendCreated); // Disabling `region-removed' because destroying the plugin calls
|
|
149
|
+
// the Region.remove() method that is also used to remove regions based
|
|
150
|
+
// on user input. This can cause confusion since teardown is not a
|
|
151
|
+
// user event, but would emit `region-removed` as if it was.
|
|
152
|
+
|
|
153
|
+
this.wavesurfer.setDisabledEventEmissions(['region-removed']);
|
|
150
154
|
this.disableDragSelection();
|
|
151
155
|
this.clear();
|
|
152
156
|
}
|
|
@@ -177,6 +181,16 @@ var RegionsPlugin = /*#__PURE__*/function () {
|
|
|
177
181
|
return null;
|
|
178
182
|
}
|
|
179
183
|
|
|
184
|
+
params = _objectSpread({
|
|
185
|
+
edgeScrollWidth: this.params.edgeScrollWidth || this.defaultEdgeScrollWidth
|
|
186
|
+
}, params); // Take formatTimeCallback from plugin params if not already set
|
|
187
|
+
|
|
188
|
+
if (!params.formatTimeCallback && this.params.formatTimeCallback) {
|
|
189
|
+
params = _objectSpread(_objectSpread({}, params), {}, {
|
|
190
|
+
formatTimeCallback: this.params.formatTimeCallback
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
180
194
|
if (!params.minLength && this.regionsMinLength) {
|
|
181
195
|
params = _objectSpread(_objectSpread({}, params), {}, {
|
|
182
196
|
minLength: this.regionsMinLength
|
|
@@ -256,7 +270,21 @@ var RegionsPlugin = /*#__PURE__*/function () {
|
|
|
256
270
|
touchId = e.targetTouches ? e.targetTouches[0].identifier : null; // Store for scroll calculations
|
|
257
271
|
|
|
258
272
|
maxScroll = _this4.wrapper.scrollWidth - _this4.wrapper.clientWidth;
|
|
259
|
-
wrapperRect = _this4.util.withOrientation(_this4.wrapper.getBoundingClientRect(), _this4.vertical);
|
|
273
|
+
wrapperRect = _this4.util.withOrientation(_this4.wrapper.getBoundingClientRect(), _this4.vertical); // set the region channel index based on the clicked area
|
|
274
|
+
|
|
275
|
+
if (_this4.wavesurfer.params.splitChannels) {
|
|
276
|
+
var y = (e.touches ? e.touches[0].clientY : e.clientY) - wrapperRect.top;
|
|
277
|
+
var channelCount = _this4.wavesurfer.backend.buffer != null ? _this4.wavesurfer.backend.buffer.numberOfChannels : 1;
|
|
278
|
+
var channelHeight = _this4.wrapper.clientHeight / channelCount;
|
|
279
|
+
var channelIdx = Math.floor(y / channelHeight);
|
|
280
|
+
params.channelIdx = channelIdx;
|
|
281
|
+
var channelColors = _this4.wavesurfer.params.splitChannelsOptions.channelColors[channelIdx];
|
|
282
|
+
|
|
283
|
+
if (channelColors && channelColors.dragColor) {
|
|
284
|
+
params.color = channelColors.dragColor;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
260
288
|
drag = true;
|
|
261
289
|
start = _this4.wavesurfer.drawer.handleEvent(e, true);
|
|
262
290
|
region = null;
|
|
@@ -479,7 +507,7 @@ var RegionsPlugin = /*#__PURE__*/function () {
|
|
|
479
507
|
return RegionsPlugin;
|
|
480
508
|
}();
|
|
481
509
|
|
|
482
|
-
exports
|
|
510
|
+
exports["default"] = RegionsPlugin;
|
|
483
511
|
module.exports = exports.default;
|
|
484
512
|
|
|
485
513
|
/***/ }),
|
|
@@ -501,7 +529,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
501
529
|
|
|
502
530
|
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); } }
|
|
503
531
|
|
|
504
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
532
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
505
533
|
|
|
506
534
|
/**
|
|
507
535
|
* @since 4.0.0
|
|
@@ -563,6 +591,7 @@ var Region = /*#__PURE__*/function () {
|
|
|
563
591
|
this.preventContextMenu = params.preventContextMenu === undefined ? false : Boolean(params.preventContextMenu); // select channel ID to set region
|
|
564
592
|
|
|
565
593
|
var channelIdx = params.channelIdx == null ? -1 : parseInt(params.channelIdx);
|
|
594
|
+
this.channelIdx = channelIdx;
|
|
566
595
|
this.regionHeight = '100%';
|
|
567
596
|
this.marginTop = '0px';
|
|
568
597
|
|
|
@@ -588,7 +617,7 @@ var Region = /*#__PURE__*/function () {
|
|
|
588
617
|
|
|
589
618
|
_createClass(Region, [{
|
|
590
619
|
key: "update",
|
|
591
|
-
value: function update(params) {
|
|
620
|
+
value: function update(params, eventParams) {
|
|
592
621
|
if (params.start != null) {
|
|
593
622
|
this.start = Number(params.start);
|
|
594
623
|
}
|
|
@@ -636,7 +665,7 @@ var Region = /*#__PURE__*/function () {
|
|
|
636
665
|
|
|
637
666
|
this.updateRender();
|
|
638
667
|
this.fireEvent('update');
|
|
639
|
-
this.wavesurfer.fireEvent('region-updated', this);
|
|
668
|
+
this.wavesurfer.fireEvent('region-updated', this, eventParams);
|
|
640
669
|
}
|
|
641
670
|
/* Remove a single region. */
|
|
642
671
|
|
|
@@ -706,7 +735,7 @@ var Region = /*#__PURE__*/function () {
|
|
|
706
735
|
|
|
707
736
|
this.style(this.element, {
|
|
708
737
|
position: 'absolute',
|
|
709
|
-
zIndex:
|
|
738
|
+
zIndex: 3,
|
|
710
739
|
height: this.regionHeight,
|
|
711
740
|
top: this.marginTop
|
|
712
741
|
});
|
|
@@ -1214,10 +1243,36 @@ var Region = /*#__PURE__*/function () {
|
|
|
1214
1243
|
delta = this.start * -1;
|
|
1215
1244
|
}
|
|
1216
1245
|
|
|
1246
|
+
var eventParams = {
|
|
1247
|
+
direction: this._getDragDirection(delta),
|
|
1248
|
+
action: 'drag'
|
|
1249
|
+
};
|
|
1217
1250
|
this.update({
|
|
1218
1251
|
start: this.start + delta,
|
|
1219
1252
|
end: this.end + delta
|
|
1220
|
-
});
|
|
1253
|
+
}, eventParams);
|
|
1254
|
+
}
|
|
1255
|
+
/**
|
|
1256
|
+
* Returns the direction of dragging region based on delta
|
|
1257
|
+
* Negative delta means region is moving to the left
|
|
1258
|
+
* Positive - to the right
|
|
1259
|
+
* For zero delta the direction is not defined
|
|
1260
|
+
* @param {number} delta Drag offset
|
|
1261
|
+
* @returns {string|null} Direction 'left', 'right' or null
|
|
1262
|
+
*/
|
|
1263
|
+
|
|
1264
|
+
}, {
|
|
1265
|
+
key: "_getDragDirection",
|
|
1266
|
+
value: function _getDragDirection(delta) {
|
|
1267
|
+
if (delta < 0) {
|
|
1268
|
+
return 'left';
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
if (delta > 0) {
|
|
1272
|
+
return 'right';
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
return null;
|
|
1221
1276
|
}
|
|
1222
1277
|
/**
|
|
1223
1278
|
* @example
|
|
@@ -1232,12 +1287,20 @@ var Region = /*#__PURE__*/function () {
|
|
|
1232
1287
|
key: "onResize",
|
|
1233
1288
|
value: function onResize(delta, direction) {
|
|
1234
1289
|
var duration = this.wavesurfer.getDuration();
|
|
1290
|
+
var eventParams = {
|
|
1291
|
+
action: 'resize',
|
|
1292
|
+
direction: direction === 'start' ? 'left' : 'right'
|
|
1293
|
+
};
|
|
1235
1294
|
|
|
1236
1295
|
if (direction === 'start') {
|
|
1237
1296
|
// Check if changing the start by the given delta would result in the region being smaller than minLength
|
|
1238
|
-
// Ignore cases where we are making the region wider rather than shrinking it
|
|
1239
1297
|
if (delta > 0 && this.end - (this.start + delta) < this.minLength) {
|
|
1240
1298
|
delta = this.end - this.minLength - this.start;
|
|
1299
|
+
} // Check if changing the start by the given delta would result in the region being larger than maxLength
|
|
1300
|
+
|
|
1301
|
+
|
|
1302
|
+
if (delta < 0 && this.end - (this.start + delta) > this.maxLength) {
|
|
1303
|
+
delta = this.end - this.start - this.maxLength;
|
|
1241
1304
|
}
|
|
1242
1305
|
|
|
1243
1306
|
if (delta < 0 && this.start + delta < 0) {
|
|
@@ -1247,12 +1310,16 @@ var Region = /*#__PURE__*/function () {
|
|
|
1247
1310
|
this.update({
|
|
1248
1311
|
start: Math.min(this.start + delta, this.end),
|
|
1249
1312
|
end: Math.max(this.start + delta, this.end)
|
|
1250
|
-
});
|
|
1313
|
+
}, eventParams);
|
|
1251
1314
|
} else {
|
|
1252
1315
|
// Check if changing the end by the given delta would result in the region being smaller than minLength
|
|
1253
|
-
// Ignore cases where we are making the region wider rather than shrinking it
|
|
1254
1316
|
if (delta < 0 && this.end + delta - this.start < this.minLength) {
|
|
1255
1317
|
delta = this.start + this.minLength - this.end;
|
|
1318
|
+
} // Check if changing the end by the given delta would result in the region being larger than maxLength
|
|
1319
|
+
|
|
1320
|
+
|
|
1321
|
+
if (delta > 0 && this.end + delta - this.start > this.maxLength) {
|
|
1322
|
+
delta = this.maxLength - (this.end - this.start);
|
|
1256
1323
|
}
|
|
1257
1324
|
|
|
1258
1325
|
if (delta > 0 && this.end + delta > duration) {
|
|
@@ -1262,7 +1329,7 @@ var Region = /*#__PURE__*/function () {
|
|
|
1262
1329
|
this.update({
|
|
1263
1330
|
start: Math.min(this.end + delta, this.start),
|
|
1264
1331
|
end: Math.max(this.end + delta, this.start)
|
|
1265
|
-
});
|
|
1332
|
+
}, eventParams);
|
|
1266
1333
|
}
|
|
1267
1334
|
}
|
|
1268
1335
|
}, {
|