wavesurfer.js 4.5.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/CHANGES.md +36 -1
  2. package/README.md +6 -3
  3. package/dist/plugin/wavesurfer.cursor.js +39 -34
  4. package/dist/plugin/wavesurfer.cursor.js.map +1 -1
  5. package/dist/plugin/wavesurfer.cursor.min.js +2 -2
  6. package/dist/plugin/wavesurfer.cursor.min.js.map +1 -1
  7. package/dist/plugin/wavesurfer.elan.js +29 -27
  8. package/dist/plugin/wavesurfer.elan.js.map +1 -1
  9. package/dist/plugin/wavesurfer.elan.min.js +2 -2
  10. package/dist/plugin/wavesurfer.elan.min.js.map +1 -1
  11. package/dist/plugin/wavesurfer.markers.js +381 -0
  12. package/dist/plugin/wavesurfer.markers.js.map +1 -0
  13. package/dist/plugin/wavesurfer.markers.min.js +7 -0
  14. package/dist/plugin/wavesurfer.markers.min.js.map +1 -0
  15. package/dist/plugin/wavesurfer.mediasession.js +29 -27
  16. package/dist/plugin/wavesurfer.mediasession.js.map +1 -1
  17. package/dist/plugin/wavesurfer.mediasession.min.js +2 -2
  18. package/dist/plugin/wavesurfer.mediasession.min.js.map +1 -1
  19. package/dist/plugin/wavesurfer.microphone.js +29 -27
  20. package/dist/plugin/wavesurfer.microphone.js.map +1 -1
  21. package/dist/plugin/wavesurfer.microphone.min.js +2 -2
  22. package/dist/plugin/wavesurfer.microphone.min.js.map +1 -1
  23. package/dist/plugin/wavesurfer.minimap.js +30 -28
  24. package/dist/plugin/wavesurfer.minimap.js.map +1 -1
  25. package/dist/plugin/wavesurfer.minimap.min.js +2 -2
  26. package/dist/plugin/wavesurfer.minimap.min.js.map +1 -1
  27. package/dist/plugin/wavesurfer.playhead.js +324 -0
  28. package/dist/plugin/wavesurfer.playhead.js.map +1 -0
  29. package/dist/plugin/wavesurfer.playhead.min.js +7 -0
  30. package/dist/plugin/wavesurfer.playhead.min.js.map +1 -0
  31. package/dist/plugin/wavesurfer.regions.js +152 -126
  32. package/dist/plugin/wavesurfer.regions.js.map +1 -1
  33. package/dist/plugin/wavesurfer.regions.min.js +2 -2
  34. package/dist/plugin/wavesurfer.regions.min.js.map +1 -1
  35. package/dist/plugin/wavesurfer.spectrogram.js +97 -89
  36. package/dist/plugin/wavesurfer.spectrogram.js.map +1 -1
  37. package/dist/plugin/wavesurfer.spectrogram.min.js +2 -2
  38. package/dist/plugin/wavesurfer.spectrogram.min.js.map +1 -1
  39. package/dist/plugin/wavesurfer.timeline.js +46 -32
  40. package/dist/plugin/wavesurfer.timeline.js.map +1 -1
  41. package/dist/plugin/wavesurfer.timeline.min.js +2 -2
  42. package/dist/plugin/wavesurfer.timeline.min.js.map +1 -1
  43. package/dist/wavesurfer-html-init.js +9 -5
  44. package/dist/wavesurfer-html-init.js.map +1 -1
  45. package/dist/wavesurfer-html-init.min.js +2 -2
  46. package/dist/wavesurfer-html-init.min.js.map +1 -1
  47. package/dist/wavesurfer.js +350 -166
  48. package/dist/wavesurfer.js.map +1 -1
  49. package/dist/wavesurfer.min.js +2 -2
  50. package/dist/wavesurfer.min.js.map +1 -1
  51. package/package.json +19 -16
  52. package/src/drawer.canvasentry.js +16 -0
  53. package/src/drawer.js +30 -21
  54. package/src/drawer.multicanvas.js +63 -39
  55. package/src/plugin/cursor/index.js +3 -1
  56. package/src/plugin/markers/index.js +282 -0
  57. package/src/plugin/playhead/index.js +226 -0
  58. package/src/plugin/regions/index.js +28 -11
  59. package/src/plugin/regions/region.js +83 -70
  60. package/src/plugin/spectrogram/index.js +65 -61
  61. package/src/plugin/timeline/index.js +20 -11
  62. package/src/util/index.js +1 -0
  63. package/src/util/orientation.js +98 -0
  64. package/src/wavesurfer.js +18 -9
  65. package/src/webaudio.js +10 -9
