wavesurfer.js 6.5.1 → 7.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +24 -0
- package/.prettierrc +8 -0
- package/README.md +26 -117
- package/dist/base-plugin.d.ts +10 -0
- package/dist/base-plugin.js +13 -0
- package/dist/decoder.d.ts +10 -0
- package/dist/decoder.js +43 -0
- package/dist/event-emitter.d.ts +11 -0
- package/dist/event-emitter.js +21 -0
- package/dist/fetcher.d.ts +4 -0
- package/dist/fetcher.js +17 -0
- package/dist/index.d.ts +92 -0
- package/dist/index.js +166 -0
- package/dist/player-webaudio.d.ts +8 -0
- package/dist/player-webaudio.js +31 -0
- package/dist/player.d.ts +16 -0
- package/dist/player.js +40 -0
- package/dist/plugins/regions.d.ts +48 -0
- package/dist/plugins/regions.js +183 -0
- package/dist/renderer.d.ts +34 -0
- package/dist/renderer.js +193 -0
- package/dist/timer.d.ts +10 -0
- package/dist/timer.js +17 -0
- package/examples/audio.ogg +0 -0
- package/examples/bars.js +19 -0
- package/examples/basic.js +8 -0
- package/examples/gradient.js +28 -0
- package/examples/regions.js +63 -0
- package/examples/video.js +19 -0
- package/examples/webaudio.js +14 -0
- package/package.json +19 -99
- package/src/base-plugin.ts +20 -0
- package/src/decoder.ts +41 -0
- package/src/event-emitter.ts +35 -0
- package/src/fetcher.ts +7 -0
- package/src/index.ts +252 -0
- package/src/player-webaudio.ts +34 -0
- package/src/player.ts +50 -0
- package/src/plugins/regions.ts +240 -0
- package/src/renderer.ts +250 -0
- package/src/timer.ts +27 -0
- package/tsconfig.json +105 -0
- package/tutorial/index.html +47 -0
- package/tutorial/src/editor.js +70 -0
- package/tutorial/src/init.js +66 -0
- package/tutorial/src/url.js +25 -0
- package/tutorial/style.css +211 -0
- package/yarn-error.log +1049 -0
- package/LICENSE +0 -29
- package/dist/plugin/wavesurfer.cursor.js +0 -418
- package/dist/plugin/wavesurfer.cursor.js.map +0 -1
- package/dist/plugin/wavesurfer.cursor.min.js +0 -7
- package/dist/plugin/wavesurfer.cursor.min.js.map +0 -1
- package/dist/plugin/wavesurfer.elan.js +0 -381
- package/dist/plugin/wavesurfer.elan.js.map +0 -1
- package/dist/plugin/wavesurfer.elan.min.js +0 -7
- package/dist/plugin/wavesurfer.elan.min.js.map +0 -1
- package/dist/plugin/wavesurfer.markers.js +0 -520
- package/dist/plugin/wavesurfer.markers.js.map +0 -1
- package/dist/plugin/wavesurfer.markers.min.js +0 -7
- package/dist/plugin/wavesurfer.markers.min.js.map +0 -1
- package/dist/plugin/wavesurfer.mediasession.js +0 -181
- package/dist/plugin/wavesurfer.mediasession.js.map +0 -1
- package/dist/plugin/wavesurfer.mediasession.min.js +0 -7
- package/dist/plugin/wavesurfer.mediasession.min.js.map +0 -1
- package/dist/plugin/wavesurfer.microphone.js +0 -466
- package/dist/plugin/wavesurfer.microphone.js.map +0 -1
- package/dist/plugin/wavesurfer.microphone.min.js +0 -7
- package/dist/plugin/wavesurfer.microphone.min.js.map +0 -1
- package/dist/plugin/wavesurfer.minimap.js +0 -440
- package/dist/plugin/wavesurfer.minimap.js.map +0 -1
- package/dist/plugin/wavesurfer.minimap.min.js +0 -7
- package/dist/plugin/wavesurfer.minimap.min.js.map +0 -1
- package/dist/plugin/wavesurfer.playhead.js +0 -300
- package/dist/plugin/wavesurfer.playhead.js.map +0 -1
- package/dist/plugin/wavesurfer.playhead.min.js +0 -7
- package/dist/plugin/wavesurfer.playhead.min.js.map +0 -1
- package/dist/plugin/wavesurfer.regions.js +0 -1335
- package/dist/plugin/wavesurfer.regions.js.map +0 -1
- package/dist/plugin/wavesurfer.regions.min.js +0 -7
- package/dist/plugin/wavesurfer.regions.min.js.map +0 -1
- package/dist/plugin/wavesurfer.spectrogram.js +0 -736
- package/dist/plugin/wavesurfer.spectrogram.js.map +0 -1
- package/dist/plugin/wavesurfer.spectrogram.min.js +0 -7
- package/dist/plugin/wavesurfer.spectrogram.min.js.map +0 -1
- package/dist/plugin/wavesurfer.timeline.js +0 -649
- package/dist/plugin/wavesurfer.timeline.js.map +0 -1
- package/dist/plugin/wavesurfer.timeline.min.js +0 -7
- package/dist/plugin/wavesurfer.timeline.min.js.map +0 -1
- package/dist/wavesurfer-html-init.js +0 -381
- package/dist/wavesurfer-html-init.js.map +0 -1
- package/dist/wavesurfer-html-init.min.js +0 -7
- package/dist/wavesurfer-html-init.min.js.map +0 -1
- package/dist/wavesurfer.js +0 -6145
- package/dist/wavesurfer.js.map +0 -1
- package/dist/wavesurfer.min.js +0 -7
- package/dist/wavesurfer.min.js.map +0 -1
- package/src/drawer.canvasentry.js +0 -427
- package/src/drawer.js +0 -413
- package/src/drawer.multicanvas.js +0 -617
- package/src/html-init.js +0 -241
- package/src/mediaelement-webaudio.js +0 -77
- package/src/mediaelement.js +0 -443
- package/src/peakcache.js +0 -127
- package/src/plugin/cursor/index.js +0 -350
- package/src/plugin/elan/index.js +0 -307
- package/src/plugin/markers/index.js +0 -436
- package/src/plugin/mediasession/index.js +0 -94
- package/src/plugin/microphone/index.js +0 -415
- package/src/plugin/minimap/index.js +0 -403
- package/src/plugin/playhead/index.js +0 -226
- package/src/plugin/regions/index.js +0 -478
- package/src/plugin/regions/region.js +0 -875
- package/src/plugin/spectrogram/fft.js +0 -222
- package/src/plugin/spectrogram/index.js +0 -522
- package/src/plugin/timeline/index.js +0 -600
- package/src/util/absMax.js +0 -16
- package/src/util/clamp.js +0 -11
- package/src/util/fetch.js +0 -222
- package/src/util/frame.js +0 -13
- package/src/util/get-id.js +0 -22
- package/src/util/index.js +0 -14
- package/src/util/max.js +0 -16
- package/src/util/min.js +0 -16
- package/src/util/observer.js +0 -144
- package/src/util/orientation.js +0 -98
- package/src/util/prevent-click.js +0 -19
- package/src/util/request-animation-frame.js +0 -15
- package/src/util/silence-mode.js +0 -42
- package/src/util/style.js +0 -16
- package/src/wavesurfer.js +0 -1797
- package/src/webaudio.js +0 -779
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* wavesurfer.js playhead plugin 6.5.1 (2023-03-12)
|
|
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
|
-
})(self, () => {
|
|
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
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
33
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
34
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
35
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
36
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
37
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
38
|
-
/**
|
|
39
|
-
* The playhead plugin separates the notion of the currently playing position from
|
|
40
|
-
* a 'play-start' position. Having a playhead enables a listening pattern
|
|
41
|
-
* (commonly found in DAWs) that involves listening to a section of a track
|
|
42
|
-
* repeatedly, rather than listening to an entire track in a linear fashion.
|
|
43
|
-
*
|
|
44
|
-
* @implements {PluginClass}
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* import PlayheadPlugin from 'wavesurfer.playhead.js';
|
|
48
|
-
*
|
|
49
|
-
* // if you are using <script> tags
|
|
50
|
-
* var PlayheadPlugin = window.WaveSurfer.playhead;
|
|
51
|
-
*
|
|
52
|
-
* // ... initialising wavesurfer with the plugin
|
|
53
|
-
* var wavesurfer = WaveSurfer.create({
|
|
54
|
-
* // wavesurfer options ...
|
|
55
|
-
* plugins: [
|
|
56
|
-
* PlayheadPlugin.create({
|
|
57
|
-
* movePlayheadOnSeek: true,
|
|
58
|
-
* drawPlayhead: false,
|
|
59
|
-
* movePlayheadOnPause: false
|
|
60
|
-
* })
|
|
61
|
-
* ]
|
|
62
|
-
* });
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
var DEFAULT_FILL_COLOR = '#CF2F00';
|
|
66
|
-
var PlayheadPlugin = /*#__PURE__*/function () {
|
|
67
|
-
function PlayheadPlugin(params, ws) {
|
|
68
|
-
var _this = this;
|
|
69
|
-
_classCallCheck(this, PlayheadPlugin);
|
|
70
|
-
this.params = params;
|
|
71
|
-
this.options = {};
|
|
72
|
-
['draw', 'moveOnSeek', 'returnOnPause'].forEach(function (opt) {
|
|
73
|
-
if (opt in params) {
|
|
74
|
-
_this.options[opt] = params[opt];
|
|
75
|
-
} else {
|
|
76
|
-
_this.options[opt] = true;
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
this.wavesurfer = ws;
|
|
80
|
-
this.util = ws.util;
|
|
81
|
-
this.style = this.util.style;
|
|
82
|
-
this.markerWidth = 21;
|
|
83
|
-
this.markerHeight = 16;
|
|
84
|
-
this.playheadTime = 0;
|
|
85
|
-
this.unFuns = [];
|
|
86
|
-
this._onResize = function () {
|
|
87
|
-
_this._updatePlayheadPosition();
|
|
88
|
-
};
|
|
89
|
-
this._onReady = function () {
|
|
90
|
-
_this.wrapper = _this.wavesurfer.drawer.wrapper;
|
|
91
|
-
_this._updatePlayheadPosition();
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
_createClass(PlayheadPlugin, [{
|
|
95
|
-
key: "_onBackendCreated",
|
|
96
|
-
value: function _onBackendCreated() {
|
|
97
|
-
var _this2 = this;
|
|
98
|
-
this.wrapper = this.wavesurfer.drawer.wrapper;
|
|
99
|
-
if (this.options.draw) {
|
|
100
|
-
this._createPlayheadElement();
|
|
101
|
-
window.addEventListener('resize', this._onResize, true);
|
|
102
|
-
window.addEventListener('orientationchange', this._onResize, true);
|
|
103
|
-
this.wavesurferOn('zoom', this._onResize);
|
|
104
|
-
}
|
|
105
|
-
this.wavesurferOn('pause', function () {
|
|
106
|
-
if (_this2.options.returnOnPause) {
|
|
107
|
-
_this2.wavesurfer.setCurrentTime(_this2.playheadTime);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
this.wavesurferOn('seek', function () {
|
|
111
|
-
if (_this2.options.moveOnSeek) {
|
|
112
|
-
_this2.playheadTime = _this2.wavesurfer.getCurrentTime();
|
|
113
|
-
_this2._updatePlayheadPosition();
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
this.playheadTime = this.wavesurfer.getCurrentTime();
|
|
117
|
-
}
|
|
118
|
-
}, {
|
|
119
|
-
key: "wavesurferOn",
|
|
120
|
-
value: function wavesurferOn(ev, fn) {
|
|
121
|
-
var _this3 = this;
|
|
122
|
-
var ret = this.wavesurfer.on(ev, fn);
|
|
123
|
-
this.unFuns.push(function () {
|
|
124
|
-
_this3.wavesurfer.un(ev, fn);
|
|
125
|
-
});
|
|
126
|
-
return ret;
|
|
127
|
-
}
|
|
128
|
-
}, {
|
|
129
|
-
key: "init",
|
|
130
|
-
value: function init() {
|
|
131
|
-
var _this4 = this;
|
|
132
|
-
if (this.wavesurfer.isReady) {
|
|
133
|
-
this._onBackendCreated();
|
|
134
|
-
this._onReady();
|
|
135
|
-
} else {
|
|
136
|
-
var r;
|
|
137
|
-
this.wavesurfer.once('ready', function () {
|
|
138
|
-
return _this4._onReady();
|
|
139
|
-
});
|
|
140
|
-
this.wavesurfer.once('backend-created', function () {
|
|
141
|
-
return _this4._onBackendCreated();
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}, {
|
|
146
|
-
key: "destroy",
|
|
147
|
-
value: function destroy() {
|
|
148
|
-
this.unFuns.forEach(function (f) {
|
|
149
|
-
return f();
|
|
150
|
-
});
|
|
151
|
-
this.unFuns = [];
|
|
152
|
-
this.wrapper.removeChild(this.element);
|
|
153
|
-
window.removeEventListener('resize', this._onResize, true);
|
|
154
|
-
window.removeEventListener('orientationchange', this._onResize, true);
|
|
155
|
-
}
|
|
156
|
-
}, {
|
|
157
|
-
key: "setPlayheadTime",
|
|
158
|
-
value: function setPlayheadTime(time) {
|
|
159
|
-
this.playheadTime = time;
|
|
160
|
-
if (!this.wavesurfer.isPlaying()) {
|
|
161
|
-
this.wavesurfer.setCurrentTime(time);
|
|
162
|
-
}
|
|
163
|
-
this._updatePlayheadPosition();
|
|
164
|
-
}
|
|
165
|
-
}, {
|
|
166
|
-
key: "_createPointerSVG",
|
|
167
|
-
value: function _createPointerSVG() {
|
|
168
|
-
var svgNS = 'http://www.w3.org/2000/svg';
|
|
169
|
-
var el = document.createElementNS(svgNS, 'svg');
|
|
170
|
-
var path = document.createElementNS(svgNS, 'path');
|
|
171
|
-
el.setAttribute('viewBox', '0 0 33 30');
|
|
172
|
-
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');
|
|
173
|
-
path.setAttribute('stroke', '#979797');
|
|
174
|
-
path.setAttribute('fill', DEFAULT_FILL_COLOR);
|
|
175
|
-
el.appendChild(path);
|
|
176
|
-
this.style(el, {
|
|
177
|
-
width: this.markerWidth + 'px',
|
|
178
|
-
height: this.markerHeight + 'px',
|
|
179
|
-
cursor: 'pointer',
|
|
180
|
-
'z-index': 5
|
|
181
|
-
});
|
|
182
|
-
return el;
|
|
183
|
-
}
|
|
184
|
-
}, {
|
|
185
|
-
key: "_createPlayheadElement",
|
|
186
|
-
value: function _createPlayheadElement() {
|
|
187
|
-
var _this5 = this;
|
|
188
|
-
var el = document.createElement('playhead');
|
|
189
|
-
el.className = 'wavesurfer-playhead';
|
|
190
|
-
this.style(el, {
|
|
191
|
-
position: 'absolute',
|
|
192
|
-
height: '100%',
|
|
193
|
-
display: 'flex',
|
|
194
|
-
'flex-direction': 'column'
|
|
195
|
-
});
|
|
196
|
-
var pointer = this._createPointerSVG();
|
|
197
|
-
el.appendChild(pointer);
|
|
198
|
-
pointer.addEventListener('click', function (e) {
|
|
199
|
-
e.stopPropagation();
|
|
200
|
-
_this5.wavesurfer.setCurrentTime(_this5.playheadTime);
|
|
201
|
-
});
|
|
202
|
-
var line = document.createElement('div');
|
|
203
|
-
this.style(line, {
|
|
204
|
-
'flex-grow': 1,
|
|
205
|
-
'margin-left': this.markerWidth / 2 - 0.5 + 'px',
|
|
206
|
-
background: 'black',
|
|
207
|
-
width: '1px',
|
|
208
|
-
opacity: 0.1
|
|
209
|
-
});
|
|
210
|
-
el.appendChild(line);
|
|
211
|
-
this.element = el;
|
|
212
|
-
this.wrapper.appendChild(el);
|
|
213
|
-
}
|
|
214
|
-
}, {
|
|
215
|
-
key: "_updatePlayheadPosition",
|
|
216
|
-
value: function _updatePlayheadPosition() {
|
|
217
|
-
if (!this.element) {
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
var duration = this.wavesurfer.getDuration();
|
|
221
|
-
var elementWidth = this.wavesurfer.drawer.width / this.wavesurfer.params.pixelRatio;
|
|
222
|
-
var positionPct = this.playheadTime / duration;
|
|
223
|
-
this.style(this.element, {
|
|
224
|
-
left: elementWidth * positionPct - this.markerWidth / 2 + 'px'
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
}], [{
|
|
228
|
-
key: "create",
|
|
229
|
-
value:
|
|
230
|
-
/**
|
|
231
|
-
* @typedef {Object} PlayheadPluginParams
|
|
232
|
-
* @property {?boolean} draw=true Draw the playhead as a triangle/line
|
|
233
|
-
* @property {?boolean} moveOnSeek=true Seeking (via clicking) while playing moves the playhead
|
|
234
|
-
* @property {?boolean} returnOnPause=true Pausing the track returns the seek position to the playhead
|
|
235
|
-
*/
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Playhead plugin definition factory
|
|
239
|
-
*
|
|
240
|
-
* This function must be used to create a plugin definition which can be
|
|
241
|
-
* used by wavesurfer to correctly instantiate the plugin.
|
|
242
|
-
*
|
|
243
|
-
* @param {PlayheadPluginParams} params parameters use to initialise the plugin
|
|
244
|
-
* @since 5.0.0
|
|
245
|
-
* @return {PluginDefinition} an object representing the plugin
|
|
246
|
-
*/
|
|
247
|
-
function create(params) {
|
|
248
|
-
return {
|
|
249
|
-
name: 'playhead',
|
|
250
|
-
deferInit: params && params.deferInit ? params.deferInit : false,
|
|
251
|
-
params: params,
|
|
252
|
-
instance: PlayheadPlugin
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
}]);
|
|
256
|
-
return PlayheadPlugin;
|
|
257
|
-
}();
|
|
258
|
-
exports["default"] = PlayheadPlugin;
|
|
259
|
-
module.exports = exports.default;
|
|
260
|
-
|
|
261
|
-
/***/ })
|
|
262
|
-
|
|
263
|
-
/******/ });
|
|
264
|
-
/************************************************************************/
|
|
265
|
-
/******/ // The module cache
|
|
266
|
-
/******/ var __webpack_module_cache__ = {};
|
|
267
|
-
/******/
|
|
268
|
-
/******/ // The require function
|
|
269
|
-
/******/ function __webpack_require__(moduleId) {
|
|
270
|
-
/******/ // Check if module is in cache
|
|
271
|
-
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
272
|
-
/******/ if (cachedModule !== undefined) {
|
|
273
|
-
/******/ return cachedModule.exports;
|
|
274
|
-
/******/ }
|
|
275
|
-
/******/ // Create a new module (and put it into the cache)
|
|
276
|
-
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
277
|
-
/******/ // no module.id needed
|
|
278
|
-
/******/ // no module.loaded needed
|
|
279
|
-
/******/ exports: {}
|
|
280
|
-
/******/ };
|
|
281
|
-
/******/
|
|
282
|
-
/******/ // Execute the module function
|
|
283
|
-
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
284
|
-
/******/
|
|
285
|
-
/******/ // Return the exports of the module
|
|
286
|
-
/******/ return module.exports;
|
|
287
|
-
/******/ }
|
|
288
|
-
/******/
|
|
289
|
-
/************************************************************************/
|
|
290
|
-
/******/
|
|
291
|
-
/******/ // startup
|
|
292
|
-
/******/ // Load entry module and return exports
|
|
293
|
-
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
294
|
-
/******/ var __webpack_exports__ = __webpack_require__("./src/plugin/playhead/index.js");
|
|
295
|
-
/******/
|
|
296
|
-
/******/ return __webpack_exports__;
|
|
297
|
-
/******/ })()
|
|
298
|
-
;
|
|
299
|
-
});
|
|
300
|
-
//# sourceMappingURL=wavesurfer.playhead.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wavesurfer.playhead.js","mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD;;;;;;;;;;;;;;;;;;;;;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAMA,kBAAkB,GAAG,SAAS;AAAC,IAEhBC,cAAc;EA2B/B,SAAAA,eAAYC,MAAM,EAAEC,EAAE,EAAE;IAAA,IAAAC,KAAA;IAAAC,eAAA,OAAAJ,cAAA;IACpB,IAAI,CAACC,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACI,OAAO,GAAG,CAAC,CAAC;IAEjB,CAAC,MAAM,EAAE,YAAY,EAAE,eAAe,CAAC,CAACC,OAAO,CAAC,UAAAC,GAAG,EAAI;MACnD,IAAIA,GAAG,IAAIN,MAAM,EAAE;QACfE,KAAI,CAACE,OAAO,CAACE,GAAG,CAAC,GAAGN,MAAM,CAACM,GAAG,CAAC;MACnC,CAAC,MAAM;QACHJ,KAAI,CAACE,OAAO,CAACE,GAAG,CAAC,GAAG,IAAI;MAC5B;IACJ,CAAC,CAAC;IAGF,IAAI,CAACC,UAAU,GAAGN,EAAE;IACpB,IAAI,CAACO,IAAI,GAAGP,EAAE,CAACO,IAAI;IACnB,IAAI,CAACC,KAAK,GAAG,IAAI,CAACD,IAAI,CAACC,KAAK;IAC5B,IAAI,CAACC,WAAW,GAAG,EAAE;IACrB,IAAI,CAACC,YAAY,GAAG,EAAE;IACtB,IAAI,CAACC,YAAY,GAAG,CAAC;IACrB,IAAI,CAACC,MAAM,GAAG,EAAE;IAEhB,IAAI,CAACC,SAAS,GAAG,YA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Y,GAAG+D,QAAQ;MAChD,IAAI,CAAClE,KAAK,CAAC,IAAI,CAACuC,OAAO,EAAE;QACrBgC,IAAI,EAAIH,YAAY,GAAGE,WAAW,GAAK,IAAI,CAACrE,WAAW,GAAG,CAAE,GAAI;MACpE,CAAC,CAAC;IACN;EAAC;IAAAU,GAAA;IAAAC,KAAA;IAjMD;AACJ;AACA;AACA;AACA;AACA;;IAEI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACI,SAAA4D,OAAcjF,MAAM,EAAE;MAClB,OAAO;QACHkF,IAAI,EAAE,UAAU;QAChBC,SAAS,EAAEnF,MAAM,IAAIA,MAAM,CAACmF,SAAS,GAAGnF,MAAM,CAACmF,SAAS,GAAG,KAAK;QAChEnF,MAAM,EAAEA,MAAM;QACdoF,QAAQ,EAAErF;MACd,CAAC;IACL;EAAC;EAAA,OAAAA,cAAA;AAAA;AAAAsF,kBAAA,GAAAtF,cAAA;AAAAwF,MAAA,CAAAF,OAAA,GAAAA,OAAA,CAAAC,OAAA;;;;;;UCvDL;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UEtBA;UACA;UACA;UACA","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/playhead/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/before-startup","webpack://WaveSurfer/webpack/startup","webpack://WaveSurfer/webpack/after-startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"playhead\"] = factory();\n})(self, () => {\nreturn ","\n/**\n * The playhead plugin separates the notion of the currently playing position from\n * a 'play-start' position. Having a playhead enables a listening pattern\n * (commonly found in DAWs) that involves listening to a section of a track\n * repeatedly, rather than listening to an entire track in a linear fashion.\n *\n * @implements {PluginClass}\n *\n * @example\n * import PlayheadPlugin from 'wavesurfer.playhead.js';\n *\n * // if you are using <script> tags\n * var PlayheadPlugin = window.WaveSurfer.playhead;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * PlayheadPlugin.create({\n * movePlayheadOnSeek: true,\n * drawPlayhead: false,\n * movePlayheadOnPause: false\n * })\n * ]\n * });\n */\n\nconst DEFAULT_FILL_COLOR = '#CF2F00';\n\nexport default class PlayheadPlugin {\n /**\n * @typedef {Object} PlayheadPluginParams\n * @property {?boolean} draw=true Draw the playhead as a triangle/line\n * @property {?boolean} moveOnSeek=true Seeking (via clicking) while playing moves the playhead\n * @property {?boolean} returnOnPause=true Pausing the track returns the seek position to the playhead\n */\n\n /**\n * Playhead plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {PlayheadPluginParams} params parameters use to initialise the plugin\n * @since 5.0.0\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'playhead',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: PlayheadPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.options = {};\n\n ['draw', 'moveOnSeek', 'returnOnPause'].forEach(opt => {\n if (opt in params) {\n this.options[opt] = params[opt];\n } else {\n this.options[opt] = true;\n }\n });\n\n\n this.wavesurfer = ws;\n this.util = ws.util;\n this.style = this.util.style;\n this.markerWidth = 21;\n this.markerHeight = 16;\n this.playheadTime = 0;\n this.unFuns = [];\n\n this._onResize = () => {\n this._updatePlayheadPosition();\n };\n\n this._onReady = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this._updatePlayheadPosition();\n };\n }\n\n _onBackendCreated() {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n\n if (this.options.draw) {\n this._createPlayheadElement();\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n\n this.wavesurferOn('zoom', this._onResize);\n }\n\n this.wavesurferOn('pause', () => {\n if ( this.options.returnOnPause ) {\n this.wavesurfer.setCurrentTime(this.playheadTime);\n }\n });\n\n this.wavesurferOn('seek', () => {\n if ( this.options.moveOnSeek ) {\n this.playheadTime = this.wavesurfer.getCurrentTime();\n this._updatePlayheadPosition();\n }\n });\n\n this.playheadTime = this.wavesurfer.getCurrentTime();\n }\n\n wavesurferOn(ev, fn) {\n let ret = this.wavesurfer.on(ev, fn);\n this.unFuns.push(() => {\n this.wavesurfer.un(ev, fn);\n });\n return ret;\n }\n\n init() {\n if (this.wavesurfer.isReady) {\n this._onBackendCreated();\n this._onReady();\n } else {\n let r;\n\n this.wavesurfer.once('ready', () => this._onReady());\n this.wavesurfer.once('backend-created', () => this._onBackendCreated());\n }\n }\n\n destroy() {\n this.unFuns.forEach(f => f());\n this.unFuns = [];\n\n this.wrapper.removeChild(this.element);\n\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n }\n\n setPlayheadTime(time) {\n this.playheadTime = time;\n\n if (!this.wavesurfer.isPlaying()) {\n this.wavesurfer.setCurrentTime(time);\n }\n this._updatePlayheadPosition();\n }\n\n _createPointerSVG() {\n const svgNS = 'http://www.w3.org/2000/svg';\n\n const el = document.createElementNS(svgNS, 'svg');\n const path = document.createElementNS(svgNS, 'path');\n\n el.setAttribute('viewBox', '0 0 33 30');\n path.setAttribute('d', 'M16.75 31 31.705 5.566A3 3 0 0 0 29.146 1H4.354a3 3 0 0 0-2.56 4.566L16.75 31z');\n path.setAttribute('stroke', '#979797');\n path.setAttribute('fill', DEFAULT_FILL_COLOR);\n\n el.appendChild(path);\n\n this.style(el, {\n width: this.markerWidth + 'px',\n height: this.markerHeight + 'px',\n cursor: 'pointer',\n 'z-index': 5\n });\n return el;\n }\n\n _createPlayheadElement() {\n const el = document.createElement('playhead');\n el.className = 'wavesurfer-playhead';\n\n this.style(el, {\n position: 'absolute',\n height: '100%',\n display: 'flex',\n 'flex-direction': 'column'\n });\n\n const pointer = this._createPointerSVG();\n el.appendChild(pointer);\n\n pointer.addEventListener('click', e => {\n e.stopPropagation();\n this.wavesurfer.setCurrentTime(this.playheadTime);\n });\n\n const line = document.createElement('div');\n this.style(line, {\n 'flex-grow': 1,\n 'margin-left': (this.markerWidth / 2 - 0.5) + 'px',\n background: 'black',\n width: '1px',\n opacity: 0.1\n });\n\n el.appendChild(line);\n\n this.element = el;\n this.wrapper.appendChild(el);\n }\n\n _updatePlayheadPosition() {\n if (!this.element) {\n return;\n }\n\n const duration = this.wavesurfer.getDuration();\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n\n const positionPct = this.playheadTime / duration;\n this.style(this.element, {\n left: ((elementWidth * positionPct) - (this.markerWidth / 2)) + 'px'\n });\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/plugin/playhead/index.js\");\n",""],"names":["DEFAULT_FILL_COLOR","PlayheadPlugin","params","ws","_this","_classCallCheck","options","forEach","opt","wavesurfer","util","style","markerWidth","markerHeight","playheadTime","unFuns","_onResize","_updatePlayheadPosition","_onReady","wrapper","drawer","_createClass","key","value","_onBackendCreated","_this2","draw","_createPlayheadElement","window","addEventListener","wavesurferOn","returnOnPause","setCurrentTime","moveOnSeek","getCurrentTime","ev","fn","_this3","ret","on","push","un","init","_this4","isReady","r","once","destroy","f","removeChild","element","removeEventListener","setPlayheadTime","time","isPlaying","_createPointerSVG","svgNS","el","document","createElementNS","path","setAttribute","appendChild","width","height","cursor","_this5","createElement","className","position","display","pointer","e","stopPropagation","line","background","opacity","duration","getDuration","elementWidth","pixelRatio","positionPct","left","create","name","deferInit","instance","exports","default","module"],"sourceRoot":""}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* wavesurfer.js playhead plugin 6.5.1 (2023-03-12)
|
|
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())}(self,(()=>(()=>{"use strict";var e={374:(e,t)=>{function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function i(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(a=n.key,s=void 0,s=function(e,t){if("object"!==r(e)||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!==r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(a,"string"),"symbol"===r(s)?s:String(s)),n)}var a,s}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=function(){function e(t,r){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=t,this.options={},["draw","moveOnSeek","returnOnPause"].forEach((function(e){i.options[e]=!(e in t)||t[e]})),this.wavesurfer=r,this.util=r.util,this.style=this.util.style,this.markerWidth=21,this.markerHeight=16,this.playheadTime=0,this.unFuns=[],this._onResize=function(){i._updatePlayheadPosition()},this._onReady=function(){i.wrapper=i.wavesurfer.drawer.wrapper,i._updatePlayheadPosition()}}var t,r,n;return t=e,n=[{key:"create",value:function(t){return{name:"playhead",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,instance:e}}}],(r=[{key:"_onBackendCreated",value:function(){var e=this;this.wrapper=this.wavesurfer.drawer.wrapper,this.options.draw&&(this._createPlayheadElement(),window.addEventListener("resize",this._onResize,!0),window.addEventListener("orientationchange",this._onResize,!0),this.wavesurferOn("zoom",this._onResize)),this.wavesurferOn("pause",(function(){e.options.returnOnPause&&e.wavesurfer.setCurrentTime(e.playheadTime)})),this.wavesurferOn("seek",(function(){e.options.moveOnSeek&&(e.playheadTime=e.wavesurfer.getCurrentTime(),e._updatePlayheadPosition())})),this.playheadTime=this.wavesurfer.getCurrentTime()}},{key:"wavesurferOn",value:function(e,t){var r=this,i=this.wavesurfer.on(e,t);return this.unFuns.push((function(){r.wavesurfer.un(e,t)})),i}},{key:"init",value:function(){var e=this;this.wavesurfer.isReady?(this._onBackendCreated(),this._onReady()):(this.wavesurfer.once("ready",(function(){return e._onReady()})),this.wavesurfer.once("backend-created",(function(){return e._onBackendCreated()})))}},{key:"destroy",value:function(){this.unFuns.forEach((function(e){return e()})),this.unFuns=[],this.wrapper.removeChild(this.element),window.removeEventListener("resize",this._onResize,!0),window.removeEventListener("orientationchange",this._onResize,!0)}},{key:"setPlayheadTime",value:function(e){this.playheadTime=e,this.wavesurfer.isPlaying()||this.wavesurfer.setCurrentTime(e),this._updatePlayheadPosition()}},{key:"_createPointerSVG",value:function(){var e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"svg"),r=document.createElementNS(e,"path");return t.setAttribute("viewBox","0 0 33 30"),r.setAttribute("d","M16.75 31 31.705 5.566A3 3 0 0 0 29.146 1H4.354a3 3 0 0 0-2.56 4.566L16.75 31z"),r.setAttribute("stroke","#979797"),r.setAttribute("fill","#CF2F00"),t.appendChild(r),this.style(t,{width:this.markerWidth+"px",height:this.markerHeight+"px",cursor:"pointer","z-index":5}),t}},{key:"_createPlayheadElement",value:function(){var e=this,t=document.createElement("playhead");t.className="wavesurfer-playhead",this.style(t,{position:"absolute",height:"100%",display:"flex","flex-direction":"column"});var r=this._createPointerSVG();t.appendChild(r),r.addEventListener("click",(function(t){t.stopPropagation(),e.wavesurfer.setCurrentTime(e.playheadTime)}));var i=document.createElement("div");this.style(i,{"flex-grow":1,"margin-left":this.markerWidth/2-.5+"px",background:"black",width:"1px",opacity:.1}),t.appendChild(i),this.element=t,this.wrapper.appendChild(t)}},{key:"_updatePlayheadPosition",value:function(){if(this.element){var e=this.wavesurfer.getDuration(),t=this.wavesurfer.drawer.width/this.wavesurfer.params.pixelRatio,r=this.playheadTime/e;this.style(this.element,{left:t*r-this.markerWidth/2+"px"})}}}])&&i(t.prototype,r),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=n,e.exports=t.default}},t={};var r=function r(i){var n=t[i];if(void 0!==n)return n.exports;var a=t[i]={exports:{}};return e[i](a,a.exports,r),a.exports}(374);return r})()));
|
|
7
|
-
//# sourceMappingURL=wavesurfer.playhead.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,WA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,EAAyBG,GAAY,CAGjD1F,QAAS,CAAC,GAOX,OAHA6F,EAAoBH,GAAUzF,EAAQA,EAAOD,QAASyF,GAG/CxF,EAAOD,OACf,CCnB0ByF,CAAoB,K,UHO9C","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/playhead/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"playhead\"] = factory();\n})(self, () => {\nreturn ","\n/**\n * The playhead plugin separates the notion of the currently playing position from\n * a 'play-start' position. Having a playhead enables a listening pattern\n * (commonly found in DAWs) that involves listening to a section of a track\n * repeatedly, rather than listening to an entire track in a linear fashion.\n *\n * @implements {PluginClass}\n *\n * @example\n * import PlayheadPlugin from 'wavesurfer.playhead.js';\n *\n * // if you are using <script> tags\n * var PlayheadPlugin = window.WaveSurfer.playhead;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * PlayheadPlugin.create({\n * movePlayheadOnSeek: true,\n * drawPlayhead: false,\n * movePlayheadOnPause: false\n * })\n * ]\n * });\n */\n\nconst DEFAULT_FILL_COLOR = '#CF2F00';\n\nexport default class PlayheadPlugin {\n /**\n * @typedef {Object} PlayheadPluginParams\n * @property {?boolean} draw=true Draw the playhead as a triangle/line\n * @property {?boolean} moveOnSeek=true Seeking (via clicking) while playing moves the playhead\n * @property {?boolean} returnOnPause=true Pausing the track returns the seek position to the playhead\n */\n\n /**\n * Playhead plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {PlayheadPluginParams} params parameters use to initialise the plugin\n * @since 5.0.0\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'playhead',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: PlayheadPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.options = {};\n\n ['draw', 'moveOnSeek', 'returnOnPause'].forEach(opt => {\n if (opt in params) {\n this.options[opt] = params[opt];\n } else {\n this.options[opt] = true;\n }\n });\n\n\n this.wavesurfer = ws;\n this.util = ws.util;\n this.style = this.util.style;\n this.markerWidth = 21;\n this.markerHeight = 16;\n this.playheadTime = 0;\n this.unFuns = [];\n\n this._onResize = () => {\n this._updatePlayheadPosition();\n };\n\n this._onReady = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this._updatePlayheadPosition();\n };\n }\n\n _onBackendCreated() {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n\n if (this.options.draw) {\n this._createPlayheadElement();\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n\n this.wavesurferOn('zoom', this._onResize);\n }\n\n this.wavesurferOn('pause', () => {\n if ( this.options.returnOnPause ) {\n this.wavesurfer.setCurrentTime(this.playheadTime);\n }\n });\n\n this.wavesurferOn('seek', () => {\n if ( this.options.moveOnSeek ) {\n this.playheadTime = this.wavesurfer.getCurrentTime();\n this._updatePlayheadPosition();\n }\n });\n\n this.playheadTime = this.wavesurfer.getCurrentTime();\n }\n\n wavesurferOn(ev, fn) {\n let ret = this.wavesurfer.on(ev, fn);\n this.unFuns.push(() => {\n this.wavesurfer.un(ev, fn);\n });\n return ret;\n }\n\n init() {\n if (this.wavesurfer.isReady) {\n this._onBackendCreated();\n this._onReady();\n } else {\n let r;\n\n this.wavesurfer.once('ready', () => this._onReady());\n this.wavesurfer.once('backend-created', () => this._onBackendCreated());\n }\n }\n\n destroy() {\n this.unFuns.forEach(f => f());\n this.unFuns = [];\n\n this.wrapper.removeChild(this.element);\n\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n }\n\n setPlayheadTime(time) {\n this.playheadTime = time;\n\n if (!this.wavesurfer.isPlaying()) {\n this.wavesurfer.setCurrentTime(time);\n }\n this._updatePlayheadPosition();\n }\n\n _createPointerSVG() {\n const svgNS = 'http://www.w3.org/2000/svg';\n\n const el = document.createElementNS(svgNS, 'svg');\n const path = document.createElementNS(svgNS, 'path');\n\n el.setAttribute('viewBox', '0 0 33 30');\n path.setAttribute('d', 'M16.75 31 31.705 5.566A3 3 0 0 0 29.146 1H4.354a3 3 0 0 0-2.56 4.566L16.75 31z');\n path.setAttribute('stroke', '#979797');\n path.setAttribute('fill', DEFAULT_FILL_COLOR);\n\n el.appendChild(path);\n\n this.style(el, {\n width: this.markerWidth + 'px',\n height: this.markerHeight + 'px',\n cursor: 'pointer',\n 'z-index': 5\n });\n return el;\n }\n\n _createPlayheadElement() {\n const el = document.createElement('playhead');\n el.className = 'wavesurfer-playhead';\n\n this.style(el, {\n position: 'absolute',\n height: '100%',\n display: 'flex',\n 'flex-direction': 'column'\n });\n\n const pointer = this._createPointerSVG();\n el.appendChild(pointer);\n\n pointer.addEventListener('click', e => {\n e.stopPropagation();\n this.wavesurfer.setCurrentTime(this.playheadTime);\n });\n\n const line = document.createElement('div');\n this.style(line, {\n 'flex-grow': 1,\n 'margin-left': (this.markerWidth / 2 - 0.5) + 'px',\n background: 'black',\n width: '1px',\n opacity: 0.1\n });\n\n el.appendChild(line);\n\n this.element = el;\n this.wrapper.appendChild(el);\n }\n\n _updatePlayheadPosition() {\n if (!this.element) {\n return;\n }\n\n const duration = this.wavesurfer.getDuration();\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n\n const positionPct = this.playheadTime / duration;\n this.style(this.element, {\n left: ((elementWidth * positionPct) - (this.markerWidth / 2)) + 'px'\n });\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(374);\n"],"names":["root","factory","exports","module","define","amd","self","PlayheadPlugin","params","ws","_this","_classCallCheck","this","options","forEach","opt","wavesurfer","util","style","markerWidth","markerHeight","playheadTime","unFuns","_onResize","_updatePlayheadPosition","_onReady","wrapper","drawer","key","value","name","deferInit","instance","_this2","draw","_createPlayheadElement","window","addEventListener","wavesurferOn","returnOnPause","setCurrentTime","moveOnSeek","getCurrentTime","ev","fn","_this3","ret","on","push","un","_this4","isReady","_onBackendCreated","once","f","removeChild","element","removeEventListener","time","isPlaying","svgNS","el","document","createElementNS","path","setAttribute","appendChild","width","height","cursor","_this5","createElement","className","position","display","pointer","_createPointerSVG","e","stopPropagation","line","background","opacity","duration","getDuration","elementWidth","pixelRatio","positionPct","left","default","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
|