wavesurfer.js 5.1.0 → 6.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGES.md +47 -0
- package/README.md +10 -0
- package/dist/plugin/wavesurfer.cursor.js +53 -51
- package/dist/plugin/wavesurfer.cursor.js.map +1 -1
- package/dist/plugin/wavesurfer.cursor.min.js +2 -2
- package/dist/plugin/wavesurfer.cursor.min.js.map +1 -1
- package/dist/plugin/wavesurfer.elan.js +10 -7
- package/dist/plugin/wavesurfer.elan.js.map +1 -1
- package/dist/plugin/wavesurfer.elan.min.js +2 -2
- package/dist/plugin/wavesurfer.elan.min.js.map +1 -1
- package/dist/plugin/wavesurfer.markers.js +142 -26
- package/dist/plugin/wavesurfer.markers.js.map +1 -1
- package/dist/plugin/wavesurfer.markers.min.js +2 -2
- package/dist/plugin/wavesurfer.markers.min.js.map +1 -1
- package/dist/plugin/wavesurfer.mediasession.js +6 -6
- package/dist/plugin/wavesurfer.mediasession.js.map +1 -1
- package/dist/plugin/wavesurfer.mediasession.min.js +2 -2
- package/dist/plugin/wavesurfer.mediasession.min.js.map +1 -1
- package/dist/plugin/wavesurfer.microphone.js +5 -5
- package/dist/plugin/wavesurfer.microphone.js.map +1 -1
- package/dist/plugin/wavesurfer.microphone.min.js +2 -2
- package/dist/plugin/wavesurfer.microphone.min.js.map +1 -1
- package/dist/plugin/wavesurfer.minimap.js +26 -23
- package/dist/plugin/wavesurfer.minimap.js.map +1 -1
- package/dist/plugin/wavesurfer.minimap.min.js +2 -2
- package/dist/plugin/wavesurfer.minimap.min.js.map +1 -1
- package/dist/plugin/wavesurfer.playhead.js +5 -5
- package/dist/plugin/wavesurfer.playhead.js.map +1 -1
- package/dist/plugin/wavesurfer.playhead.min.js +2 -2
- package/dist/plugin/wavesurfer.playhead.min.js.map +1 -1
- package/dist/plugin/wavesurfer.regions.js +88 -21
- package/dist/plugin/wavesurfer.regions.js.map +1 -1
- package/dist/plugin/wavesurfer.regions.min.js +2 -2
- package/dist/plugin/wavesurfer.regions.min.js.map +1 -1
- package/dist/plugin/wavesurfer.spectrogram.js +71 -58
- package/dist/plugin/wavesurfer.spectrogram.js.map +1 -1
- package/dist/plugin/wavesurfer.spectrogram.min.js +2 -2
- package/dist/plugin/wavesurfer.spectrogram.min.js.map +1 -1
- package/dist/plugin/wavesurfer.timeline.js +52 -54
- package/dist/plugin/wavesurfer.timeline.js.map +1 -1
- package/dist/plugin/wavesurfer.timeline.min.js +2 -2
- package/dist/plugin/wavesurfer.timeline.min.js.map +1 -1
- package/dist/wavesurfer-html-init.js +6 -6
- package/dist/wavesurfer-html-init.js.map +1 -1
- package/dist/wavesurfer-html-init.min.js +2 -2
- package/dist/wavesurfer-html-init.min.js.map +1 -1
- package/dist/wavesurfer.js +302 -133
- package/dist/wavesurfer.js.map +1 -1
- package/dist/wavesurfer.min.js +2 -2
- package/dist/wavesurfer.min.js.map +1 -1
- package/package.json +23 -23
- package/src/drawer.canvasentry.js +33 -6
- package/src/drawer.js +1 -0
- package/src/drawer.multicanvas.js +19 -8
- package/src/mediaelement.js +1 -1
- package/src/plugin/cursor/index.js +68 -70
- package/src/plugin/markers/index.js +112 -23
- package/src/plugin/minimap/index.js +24 -21
- package/src/plugin/regions/index.js +31 -4
- package/src/plugin/regions/region.js +45 -8
- package/src/plugin/spectrogram/index.js +65 -50
- package/src/plugin/timeline/index.js +11 -9
- package/src/util/index.js +1 -0
- package/src/util/silence-mode.js +35 -0
- package/src/wavesurfer.js +54 -23
- package/src/webaudio.js +10 -1
package/src/wavesurfer.js
CHANGED
|
@@ -69,6 +69,10 @@ import MediaElementWebAudio from './mediaelement-webaudio';
|
|
|
69
69
|
* pixels.
|
|
70
70
|
* @property {boolean} hideScrollbar=false Whether to hide the horizontal
|
|
71
71
|
* scrollbar when one would normally be shown.
|
|
72
|
+
* @property {boolean} hideCursor=false Whether to hide the mouse cursor
|
|
73
|
+
* when one would normally be shown by default.
|
|
74
|
+
* @property {boolean} ignoreSilenceMode=false If true, ignores device silence mode
|
|
75
|
+
* when using the `WebAudio` backend.
|
|
72
76
|
* @property {boolean} interact=true Whether the mouse interaction will be
|
|
73
77
|
* enabled at initialization. You can switch this parameter at any time later
|
|
74
78
|
* on.
|
|
@@ -268,6 +272,8 @@ export default class WaveSurfer extends util.Observer {
|
|
|
268
272
|
forceDecode: false,
|
|
269
273
|
height: 128,
|
|
270
274
|
hideScrollbar: false,
|
|
275
|
+
hideCursor: false,
|
|
276
|
+
ignoreSilenceMode: false,
|
|
271
277
|
interact: true,
|
|
272
278
|
loopSelection: true,
|
|
273
279
|
maxCanvasWidth: 4000,
|
|
@@ -813,6 +819,11 @@ export default class WaveSurfer extends util.Observer {
|
|
|
813
819
|
* wavesurfer.play(1, 5);
|
|
814
820
|
*/
|
|
815
821
|
play(start, end) {
|
|
822
|
+
if (this.params.ignoreSilenceMode) {
|
|
823
|
+
// ignores device hardware silence mode
|
|
824
|
+
util.ignoreSilenceMode();
|
|
825
|
+
}
|
|
826
|
+
|
|
816
827
|
this.fireEvent('interaction', () => this.play(start, end));
|
|
817
828
|
return this.backend.play(start, end);
|
|
818
829
|
}
|
|
@@ -1117,40 +1128,58 @@ export default class WaveSurfer extends util.Observer {
|
|
|
1117
1128
|
/**
|
|
1118
1129
|
* Get the fill color of the waveform after the cursor.
|
|
1119
1130
|
*
|
|
1120
|
-
* @
|
|
1131
|
+
* @param {?number} channelIdx Optional index of the channel to get its wave color if splitChannels is true
|
|
1132
|
+
* @return {string|object} A CSS color string, or an array of CSS color strings.
|
|
1121
1133
|
*/
|
|
1122
|
-
getWaveColor() {
|
|
1134
|
+
getWaveColor(channelIdx = null) {
|
|
1135
|
+
if (this.params.splitChannelsOptions.channelColors[channelIdx]) {
|
|
1136
|
+
return this.params.splitChannelsOptions.channelColors[channelIdx].waveColor;
|
|
1137
|
+
}
|
|
1123
1138
|
return this.params.waveColor;
|
|
1124
1139
|
}
|
|
1125
1140
|
|
|
1126
1141
|
/**
|
|
1127
1142
|
* Set the fill color of the waveform after the cursor.
|
|
1128
1143
|
*
|
|
1129
|
-
* @param {string} color A CSS color string.
|
|
1144
|
+
* @param {string|object} color A CSS color string, or an array of CSS color strings.
|
|
1145
|
+
* @param {?number} channelIdx Optional index of the channel to set its wave color if splitChannels is true
|
|
1130
1146
|
* @example wavesurfer.setWaveColor('#ddd');
|
|
1131
1147
|
*/
|
|
1132
|
-
setWaveColor(color) {
|
|
1133
|
-
this.params.
|
|
1148
|
+
setWaveColor(color, channelIdx = null) {
|
|
1149
|
+
if (this.params.splitChannelsOptions.channelColors[channelIdx]) {
|
|
1150
|
+
this.params.splitChannelsOptions.channelColors[channelIdx].waveColor = color;
|
|
1151
|
+
} else {
|
|
1152
|
+
this.params.waveColor = color;
|
|
1153
|
+
}
|
|
1134
1154
|
this.drawBuffer();
|
|
1135
1155
|
}
|
|
1136
1156
|
|
|
1137
1157
|
/**
|
|
1138
1158
|
* Get the fill color of the waveform behind the cursor.
|
|
1139
1159
|
*
|
|
1140
|
-
* @
|
|
1160
|
+
* @param {?number} channelIdx Optional index of the channel to get its progress color if splitChannels is true
|
|
1161
|
+
* @return {string|object} A CSS color string, or an array of CSS color strings.
|
|
1141
1162
|
*/
|
|
1142
|
-
getProgressColor() {
|
|
1163
|
+
getProgressColor(channelIdx = null) {
|
|
1164
|
+
if (this.params.splitChannelsOptions.channelColors[channelIdx]) {
|
|
1165
|
+
return this.params.splitChannelsOptions.channelColors[channelIdx].progressColor;
|
|
1166
|
+
}
|
|
1143
1167
|
return this.params.progressColor;
|
|
1144
1168
|
}
|
|
1145
1169
|
|
|
1146
1170
|
/**
|
|
1147
1171
|
* Set the fill color of the waveform behind the cursor.
|
|
1148
1172
|
*
|
|
1149
|
-
* @param {string} color A CSS color string.
|
|
1173
|
+
* @param {string|object} color A CSS color string, or an array of CSS color strings.
|
|
1174
|
+
* @param {?number} channelIdx Optional index of the channel to set its progress color if splitChannels is true
|
|
1150
1175
|
* @example wavesurfer.setProgressColor('#400');
|
|
1151
1176
|
*/
|
|
1152
|
-
setProgressColor(color) {
|
|
1153
|
-
this.params.
|
|
1177
|
+
setProgressColor(color, channelIdx) {
|
|
1178
|
+
if (this.params.splitChannelsOptions.channelColors[channelIdx]) {
|
|
1179
|
+
this.params.splitChannelsOptions.channelColors[channelIdx].progressColor = color;
|
|
1180
|
+
} else {
|
|
1181
|
+
this.params.progressColor = color;
|
|
1182
|
+
}
|
|
1154
1183
|
this.drawBuffer();
|
|
1155
1184
|
}
|
|
1156
1185
|
|
|
@@ -1538,19 +1567,21 @@ export default class WaveSurfer extends util.Observer {
|
|
|
1538
1567
|
* @param {function} callback The function to call on complete
|
|
1539
1568
|
*/
|
|
1540
1569
|
decodeArrayBuffer(arraybuffer, callback) {
|
|
1541
|
-
this.
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1570
|
+
if (!this.isDestroyed) {
|
|
1571
|
+
this.arraybuffer = arraybuffer;
|
|
1572
|
+
this.backend.decodeArrayBuffer(
|
|
1573
|
+
arraybuffer,
|
|
1574
|
+
data => {
|
|
1575
|
+
// Only use the decoded data if we haven't been destroyed or
|
|
1576
|
+
// another decode started in the meantime
|
|
1577
|
+
if (!this.isDestroyed && this.arraybuffer == arraybuffer) {
|
|
1578
|
+
callback(data);
|
|
1579
|
+
this.arraybuffer = null;
|
|
1580
|
+
}
|
|
1581
|
+
},
|
|
1582
|
+
() => this.fireEvent('error', 'Error decoding audiobuffer')
|
|
1583
|
+
);
|
|
1584
|
+
}
|
|
1554
1585
|
}
|
|
1555
1586
|
|
|
1556
1587
|
/**
|
package/src/webaudio.js
CHANGED
|
@@ -702,7 +702,16 @@ export default class WebAudio extends util.Observer {
|
|
|
702
702
|
this.scheduledPause = null;
|
|
703
703
|
|
|
704
704
|
this.startPosition += this.getPlayedTime();
|
|
705
|
-
|
|
705
|
+
try {
|
|
706
|
+
this.source && this.source.stop(0);
|
|
707
|
+
} catch (err) {
|
|
708
|
+
// Calling stop can throw the following 2 errors:
|
|
709
|
+
// - RangeError (The value specified for when is negative.)
|
|
710
|
+
// - InvalidStateNode (The node has not been started by calling start().)
|
|
711
|
+
// We can safely ignore both errors, because:
|
|
712
|
+
// - The range is surely correct
|
|
713
|
+
// - The node might not have been started yet, in which case we just want to carry on without causing any trouble.
|
|
714
|
+
}
|
|
706
715
|
|
|
707
716
|
this.setState(PAUSED);
|
|
708
717
|
|