@@ -0,0 +1,324 @@
1
+ /*!
2
+ * wavesurfer.js playhead plugin 5.1.0 (2021-06-20)
3
+ * https://wavesurfer-js.org
4
+ * @license BSD-3-Clause
5
+ */
6
+ (function webpackUniversalModuleDefinition(root, factory) {
7
+ if(typeof exports === 'object' && typeof module === 'object')
8
+ module.exports = factory();
9
+ else if(typeof define === 'function' && define.amd)
10
+ define("WaveSurfer", [], factory);
11
+ else if(typeof exports === 'object')
12
+ exports["WaveSurfer"] = factory();
13
+ else
14
+ root["WaveSurfer"] = root["WaveSurfer"] || {}, root["WaveSurfer"]["playhead"] = factory();
15
+ })(this, function() {
16
+ return /******/ (() => { // webpackBootstrap
17
+ /******/ "use strict";
18
+ /******/ var __webpack_modules__ = ({
19
+
20
+ /***/ "./src/plugin/playhead/index.js":
21
+ /*!**************************************!*\
22
+ !*** ./src/plugin/playhead/index.js ***!
23
+ \**************************************/
24
+ /***/ ((module, exports) => {
25
+
26
+
27
+
28
+ Object.defineProperty(exports, "__esModule", ({
29
+ value: true
30
+ }));
31
+ exports.default = void 0;
32
+
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
+
37
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
38
+
39
+ /**
40
+ * The playhead plugin separates the notion of the currently playing position from
41
+ * a 'play-start' position. Having a playhead enables a listening pattern
42
+ * (commonly found in DAWs) that involves listening to a section of a track
43
+ * repeatedly, rather than listening to an entire track in a linear fashion.
44
+ *
45
+ * @implements {PluginClass}
46
+ *
47
+ * @example
48
+ * import PlayheadPlugin from 'wavesurfer.playhead.js';
49
+ *
50
+ * // if you are using <script> tags
51
+ * var PlayheadPlugin = window.WaveSurfer.playhead;
52
+ *
53
+ * // ... initialising wavesurfer with the plugin
54
+ * var wavesurfer = WaveSurfer.create({
55
+ * // wavesurfer options ...
56
+ * plugins: [
57
+ * PlayheadPlugin.create({
58
+ * movePlayheadOnSeek: true,
59
+ * drawPlayhead: false,
60
+ * movePlayheadOnPause: false
61
+ * })
62
+ * ]
63
+ * });
64
+ */
65
+ var DEFAULT_FILL_COLOR = '#CF2F00';
66
+
67
+ var PlayheadPlugin = /*#__PURE__*/function () {
68
+ function PlayheadPlugin(params, ws) {
69
+ var _this = this;
70
+
71
+ _classCallCheck(this, PlayheadPlugin);
72
+
73
+ this.params = params;
74
+ this.options = {};
75
+ ['draw', 'moveOnSeek', 'returnOnPause'].forEach(function (opt) {
76
+ if (opt in params) {
77
+ _this.options[opt] = params[opt];
78
+ } else {
79
+ _this.options[opt] = true;
80
+ }
81
+ });
82
+ this.wavesurfer = ws;
83
+ this.util = ws.util;
84
+ this.style = this.util.style;
85
+ this.markerWidth = 21;
86
+ this.markerHeight = 16;
87
+ this.playheadTime = 0;
88
+ this.unFuns = [];
89
+
90
+ this._onResize = function () {
91
+ _this._updatePlayheadPosition();
92
+ };
93
+
94
+ this._onReady = function () {
95
+ _this.wrapper = _this.wavesurfer.drawer.wrapper;
96
+
97
+ _this._updatePlayheadPosition();
98
+ };
99
+ }
100
+
101
+ _createClass(PlayheadPlugin, [{
102
+ key: "_onBackendCreated",
103
+ value: function _onBackendCreated() {
104
+ var _this2 = this;
105
+
106
+ this.wrapper = this.wavesurfer.drawer.wrapper;
107
+
108
+ if (this.options.draw) {
109
+ this._createPlayheadElement();
110
+
111
+ window.addEventListener('resize', this._onResize, true);
112
+ window.addEventListener('orientationchange', this._onResize, true);
113
+ this.wavesurferOn('zoom', this._onResize);
114
+ }
115
+
116
+ this.wavesurferOn('pause', function () {
117
+ if (_this2.options.returnOnPause) {
118
+ _this2.wavesurfer.setCurrentTime(_this2.playheadTime);
119
+ }
120
+ });
121
+ this.wavesurferOn('seek', function () {
122
+ if (_this2.options.moveOnSeek) {
123
+ _this2.playheadTime = _this2.wavesurfer.getCurrentTime();
124
+
125
+ _this2._updatePlayheadPosition();
126
+ }
127
+ });
128
+ this.playheadTime = this.wavesurfer.getCurrentTime();
129
+ }
130
+ }, {
131
+ key: "wavesurferOn",
132
+ value: function wavesurferOn(ev, fn) {
133
+ var _this3 = this;
134
+
135
+ var ret = this.wavesurfer.on(ev, fn);
136
+ this.unFuns.push(function () {
137
+ _this3.wavesurfer.un(ev, fn);
138
+ });
139
+ return ret;
140
+ }
141
+ }, {
142
+ key: "init",
143
+ value: function init() {
144
+ var _this4 = this;
145
+
146
+ if (this.wavesurfer.isReady) {
147
+ this._onBackendCreated();
148
+
149
+ this._onReady();
150
+ } else {
151
+ var r;
152
+ this.wavesurfer.once('ready', function () {
153
+ return _this4._onReady();
154
+ });
155
+ this.wavesurfer.once('backend-created', function () {
156
+ return _this4._onBackendCreated();
157
+ });
158
+ }
159
+ }
160
+ }, {
161
+ key: "destroy",
162
+ value: function destroy() {
163
+ this.unFuns.forEach(function (f) {
164
+ return f();
165
+ });
166
+ this.unFuns = [];
167
+ this.wrapper.removeChild(this.element);
168
+ window.removeEventListener('resize', this._onResize, true);
169
+ window.removeEventListener('orientationchange', this._onResize, true);
170
+ }
171
+ }, {
172
+ key: "setPlayheadTime",
173
+ value: function setPlayheadTime(time) {
174
+ this.playheadTime = time;
175
+
176
+ if (!this.wavesurfer.isPlaying()) {
177
+ this.wavesurfer.setCurrentTime(time);
178
+ }
179
+
180
+ this._updatePlayheadPosition();
181
+ }
182
+ }, {
183
+ key: "_createPointerSVG",
184
+ value: function _createPointerSVG() {
185
+ var svgNS = 'http://www.w3.org/2000/svg';
186
+ var el = document.createElementNS(svgNS, 'svg');
187
+ var path = document.createElementNS(svgNS, 'path');
188
+ el.setAttribute('viewBox', '0 0 33 30');
189
+ 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');
190
+ path.setAttribute('stroke', '#979797');
191
+ path.setAttribute('fill', DEFAULT_FILL_COLOR);
192
+ el.appendChild(path);
193
+ this.style(el, {
194
+ width: this.markerWidth + 'px',
195
+ height: this.markerHeight + 'px',
196
+ cursor: 'pointer',
197
+ 'z-index': 5
198
+ });
199
+ return el;
200
+ }
201
+ }, {
202
+ key: "_createPlayheadElement",
203
+ value: function _createPlayheadElement() {
204
+ var _this5 = this;
205
+
206
+ var el = document.createElement('playhead');
207
+ el.className = 'wavesurfer-playhead';
208
+ this.style(el, {
209
+ position: 'absolute',
210
+ height: '100%',
211
+ display: 'flex',
212
+ 'flex-direction': 'column'
213
+ });
214
+
215
+ var pointer = this._createPointerSVG();
216
+
217
+ el.appendChild(pointer);
218
+ pointer.addEventListener('click', function (e) {
219
+ e.stopPropagation();
220
+
221
+ _this5.wavesurfer.setCurrentTime(_this5.playheadTime);
222
+ });
223
+ var line = document.createElement('div');
224
+ this.style(line, {
225
+ 'flex-grow': 1,
226
+ 'margin-left': this.markerWidth / 2 - 0.5 + 'px',
227
+ background: 'black',
228
+ width: '1px',
229
+ opacity: 0.1
230
+ });
231
+ el.appendChild(line);
232
+ this.element = el;
233
+ this.wrapper.appendChild(el);
234
+ }
235
+ }, {
236
+ key: "_updatePlayheadPosition",
237
+ value: function _updatePlayheadPosition() {
238
+ if (!this.element) {
239
+ return;
240
+ }
241
+
242
+ var duration = this.wavesurfer.getDuration();
243
+ var elementWidth = this.wavesurfer.drawer.width / this.wavesurfer.params.pixelRatio;
244
+ var positionPct = this.playheadTime / duration;
245
+ this.style(this.element, {
246
+ left: elementWidth * positionPct - this.markerWidth / 2 + 'px'
247
+ });
248
+ }
249
+ }], [{
250
+ key: "create",
251
+ value:
252
+ /**
253
+ * @typedef {Object} PlayheadPluginParams
254
+ * @property {?boolean} draw=true Draw the playhead as a triangle/line
255
+ * @property {?boolean} moveOnSeek=true Seeking (via clicking) while playing moves the playhead
256
+ * @property {?boolean} returnOnPause=true Pausing the track returns the seek position to the playhead
257
+ */
258
+
259
+ /**
260
+ * Playhead plugin definition factory
261
+ *
262
+ * This function must be used to create a plugin definition which can be
263
+ * used by wavesurfer to correctly instantiate the plugin.
264
+ *
265
+ * @param {PlayheadPluginParams} params parameters use to initialise the plugin
266
+ * @since 5.0.0
267
+ * @return {PluginDefinition} an object representing the plugin
268
+ */
269
+ function create(params) {
270
+ return {
271
+ name: 'playhead',
272
+ deferInit: params && params.deferInit ? params.deferInit : false,
273
+ params: params,
274
+ instance: PlayheadPlugin
275
+ };
276
+ }
277
+ }]);
278
+
279
+ return PlayheadPlugin;
280
+ }();
281
+
282
+ exports.default = PlayheadPlugin;
283
+ module.exports = exports.default;
284
+
285
+ /***/ })
286
+
287
+ /******/ });
288
+ /************************************************************************/
289
+ /******/ // The module cache
290
+ /******/ var __webpack_module_cache__ = {};
291
+ /******/
292
+ /******/ // The require function
293
+ /******/ function __webpack_require__(moduleId) {
294
+ /******/ // Check if module is in cache
295
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
296
+ /******/ if (cachedModule !== undefined) {
297
+ /******/ return cachedModule.exports;
298
+ /******/ }
299
+ /******/ // Create a new module (and put it into the cache)
300
+ /******/ var module = __webpack_module_cache__[moduleId] = {
301
+ /******/ // no module.id needed
302
+ /******/ // no module.loaded needed
303
+ /******/ exports: {}
304
+ /******/ };
305
+ /******/
306
+ /******/ // Execute the module function
307
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
308
+ /******/
309
+ /******/ // Return the exports of the module
310
+ /******/ return module.exports;
311
+ /******/ }
312
+ /******/
313
+ /************************************************************************/
314
+ /******/
315
+ /******/ // startup
316
+ /******/ // Load entry module and return exports
317
+ /******/ // This entry module is referenced by other modules so it can't be inlined
318
+ /******/ var __webpack_exports__ = __webpack_require__("./src/plugin/playhead/index.js");
319
+ /******/
320
+ /******/ return __webpack_exports__;
321
+ /******/ })()
322
+ ;
323
+ });
324
+ //# sourceMappingURL=wavesurfer.playhead.js.map
@@ -0,0 +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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,EAAExE;AAJP,OAAP;AAMH;;;;;;;;;;;;;UCvDL;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UCtBA;UACA;UACA;UACA","file":"wavesurfer.playhead.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":""}
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * wavesurfer.js playhead plugin 5.1.0 (2021-06-20)
3
+ * https://wavesurfer-js.org
4
+ * @license BSD-3-Clause
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())}(this,(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),e}();t.default=i,e.exports=t.default}},t={};return function r(i){var n=t[i];if(void 0!==n)return n.exports;var a=t[i]={exports:{}};return e[i](a,a.exports,r),a.exports}(374)})()}));
7
+ //# sourceMappingURL=wavesurfer.playhead.min.js.map
@@ -0,0 +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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tB,IAAMC,EAAU5D,KAAK6D,oBACrBd,EAAGK,YAAYQ,GAEfA,EAAQnC,iBAAiB,SAAS,SAAAqC,GAC9BA,EAAEC,kBACF,EAAKxD,WAAWqB,eAAe,EAAKhB,iBAGxC,IAAMoD,EAAOhB,SAASQ,cAAc,OACpCxD,KAAKS,MAAMuD,EAAM,CACb,YAAa,EACb,cAAgBhE,KAAKU,YAAc,EAAI,GAAO,KAC9CuD,WAAY,QACZZ,MAAO,MACPa,QAAS,KAGbnB,EAAGK,YAAYY,GAEfhE,KAAK0C,QAAUK,EACf/C,KAAKiB,QAAQmC,YAAYL,K,qCAG7B,WACI,GAAK/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":""}