wavesurfer.js 6.0.4 → 6.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.
- package/CHANGES.md +8 -0
- package/README.md +1 -1
- package/dist/plugin/wavesurfer.cursor.js +1 -1
- package/dist/plugin/wavesurfer.cursor.min.js +1 -1
- package/dist/plugin/wavesurfer.elan.js +1 -1
- package/dist/plugin/wavesurfer.elan.min.js +1 -1
- package/dist/plugin/wavesurfer.markers.js +1 -1
- package/dist/plugin/wavesurfer.markers.min.js +1 -1
- package/dist/plugin/wavesurfer.mediasession.js +1 -3
- package/dist/plugin/wavesurfer.mediasession.js.map +1 -1
- package/dist/plugin/wavesurfer.mediasession.min.js +1 -1
- package/dist/plugin/wavesurfer.mediasession.min.js.map +1 -1
- package/dist/plugin/wavesurfer.microphone.js +1 -1
- package/dist/plugin/wavesurfer.microphone.min.js +1 -1
- package/dist/plugin/wavesurfer.minimap.js +24 -4
- package/dist/plugin/wavesurfer.minimap.js.map +1 -1
- package/dist/plugin/wavesurfer.minimap.min.js +2 -2
- package/dist/plugin/wavesurfer.minimap.min.js.map +1 -1
- package/dist/plugin/wavesurfer.playhead.js +1 -1
- package/dist/plugin/wavesurfer.playhead.min.js +1 -1
- package/dist/plugin/wavesurfer.regions.js +1 -1
- package/dist/plugin/wavesurfer.regions.min.js +1 -1
- package/dist/plugin/wavesurfer.spectrogram.js +1 -1
- package/dist/plugin/wavesurfer.spectrogram.min.js +1 -1
- package/dist/plugin/wavesurfer.timeline.js +1 -1
- package/dist/plugin/wavesurfer.timeline.min.js +1 -1
- package/dist/wavesurfer-html-init.js +1 -1
- package/dist/wavesurfer-html-init.min.js +1 -1
- package/dist/wavesurfer.js +33 -10
- package/dist/wavesurfer.js.map +1 -1
- package/dist/wavesurfer.min.js +2 -2
- package/dist/wavesurfer.min.js.map +1 -1
- package/package.json +7 -7
- package/src/plugin/mediasession/index.js +0 -2
- package/src/plugin/minimap/index.js +17 -2
- package/src/wavesurfer.js +4 -1
- package/src/webaudio.js +24 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wavesurfer.js",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "Interactive navigable audio visualization using Web Audio and Canvas",
|
|
5
5
|
"main": "dist/wavesurfer.js",
|
|
6
6
|
"directories": {
|
|
@@ -55,13 +55,13 @@
|
|
|
55
55
|
"visualization"
|
|
56
56
|
],
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@babel/core": "^7.17.
|
|
58
|
+
"@babel/core": "^7.17.8",
|
|
59
59
|
"@babel/eslint-parser": "^7.17.0",
|
|
60
60
|
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
61
61
|
"@babel/preset-env": "^7.16.11",
|
|
62
|
-
"@babel/register": "^7.17.
|
|
62
|
+
"@babel/register": "^7.17.7",
|
|
63
63
|
"@chiragrupani/karma-chromium-edge-launcher": "^2.2.1",
|
|
64
|
-
"babel-loader": "^8.2.
|
|
64
|
+
"babel-loader": "^8.2.4",
|
|
65
65
|
"babel-plugin-add-module-exports": "^1.0.4",
|
|
66
66
|
"babel-plugin-istanbul": "^6.1.1",
|
|
67
67
|
"babel-plugin-proxy": "^1.1.0",
|
|
@@ -74,19 +74,19 @@
|
|
|
74
74
|
"esdoc-ecmascript-proposal-plugin": "^1.0.0",
|
|
75
75
|
"esdoc-integrate-test-plugin": "^1.0.0",
|
|
76
76
|
"esdoc-standard-plugin": "^1.0.0",
|
|
77
|
-
"eslint": "^8.
|
|
77
|
+
"eslint": "^8.11.0",
|
|
78
78
|
"htmlhint": "^1.1.2",
|
|
79
79
|
"in-publish": "^2.0.1",
|
|
80
80
|
"jasmine-core": "^4.0.1",
|
|
81
81
|
"karma": "^6.3.17",
|
|
82
|
-
"karma-chrome-launcher": "3.1.
|
|
82
|
+
"karma-chrome-launcher": "3.1.1",
|
|
83
83
|
"karma-coverage": "^2.2.0",
|
|
84
84
|
"karma-firefox-launcher": "^2.1.2",
|
|
85
85
|
"karma-jasmine": "4.0.1",
|
|
86
86
|
"karma-jasmine-matchers": "5.0.0",
|
|
87
87
|
"karma-verbose-reporter": "0.0.8",
|
|
88
88
|
"karma-webpack": "^5.0.0",
|
|
89
|
-
"lint-staged": "^12.3.
|
|
89
|
+
"lint-staged": "^12.3.7",
|
|
90
90
|
"load-script": "^2.0.0",
|
|
91
91
|
"pre-commit": "^1.2.2",
|
|
92
92
|
"webpack": "^5.70.0",
|
|
@@ -96,6 +96,7 @@ export default class MinimapPlugin {
|
|
|
96
96
|
this.drawer = new ws.Drawer(this.params.container, this.params);
|
|
97
97
|
this.wavesurfer = ws;
|
|
98
98
|
this.util = ws.util;
|
|
99
|
+
this.cleared = false;
|
|
99
100
|
this.renderEvent = 'redraw';
|
|
100
101
|
this.overviewRegion = null;
|
|
101
102
|
this.regionsPlugin = this.wavesurfer[this.params.regionsPluginName];
|
|
@@ -119,7 +120,7 @@ export default class MinimapPlugin {
|
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
if (this.regionsPlugin && this.params.showRegions) {
|
|
122
|
-
this.
|
|
123
|
+
this.drawRegions();
|
|
123
124
|
}
|
|
124
125
|
this.render();
|
|
125
126
|
};
|
|
@@ -154,6 +155,18 @@ export default class MinimapPlugin {
|
|
|
154
155
|
);
|
|
155
156
|
}
|
|
156
157
|
});
|
|
158
|
+
this._onLoading = percent => {
|
|
159
|
+
if (percent >= 100) {
|
|
160
|
+
this.cleared = false;
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (this.cleared === true) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const len = this.drawer.getWidth();
|
|
167
|
+
this.drawer.drawPeaks([0], len, 0, len);
|
|
168
|
+
this.cleared = true;
|
|
169
|
+
};
|
|
157
170
|
this._onZoom = e => {
|
|
158
171
|
this.render();
|
|
159
172
|
};
|
|
@@ -179,12 +192,13 @@ export default class MinimapPlugin {
|
|
|
179
192
|
this.wavesurfer.un('scroll', this._onScroll);
|
|
180
193
|
this.wavesurfer.un('audioprocess', this._onAudioprocess);
|
|
181
194
|
this.wavesurfer.un('zoom', this._onZoom);
|
|
195
|
+
this.wavesurfer.un('loading', this._onLoading);
|
|
182
196
|
this.drawer.destroy();
|
|
183
197
|
this.overviewRegion = null;
|
|
184
198
|
this.unAll();
|
|
185
199
|
}
|
|
186
200
|
|
|
187
|
-
|
|
201
|
+
drawRegions() {
|
|
188
202
|
this.regions = {};
|
|
189
203
|
|
|
190
204
|
this.wavesurfer.on('region-created', region => {
|
|
@@ -267,6 +281,7 @@ export default class MinimapPlugin {
|
|
|
267
281
|
window.addEventListener('orientationchange', this._onResize, true);
|
|
268
282
|
this.wavesurfer.on('audioprocess', this._onAudioprocess);
|
|
269
283
|
this.wavesurfer.on('seek', this._onSeek);
|
|
284
|
+
this.wavesurfer.on('loading', this._onLoading);
|
|
270
285
|
if (this.params.showOverview) {
|
|
271
286
|
this.wavesurfer.on('scroll', this._onScroll);
|
|
272
287
|
this.wavesurfer.drawer.wrapper.addEventListener(
|
package/src/wavesurfer.js
CHANGED
|
@@ -505,7 +505,10 @@ export default class WaveSurfer extends util.Observer {
|
|
|
505
505
|
!this.params.scrollParent
|
|
506
506
|
) {
|
|
507
507
|
prevWidth = this.drawer.wrapper.clientWidth;
|
|
508
|
-
|
|
508
|
+
if (prevWidth) {
|
|
509
|
+
// redraw only if waveform container is rendered and has a width
|
|
510
|
+
this.drawer.fireEvent('redraw');
|
|
511
|
+
}
|
|
509
512
|
}
|
|
510
513
|
},
|
|
511
514
|
typeof this.params.responsive === 'number'
|
package/src/webaudio.js
CHANGED
|
@@ -145,6 +145,10 @@ export default class WebAudio extends util.Observer {
|
|
|
145
145
|
this.state = null;
|
|
146
146
|
/** @private */
|
|
147
147
|
this.explicitDuration = params.duration;
|
|
148
|
+
/** @private */
|
|
149
|
+
this.sinkStreamDestination = null;
|
|
150
|
+
/** @private */
|
|
151
|
+
this.sinkAudioElement = null;
|
|
148
152
|
/**
|
|
149
153
|
* Boolean indicating if the backend was destroyed.
|
|
150
154
|
*/
|
|
@@ -298,19 +302,24 @@ export default class WebAudio extends util.Observer {
|
|
|
298
302
|
* output. Here we create an HTMLAudioElement, connect the
|
|
299
303
|
* webaudio stream to that element and setSinkId there.
|
|
300
304
|
*/
|
|
301
|
-
|
|
302
|
-
|
|
305
|
+
if (!this.sinkAudioElement) {
|
|
306
|
+
this.sinkAudioElement = new window.Audio();
|
|
307
|
+
// autoplay is necessary since we're not invoking .play()
|
|
308
|
+
this.sinkAudioElement.autoplay = true;
|
|
309
|
+
}
|
|
310
|
+
if (!this.sinkAudioElement.setSinkId) {
|
|
303
311
|
return Promise.reject(
|
|
304
312
|
new Error('setSinkId is not supported in your browser')
|
|
305
313
|
);
|
|
306
314
|
}
|
|
307
|
-
|
|
308
|
-
|
|
315
|
+
if (!this.sinkStreamDestination) {
|
|
316
|
+
this.sinkStreamDestination = this.ac.createMediaStreamDestination();
|
|
317
|
+
}
|
|
309
318
|
this.gainNode.disconnect();
|
|
310
|
-
this.gainNode.connect(
|
|
311
|
-
|
|
319
|
+
this.gainNode.connect(this.sinkStreamDestination);
|
|
320
|
+
this.sinkAudioElement.srcObject = this.sinkStreamDestination.stream;
|
|
312
321
|
|
|
313
|
-
return
|
|
322
|
+
return this.sinkAudioElement.setSinkId(deviceId);
|
|
314
323
|
} else {
|
|
315
324
|
return Promise.reject(new Error('Invalid deviceId: ' + deviceId));
|
|
316
325
|
}
|
|
@@ -541,6 +550,14 @@ export default class WebAudio extends util.Observer {
|
|
|
541
550
|
// clear the offlineAudioContext
|
|
542
551
|
window.WaveSurferOfflineAudioContext = null;
|
|
543
552
|
}
|
|
553
|
+
|
|
554
|
+
// disconnect resources used by setSinkId
|
|
555
|
+
if (this.sinkStreamDestination) {
|
|
556
|
+
this.sinkAudioElement.pause();
|
|
557
|
+
this.sinkAudioElement.srcObject = null;
|
|
558
|
+
this.sinkStreamDestination.disconnect();
|
|
559
|
+
this.sinkStreamDestination = null;
|
|
560
|
+
}
|
|
544
561
|
}
|
|
545
562
|
/**
|
|
546
563
|
* This is called when wavesurfer is destroyed
|