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.
Files changed (132) hide show
  1. package/.eslintrc.json +24 -0
  2. package/.prettierrc +8 -0
  3. package/README.md +26 -117
  4. package/dist/base-plugin.d.ts +10 -0
  5. package/dist/base-plugin.js +13 -0
  6. package/dist/decoder.d.ts +10 -0
  7. package/dist/decoder.js +43 -0
  8. package/dist/event-emitter.d.ts +11 -0
  9. package/dist/event-emitter.js +21 -0
  10. package/dist/fetcher.d.ts +4 -0
  11. package/dist/fetcher.js +17 -0
  12. package/dist/index.d.ts +92 -0
  13. package/dist/index.js +166 -0
  14. package/dist/player-webaudio.d.ts +8 -0
  15. package/dist/player-webaudio.js +31 -0
  16. package/dist/player.d.ts +16 -0
  17. package/dist/player.js +40 -0
  18. package/dist/plugins/regions.d.ts +48 -0
  19. package/dist/plugins/regions.js +183 -0
  20. package/dist/renderer.d.ts +34 -0
  21. package/dist/renderer.js +193 -0
  22. package/dist/timer.d.ts +10 -0
  23. package/dist/timer.js +17 -0
  24. package/examples/audio.ogg +0 -0
  25. package/examples/bars.js +19 -0
  26. package/examples/basic.js +8 -0
  27. package/examples/gradient.js +28 -0
  28. package/examples/regions.js +63 -0
  29. package/examples/video.js +19 -0
  30. package/examples/webaudio.js +14 -0
  31. package/package.json +19 -99
  32. package/src/base-plugin.ts +20 -0
  33. package/src/decoder.ts +41 -0
  34. package/src/event-emitter.ts +35 -0
  35. package/src/fetcher.ts +7 -0
  36. package/src/index.ts +252 -0
  37. package/src/player-webaudio.ts +34 -0
  38. package/src/player.ts +50 -0
  39. package/src/plugins/regions.ts +240 -0
  40. package/src/renderer.ts +250 -0
  41. package/src/timer.ts +27 -0
  42. package/tsconfig.json +105 -0
  43. package/tutorial/index.html +47 -0
  44. package/tutorial/src/editor.js +70 -0
  45. package/tutorial/src/init.js +66 -0
  46. package/tutorial/src/url.js +25 -0
  47. package/tutorial/style.css +211 -0
  48. package/yarn-error.log +1049 -0
  49. package/LICENSE +0 -29
  50. package/dist/plugin/wavesurfer.cursor.js +0 -418
  51. package/dist/plugin/wavesurfer.cursor.js.map +0 -1
  52. package/dist/plugin/wavesurfer.cursor.min.js +0 -7
  53. package/dist/plugin/wavesurfer.cursor.min.js.map +0 -1
  54. package/dist/plugin/wavesurfer.elan.js +0 -381
  55. package/dist/plugin/wavesurfer.elan.js.map +0 -1
  56. package/dist/plugin/wavesurfer.elan.min.js +0 -7
  57. package/dist/plugin/wavesurfer.elan.min.js.map +0 -1
  58. package/dist/plugin/wavesurfer.markers.js +0 -520
  59. package/dist/plugin/wavesurfer.markers.js.map +0 -1
  60. package/dist/plugin/wavesurfer.markers.min.js +0 -7
  61. package/dist/plugin/wavesurfer.markers.min.js.map +0 -1
  62. package/dist/plugin/wavesurfer.mediasession.js +0 -181
  63. package/dist/plugin/wavesurfer.mediasession.js.map +0 -1
  64. package/dist/plugin/wavesurfer.mediasession.min.js +0 -7
  65. package/dist/plugin/wavesurfer.mediasession.min.js.map +0 -1
  66. package/dist/plugin/wavesurfer.microphone.js +0 -466
  67. package/dist/plugin/wavesurfer.microphone.js.map +0 -1
  68. package/dist/plugin/wavesurfer.microphone.min.js +0 -7
  69. package/dist/plugin/wavesurfer.microphone.min.js.map +0 -1
  70. package/dist/plugin/wavesurfer.minimap.js +0 -440
  71. package/dist/plugin/wavesurfer.minimap.js.map +0 -1
  72. package/dist/plugin/wavesurfer.minimap.min.js +0 -7
  73. package/dist/plugin/wavesurfer.minimap.min.js.map +0 -1
  74. package/dist/plugin/wavesurfer.playhead.js +0 -300
  75. package/dist/plugin/wavesurfer.playhead.js.map +0 -1
  76. package/dist/plugin/wavesurfer.playhead.min.js +0 -7
  77. package/dist/plugin/wavesurfer.playhead.min.js.map +0 -1
  78. package/dist/plugin/wavesurfer.regions.js +0 -1335
  79. package/dist/plugin/wavesurfer.regions.js.map +0 -1
  80. package/dist/plugin/wavesurfer.regions.min.js +0 -7
  81. package/dist/plugin/wavesurfer.regions.min.js.map +0 -1
  82. package/dist/plugin/wavesurfer.spectrogram.js +0 -736
  83. package/dist/plugin/wavesurfer.spectrogram.js.map +0 -1
  84. package/dist/plugin/wavesurfer.spectrogram.min.js +0 -7
  85. package/dist/plugin/wavesurfer.spectrogram.min.js.map +0 -1
  86. package/dist/plugin/wavesurfer.timeline.js +0 -649
  87. package/dist/plugin/wavesurfer.timeline.js.map +0 -1
  88. package/dist/plugin/wavesurfer.timeline.min.js +0 -7
  89. package/dist/plugin/wavesurfer.timeline.min.js.map +0 -1
  90. package/dist/wavesurfer-html-init.js +0 -381
  91. package/dist/wavesurfer-html-init.js.map +0 -1
  92. package/dist/wavesurfer-html-init.min.js +0 -7
  93. package/dist/wavesurfer-html-init.min.js.map +0 -1
  94. package/dist/wavesurfer.js +0 -6145
  95. package/dist/wavesurfer.js.map +0 -1
  96. package/dist/wavesurfer.min.js +0 -7
  97. package/dist/wavesurfer.min.js.map +0 -1
  98. package/src/drawer.canvasentry.js +0 -427
  99. package/src/drawer.js +0 -413
  100. package/src/drawer.multicanvas.js +0 -617
  101. package/src/html-init.js +0 -241
  102. package/src/mediaelement-webaudio.js +0 -77
  103. package/src/mediaelement.js +0 -443
  104. package/src/peakcache.js +0 -127
  105. package/src/plugin/cursor/index.js +0 -350
  106. package/src/plugin/elan/index.js +0 -307
  107. package/src/plugin/markers/index.js +0 -436
  108. package/src/plugin/mediasession/index.js +0 -94
  109. package/src/plugin/microphone/index.js +0 -415
  110. package/src/plugin/minimap/index.js +0 -403
  111. package/src/plugin/playhead/index.js +0 -226
  112. package/src/plugin/regions/index.js +0 -478
  113. package/src/plugin/regions/region.js +0 -875
  114. package/src/plugin/spectrogram/fft.js +0 -222
  115. package/src/plugin/spectrogram/index.js +0 -522
  116. package/src/plugin/timeline/index.js +0 -600
  117. package/src/util/absMax.js +0 -16
  118. package/src/util/clamp.js +0 -11
  119. package/src/util/fetch.js +0 -222
  120. package/src/util/frame.js +0 -13
  121. package/src/util/get-id.js +0 -22
  122. package/src/util/index.js +0 -14
  123. package/src/util/max.js +0 -16
  124. package/src/util/min.js +0 -16
  125. package/src/util/observer.js +0 -144
  126. package/src/util/orientation.js +0 -98
  127. package/src/util/prevent-click.js +0 -19
  128. package/src/util/request-animation-frame.js +0 -15
  129. package/src/util/silence-mode.js +0 -42
  130. package/src/util/style.js +0 -16
  131. package/src/wavesurfer.js +0 -1797
  132. package/src/webaudio.js +0 -779
@@ -1,436 +0,0 @@
1
- /**
2
- * @typedef {Object} MarkerParams
3
- * @desc The parameters used to describe a marker.
4
- * @example wavesurfer.addMarker(regionParams);
5
- * @property {number} time The time to set the marker at
6
- * @property {?label} string An optional marker label
7
- * @property {?tooltip} string An optional marker tooltip
8
- * @property {?color} string Background color for marker
9
- * @property {?position} string "top" or "bottom", defaults to "bottom"
10
- * @property {?markerElement} element An HTML element to display instead of the default marker image
11
- * @property {?draggable} boolean Set marker as draggable, defaults to false
12
- * @property {?boolean} preventContextMenu Determines whether the context menu
13
- * is prevented from being opened, defaults to false
14
- */
15
-
16
-
17
- /**
18
- * Markers are points in time in the audio that can be jumped to.
19
- *
20
- * @implements {PluginClass}
21
- *
22
- * @example
23
- * import MarkersPlugin from 'wavesurfer.markers.js';
24
- *
25
- * // if you are using <script> tags
26
- * var MarkerPlugin = window.WaveSurfer.markers;
27
- *
28
- * // ... initialising wavesurfer with the plugin
29
- * var wavesurfer = WaveSurfer.create({
30
- * // wavesurfer options ...
31
- * plugins: [
32
- * MarkersPlugin.create({
33
- * // plugin options ...
34
- * })
35
- * ]
36
- * });
37
- */
38
-
39
- const DEFAULT_FILL_COLOR = "#D8D8D8";
40
- const DEFAULT_POSITION = "bottom";
41
-
42
- export default class MarkersPlugin {
43
- /**
44
- * @typedef {Object} MarkersPluginParams
45
- * @property {?MarkerParams[]} markers Initial set of markers
46
- * @fires MarkersPlugin#marker-click
47
- * @fires MarkersPlugin#marker-drag
48
- * @fires MarkersPlugin#marker-drop
49
- */
50
-
51
- /**
52
- * Markers plugin definition factory
53
- *
54
- * This function must be used to create a plugin definition which can be
55
- * used by wavesurfer to correctly instantiate the plugin.
56
- *
57
- * @param {MarkersPluginParams} params parameters use to initialise the plugin
58
- * @since 4.6.0
59
- * @return {PluginDefinition} an object representing the plugin
60
- */
61
- static create(params) {
62
- return {
63
- name: 'markers',
64
- deferInit: params && params.deferInit ? params.deferInit : false,
65
- params: params,
66
- staticProps: {
67
- addMarker(options) {
68
- if (!this.initialisedPluginList.markers) {
69
- this.initPlugin('markers');
70
- }
71
- return this.markers.add(options);
72
- },
73
- clearMarkers() {
74
- this.markers && this.markers.clear();
75
- }
76
- },
77
- instance: MarkersPlugin
78
- };
79
- }
80
-
81
- constructor(params, ws) {
82
- this.params = params;
83
- this.wavesurfer = ws;
84
- this.util = ws.util;
85
- this.style = this.util.style;
86
- this.markerLineWidth = 1;
87
- this.markerWidth = 11;
88
- this.markerHeight = 22;
89
- this.dragging = false;
90
-
91
-
92
- this._onResize = () => {
93
- this._updateMarkerPositions();
94
- };
95
-
96
- this._onBackendCreated = () => {
97
- this.wrapper = this.wavesurfer.drawer.wrapper;
98
- if (this.params.markers) {
99
- this.params.markers.forEach(marker => this.add(marker));
100
- }
101
- window.addEventListener('resize', this._onResize, true);
102
- window.addEventListener('orientationchange', this._onResize, true);
103
- this.wavesurfer.on('zoom', this._onResize);
104
-
105
- if (!this.markers.find(marker => marker.draggable)){
106
- return;
107
- }
108
-
109
- this.onMouseMove = (e) => this._onMouseMove(e);
110
- window.addEventListener('mousemove', this.onMouseMove);
111
-
112
- this.onMouseUp = (e) => this._onMouseUp(e);
113
- window.addEventListener("mouseup", this.onMouseUp);
114
- };
115
-
116
- this.markers = [];
117
- this._onReady = () => {
118
- this.wrapper = this.wavesurfer.drawer.wrapper;
119
- this._updateMarkerPositions();
120
- };
121
- }
122
-
123
- init() {
124
- // Check if ws is ready
125
- if (this.wavesurfer.isReady) {
126
- this._onBackendCreated();
127
- this._onReady();
128
- } else {
129
- this.wavesurfer.once('ready', this._onReady);
130
- this.wavesurfer.once('backend-created', this._onBackendCreated);
131
- }
132
- }
133
-
134
- destroy() {
135
- this.wavesurfer.un('ready', this._onReady);
136
- this.wavesurfer.un('backend-created', this._onBackendCreated);
137
-
138
- this.wavesurfer.un('zoom', this._onResize);
139
-
140
- window.removeEventListener('resize', this._onResize, true);
141
- window.removeEventListener('orientationchange', this._onResize, true);
142
-
143
- if (this.onMouseMove) {
144
- window.removeEventListener('mousemove', this.onMouseMove);
145
- }
146
- if (this.onMouseUp) {
147
- window.removeEventListener("mouseup", this.onMouseUp);
148
- }
149
-
150
- this.clear();
151
- }
152
-
153
- /**
154
- * Add a marker
155
- *
156
- * @param {MarkerParams} params Marker definition
157
- * @return {object} The created marker
158
- */
159
- add(params) {
160
- let marker = {
161
- time: params.time,
162
- label: params.label,
163
- tooltip: params.tooltip,
164
- color: params.color || DEFAULT_FILL_COLOR,
165
- position: params.position || DEFAULT_POSITION,
166
- draggable: !!params.draggable,
167
- preventContextMenu: !!params.preventContextMenu
168
- };
169
-
170
- marker.el = this._createMarkerElement(marker, params.markerElement);
171
-
172
- this.wrapper.appendChild(marker.el);
173
- this.markers.push(marker);
174
- this._updateMarkerPositions();
175
-
176
- this._registerEvents();
177
-
178
- return marker;
179
- }
180
-
181
- /**
182
- * Remove a marker
183
- *
184
- * @param {number} index Index of the marker to remove
185
- */
186
- remove(index) {
187
- let marker = this.markers[index];
188
- if (!marker) {
189
- return;
190
- }
191
- let label = marker.el.getElementsByClassName("marker-label")[0];
192
- if (label) {
193
- if (label._onContextMenu) {
194
- label.removeEventListener("contextmenu", label._onContextMenu);
195
- }
196
- if (label._onClick) {
197
- label.removeEventListener("click", label._onClick);
198
- }
199
- if (label._onMouseDown) {
200
- label.removeEventListener("mousedown", label._onMouseDown);
201
- }
202
- }
203
-
204
- this.wrapper.removeChild(marker.el);
205
- this.markers.splice(index, 1);
206
-
207
- this._unregisterEvents();
208
- }
209
-
210
- _createPointerSVG(color, position) {
211
- const svgNS = "http://www.w3.org/2000/svg";
212
-
213
- const el = document.createElementNS(svgNS, "svg");
214
- const polygon = document.createElementNS(svgNS, "polygon");
215
-
216
- el.setAttribute("viewBox", "0 0 40 80");
217
-
218
- polygon.setAttribute("id", "polygon");
219
- polygon.setAttribute("stroke", "#979797");
220
- polygon.setAttribute("fill", color);
221
- polygon.setAttribute("points", "20 0 40 30 40 80 0 80 0 30");
222
- if ( position == "top" ) {
223
- polygon.setAttribute("transform", "rotate(180, 20 40)");
224
- }
225
-
226
- el.appendChild(polygon);
227
-
228
- this.style(el, {
229
- width: this.markerWidth + "px",
230
- height: this.markerHeight + "px",
231
- "min-width": this.markerWidth + "px",
232
- "margin-right": "5px",
233
- "z-index": 4
234
- });
235
- return el;
236
- }
237
-
238
- _createMarkerElement(marker, markerElement) {
239
- let label = marker.label;
240
- let tooltip = marker.tooltip;
241
-
242
- const el = document.createElement('marker');
243
- el.className = "wavesurfer-marker";
244
-
245
- this.style(el, {
246
- position: "absolute",
247
- height: "100%",
248
- display: "flex",
249
- overflow: "hidden",
250
- "flex-direction": (marker.position == "top" ? "column-reverse" : "column")
251
- });
252
-
253
- const line = document.createElement('div');
254
- const width = markerElement ? markerElement.width : this.markerWidth;
255
- marker.offset = (width - this.markerLineWidth) / 2;
256
- this.style(line, {
257
- "flex-grow": 1,
258
- "margin-left": marker.offset + "px",
259
- background: "black",
260
- width: this.markerLineWidth + "px",
261
- opacity: 0.1
262
- });
263
- el.appendChild(line);
264
-
265
- const labelDiv = document.createElement('div');
266
- const point = markerElement || this._createPointerSVG(marker.color, marker.position);
267
- if (marker.draggable){
268
- point.draggable = false;
269
- }
270
- labelDiv.appendChild(point);
271
-
272
- if ( label ) {
273
- const labelEl = document.createElement('span');
274
- labelEl.innerText = label;
275
- labelEl.setAttribute('title', tooltip);
276
- this.style(labelEl, {
277
- "font-family": "inherit",
278
- "font-size": "90%"
279
- });
280
- labelDiv.appendChild(labelEl);
281
- }
282
-
283
- this.style(labelDiv, {
284
- display: "flex",
285
- "align-items": "center",
286
- cursor: "pointer"
287
- });
288
- labelDiv.classList.add("marker-label");
289
-
290
- el.appendChild(labelDiv);
291
-
292
- labelDiv._onClick = (e) => {
293
- e.stopPropagation();
294
- // Click event is caught when the marker-drop event was dispatched.
295
- // Drop event was dispatched at this moment, but this.dragging
296
- // is waiting for the next tick to set as false
297
- if (this.dragging){
298
- return;
299
- }
300
- this.wavesurfer.setCurrentTime(marker.time);
301
- this.wavesurfer.fireEvent("marker-click", marker, e);
302
- };
303
- labelDiv.addEventListener("click", labelDiv._onClick);
304
-
305
- labelDiv._onContextMenu = (e) => {
306
- if (marker.preventContextMenu) {
307
- e.preventDefault();
308
- }
309
- this.wavesurfer.fireEvent("marker-contextmenu", marker, e);
310
- };
311
- labelDiv.addEventListener("contextmenu", labelDiv._onContextMenu);
312
-
313
- if (marker.draggable) {
314
- labelDiv._onMouseDown = () => {
315
- this.selectedMarker = marker;
316
- };
317
- labelDiv.addEventListener("mousedown", labelDiv._onMouseDown);
318
- }
319
- return el;
320
- }
321
-
322
- _updateMarkerPositions() {
323
- for ( let i = 0 ; i < this.markers.length; i++ ) {
324
- let marker = this.markers[i];
325
- this._updateMarkerPosition(marker);
326
- }
327
- }
328
-
329
- /**
330
- * Update a marker position based on its time property.
331
- *
332
- * @private
333
- * @param {MarkerParams} params The marker to update.
334
- * @returns {void}
335
- */
336
- _updateMarkerPosition(params) {
337
- const duration = this.wavesurfer.getDuration();
338
- const elementWidth =
339
- this.wavesurfer.drawer.width /
340
- this.wavesurfer.params.pixelRatio;
341
-
342
- const positionPct = Math.min(params.time / duration, 1);
343
- const leftPx = ((elementWidth * positionPct) - params.offset);
344
- this.style(params.el, {
345
- "left": leftPx + "px",
346
- "max-width": (elementWidth - leftPx) + "px"
347
- });
348
- }
349
-
350
- /**
351
- * Fires `marker-drag` event, update the `time` property for the
352
- * selected marker based on the mouse position, and calls to update
353
- * its position.
354
- *
355
- * @private
356
- * @param {MouseEvent} event The mouse event.
357
- * @returns {void}
358
- */
359
- _onMouseMove(event) {
360
- if (!this.selectedMarker){
361
- return;
362
- }
363
- if (!this.dragging){
364
- this.dragging = true;
365
- this.wavesurfer.fireEvent("marker-drag", this.selectedMarker, event);
366
- }
367
- this.selectedMarker.time = this.wavesurfer.drawer.handleEvent(event) * this.wavesurfer.getDuration();
368
- this._updateMarkerPositions();
369
- }
370
-
371
- /**
372
- * Fires `marker-drop` event and unselect the dragged marker.
373
- *
374
- * @private
375
- * @param {MouseEvent} event The mouse event.
376
- * @returns {void}
377
- */
378
- _onMouseUp(event) {
379
- if (this.selectedMarker) {
380
- setTimeout(() => {
381
- this.selectedMarker = false;
382
- this.dragging = false;
383
- }, 0);
384
- }
385
-
386
- if (!this.dragging) {
387
- return;
388
- }
389
-
390
- event.stopPropagation();
391
- const duration = this.wavesurfer.getDuration();
392
- this.selectedMarker.time = this.wavesurfer.drawer.handleEvent(event) * duration;
393
- this._updateMarkerPositions();
394
- this.wavesurfer.fireEvent("marker-drop", this.selectedMarker, event);
395
- }
396
-
397
- _registerEvents() {
398
- if (!this.markers.find(marker => marker.draggable)) {
399
- return;
400
- }
401
- //we have some draggable markers, check for listeners
402
- if (!this.onMouseMove) {
403
- this.onMouseMove = (e) => this._onMouseMove(e);
404
- window.addEventListener('mousemove', this.onMouseMove);
405
- }
406
-
407
- if (!this.onMouseUp) {
408
- this.onMouseUp = (e) => this._onMouseUp(e);
409
- window.addEventListener("mouseup", this.onMouseUp);
410
- }
411
- }
412
-
413
- _unregisterEvents() {
414
- if (this.markers.find(marker => marker.draggable)) {
415
- return;
416
- }
417
- //we don't have any draggable markers, unregister listeners
418
- if (this.onMouseMove) {
419
- window.removeEventListener('mousemove', this.onMouseMove);
420
- this.onMouseMove = null;
421
- }
422
- if (this.onMouseUp) {
423
- window.removeEventListener("mouseup", this.onMouseUp);
424
- this.onMouseUp = null;
425
- }
426
- }
427
-
428
- /**
429
- * Remove all markers
430
- */
431
- clear() {
432
- while ( this.markers.length > 0 ) {
433
- this.remove(0);
434
- }
435
- }
436
- }
@@ -1,94 +0,0 @@
1
- /**
2
- * @typedef {Object} MediaSessionPluginParams
3
- * @property {MediaMetadata} metadata A MediaMetadata object: a representation
4
- * of the metadata associated with a MediaSession that can be used by user agents
5
- * to provide a customized user interface.
6
- * @property {?boolean} deferInit Set to true to manually call
7
- * `initPlugin('mediasession')`
8
- */
9
-
10
- /**
11
- * Visualize MediaSession information for a wavesurfer instance.
12
- *
13
- * @implements {PluginClass}
14
- * @extends {Observer}
15
- * @example
16
- * // es6
17
- * import MediaSessionPlugin from 'wavesurfer.mediasession.js';
18
- *
19
- * // commonjs
20
- * var MediaSessionPlugin = require('wavesurfer.mediasession.js');
21
- *
22
- * // if you are using <script> tags
23
- * var MediaSessionPlugin = window.WaveSurfer.mediasession;
24
- *
25
- * // ... initialising wavesurfer with the plugin
26
- * var wavesurfer = WaveSurfer.create({
27
- * // wavesurfer options ...
28
- * plugins: [
29
- * MediaSessionPlugin.create({
30
- * // plugin options ...
31
- * })
32
- * ]
33
- * });
34
- */
35
- export default class MediaSessionPlugin {
36
- /**
37
- * MediaSession plugin definition factory
38
- *
39
- * This function must be used to create a plugin definition which can be
40
- * used by wavesurfer to correctly instantiate the plugin.
41
- *
42
- * @param {MediaSessionPluginParams} params parameters use to initialise the plugin
43
- * @return {PluginDefinition} an object representing the plugin
44
- */
45
- static create(params) {
46
- return {
47
- name: 'mediasession',
48
- deferInit: params && params.deferInit ? params.deferInit : false,
49
- params: params,
50
- instance: MediaSessionPlugin
51
- };
52
- }
53
-
54
- constructor(params, ws) {
55
- this.params = params;
56
- this.wavesurfer = ws;
57
-
58
- if ('mediaSession' in navigator) {
59
- // update metadata
60
- this.metadata = this.params.metadata;
61
- this.update();
62
-
63
- // update metadata when playback starts
64
- this.wavesurfer.on('play', () => {
65
- this.update();
66
- });
67
-
68
- // set playback action handlers
69
- navigator.mediaSession.setActionHandler('play', () => {
70
- this.wavesurfer.play();
71
- });
72
- navigator.mediaSession.setActionHandler('pause', () => {
73
- this.wavesurfer.playPause();
74
- });
75
- navigator.mediaSession.setActionHandler('seekbackward', () => {
76
- this.wavesurfer.skipBackward();
77
- });
78
- navigator.mediaSession.setActionHandler('seekforward', () => {
79
- this.wavesurfer.skipForward();
80
- });
81
- }
82
- }
83
-
84
- init() {}
85
-
86
- destroy() {}
87
-
88
- update() {
89
- if (typeof MediaMetadata === typeof Function) {
90
- // set metadata
91
- navigator.mediaSession.metadata = new MediaMetadata(this.metadata);
92
- }
93
- }
94
- }