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.
- package/CHANGES.md +36 -1
- package/README.md +6 -3
- package/dist/plugin/wavesurfer.cursor.js +39 -34
- 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 +29 -27
- 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 +381 -0
- package/dist/plugin/wavesurfer.markers.js.map +1 -0
- package/dist/plugin/wavesurfer.markers.min.js +7 -0
- package/dist/plugin/wavesurfer.markers.min.js.map +1 -0
- package/dist/plugin/wavesurfer.mediasession.js +29 -27
- 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 +29 -27
- 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 +30 -28
- 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 +324 -0
- package/dist/plugin/wavesurfer.playhead.js.map +1 -0
- package/dist/plugin/wavesurfer.playhead.min.js +7 -0
- package/dist/plugin/wavesurfer.playhead.min.js.map +1 -0
- package/dist/plugin/wavesurfer.regions.js +152 -126
- 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 +97 -89
- 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 +46 -32
- 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 +9 -5
- 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 +350 -166
- 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 +19 -16
- package/src/drawer.canvasentry.js +16 -0
- package/src/drawer.js +30 -21
- package/src/drawer.multicanvas.js +63 -39
- package/src/plugin/cursor/index.js +3 -1
- package/src/plugin/markers/index.js +282 -0
- package/src/plugin/playhead/index.js +226 -0
- package/src/plugin/regions/index.js +28 -11
- package/src/plugin/regions/region.js +83 -70
- package/src/plugin/spectrogram/index.js +65 -61
- package/src/plugin/timeline/index.js +20 -11
- package/src/util/index.js +1 -0
- package/src/util/orientation.js +98 -0
- package/src/wavesurfer.js +18 -9
- package/src/webaudio.js +10 -9
package/dist/wavesurfer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wavesurfer.js
|
|
2
|
+
* wavesurfer.js 5.1.0 (2021-06-20)
|
|
3
3
|
* https://wavesurfer-js.org
|
|
4
4
|
* @license BSD-3-Clause
|
|
5
5
|
*/
|
|
@@ -196,6 +196,24 @@ var CanvasEntry = /*#__PURE__*/function () {
|
|
|
196
196
|
this.progressCtx.fillStyle = progressColor;
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Set the canvas transforms for wave and progress
|
|
201
|
+
*
|
|
202
|
+
* @param {boolean} vertical Whether to render vertically
|
|
203
|
+
*/
|
|
204
|
+
|
|
205
|
+
}, {
|
|
206
|
+
key: "applyCanvasTransforms",
|
|
207
|
+
value: function applyCanvasTransforms(vertical) {
|
|
208
|
+
if (vertical) {
|
|
209
|
+
// Reflect the waveform across the line y = -x
|
|
210
|
+
this.waveCtx.setTransform(0, 1, 1, 0, 0, 0);
|
|
211
|
+
|
|
212
|
+
if (this.hasProgressCanvas) {
|
|
213
|
+
this.progressCtx.setTransform(0, 1, 1, 0, 0, 0);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
199
217
|
/**
|
|
200
218
|
* Draw a rectangle for wave and progress
|
|
201
219
|
*
|
|
@@ -426,9 +444,9 @@ exports.default = void 0;
|
|
|
426
444
|
|
|
427
445
|
var util = _interopRequireWildcard(__webpack_require__(/*! ./util */ "./src/util/index.js"));
|
|
428
446
|
|
|
429
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
447
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
430
448
|
|
|
431
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
449
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
432
450
|
|
|
433
451
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
434
452
|
|
|
@@ -446,7 +464,7 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
446
464
|
|
|
447
465
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
448
466
|
|
|
449
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
467
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
450
468
|
|
|
451
469
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
452
470
|
|
|
@@ -470,7 +488,7 @@ var Drawer = /*#__PURE__*/function (_util$Observer) {
|
|
|
470
488
|
_classCallCheck(this, Drawer);
|
|
471
489
|
|
|
472
490
|
_this = _super.call(this);
|
|
473
|
-
_this.container = container;
|
|
491
|
+
_this.container = util.withOrientation(container, params.vertical);
|
|
474
492
|
/**
|
|
475
493
|
* @type {WavesurferParams}
|
|
476
494
|
*/
|
|
@@ -519,7 +537,7 @@ var Drawer = /*#__PURE__*/function (_util$Observer) {
|
|
|
519
537
|
}, {
|
|
520
538
|
key: "createWrapper",
|
|
521
539
|
value: function createWrapper() {
|
|
522
|
-
this.wrapper = this.container.appendChild(document.createElement('wave'));
|
|
540
|
+
this.wrapper = util.withOrientation(this.container.appendChild(document.createElement('wave')), this.params.vertical);
|
|
523
541
|
this.style(this.wrapper, {
|
|
524
542
|
display: 'block',
|
|
525
543
|
position: 'relative',
|
|
@@ -550,33 +568,44 @@ var Drawer = /*#__PURE__*/function (_util$Observer) {
|
|
|
550
568
|
key: "handleEvent",
|
|
551
569
|
value: function handleEvent(e, noPrevent) {
|
|
552
570
|
!noPrevent && e.preventDefault();
|
|
553
|
-
var clientX = e.targetTouches ? e.targetTouches[0]
|
|
571
|
+
var clientX = util.withOrientation(e.targetTouches ? e.targetTouches[0] : e, this.params.vertical).clientX;
|
|
554
572
|
var bbox = this.wrapper.getBoundingClientRect();
|
|
555
573
|
var nominalWidth = this.width;
|
|
556
574
|
var parentWidth = this.getWidth();
|
|
575
|
+
var progressPixels = this.getProgressPixels(bbox, clientX);
|
|
557
576
|
var progress;
|
|
558
577
|
|
|
559
578
|
if (!this.params.fillParent && nominalWidth < parentWidth) {
|
|
560
|
-
progress =
|
|
579
|
+
progress = progressPixels * (this.params.pixelRatio / nominalWidth) || 0;
|
|
561
580
|
} else {
|
|
562
|
-
progress = (
|
|
581
|
+
progress = (progressPixels + this.wrapper.scrollLeft) / this.wrapper.scrollWidth || 0;
|
|
563
582
|
}
|
|
564
583
|
|
|
565
584
|
return util.clamp(progress, 0, 1);
|
|
566
585
|
}
|
|
586
|
+
}, {
|
|
587
|
+
key: "getProgressPixels",
|
|
588
|
+
value: function getProgressPixels(wrapperBbox, clientX) {
|
|
589
|
+
if (this.params.rtl) {
|
|
590
|
+
return wrapperBbox.right - clientX;
|
|
591
|
+
} else {
|
|
592
|
+
return clientX - wrapperBbox.left;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
567
595
|
}, {
|
|
568
596
|
key: "setupWrapperEvents",
|
|
569
597
|
value: function setupWrapperEvents() {
|
|
570
598
|
var _this2 = this;
|
|
571
599
|
|
|
572
600
|
this.wrapper.addEventListener('click', function (e) {
|
|
601
|
+
var orientedEvent = util.withOrientation(e, _this2.params.vertical);
|
|
573
602
|
var scrollbarHeight = _this2.wrapper.offsetHeight - _this2.wrapper.clientHeight;
|
|
574
603
|
|
|
575
604
|
if (scrollbarHeight !== 0) {
|
|
576
605
|
// scrollbar is visible. Check if click was on it
|
|
577
606
|
var bbox = _this2.wrapper.getBoundingClientRect();
|
|
578
607
|
|
|
579
|
-
if (
|
|
608
|
+
if (orientedEvent.clientY >= bbox.bottom - scrollbarHeight) {
|
|
580
609
|
// ignore mousedown as it was on the scrollbar
|
|
581
610
|
return;
|
|
582
611
|
}
|
|
@@ -738,8 +767,9 @@ var Drawer = /*#__PURE__*/function (_util$Observer) {
|
|
|
738
767
|
width: ''
|
|
739
768
|
});
|
|
740
769
|
} else {
|
|
770
|
+
var newWidth = ~~(this.width / this.params.pixelRatio) + 'px';
|
|
741
771
|
this.style(this.wrapper, {
|
|
742
|
-
width:
|
|
772
|
+
width: newWidth
|
|
743
773
|
});
|
|
744
774
|
}
|
|
745
775
|
|
|
@@ -800,8 +830,8 @@ var Drawer = /*#__PURE__*/function (_util$Observer) {
|
|
|
800
830
|
this.unAll();
|
|
801
831
|
|
|
802
832
|
if (this.wrapper) {
|
|
803
|
-
if (this.wrapper.parentNode == this.container) {
|
|
804
|
-
this.container.removeChild(this.wrapper);
|
|
833
|
+
if (this.wrapper.parentNode == this.container.domElement) {
|
|
834
|
+
this.container.removeChild(this.wrapper.domElement);
|
|
805
835
|
}
|
|
806
836
|
|
|
807
837
|
this.wrapper = null;
|
|
@@ -912,9 +942,9 @@ var util = _interopRequireWildcard(__webpack_require__(/*! ./util */ "./src/util
|
|
|
912
942
|
|
|
913
943
|
var _drawer2 = _interopRequireDefault(__webpack_require__(/*! ./drawer.canvasentry */ "./src/drawer.canvasentry.js"));
|
|
914
944
|
|
|
915
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
945
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
916
946
|
|
|
917
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
947
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
918
948
|
|
|
919
949
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
920
950
|
|
|
@@ -934,7 +964,7 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
934
964
|
|
|
935
965
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
936
966
|
|
|
937
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
967
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
938
968
|
|
|
939
969
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
940
970
|
|
|
@@ -1024,6 +1054,13 @@ var MultiCanvas = /*#__PURE__*/function (_Drawer) {
|
|
|
1024
1054
|
*/
|
|
1025
1055
|
|
|
1026
1056
|
_this.barRadius = params.barRadius || 0;
|
|
1057
|
+
/**
|
|
1058
|
+
* Whether to render the waveform vertically. Defaults to false.
|
|
1059
|
+
*
|
|
1060
|
+
* @type {boolean}
|
|
1061
|
+
*/
|
|
1062
|
+
|
|
1063
|
+
_this.vertical = params.vertical;
|
|
1027
1064
|
return _this;
|
|
1028
1065
|
}
|
|
1029
1066
|
/**
|
|
@@ -1045,7 +1082,8 @@ var MultiCanvas = /*#__PURE__*/function (_Drawer) {
|
|
|
1045
1082
|
}, {
|
|
1046
1083
|
key: "createElements",
|
|
1047
1084
|
value: function createElements() {
|
|
1048
|
-
this.progressWave = this.wrapper.appendChild(
|
|
1085
|
+
this.progressWave = util.withOrientation(this.wrapper.appendChild(document.createElement('wave')), this.params.vertical);
|
|
1086
|
+
this.style(this.progressWave, {
|
|
1049
1087
|
position: 'absolute',
|
|
1050
1088
|
zIndex: 3,
|
|
1051
1089
|
left: 0,
|
|
@@ -1057,7 +1095,7 @@ var MultiCanvas = /*#__PURE__*/function (_Drawer) {
|
|
|
1057
1095
|
boxSizing: 'border-box',
|
|
1058
1096
|
borderRightStyle: 'solid',
|
|
1059
1097
|
pointerEvents: 'none'
|
|
1060
|
-
})
|
|
1098
|
+
});
|
|
1061
1099
|
this.addCanvas();
|
|
1062
1100
|
this.updateCursor();
|
|
1063
1101
|
}
|
|
@@ -1120,7 +1158,8 @@ var MultiCanvas = /*#__PURE__*/function (_Drawer) {
|
|
|
1120
1158
|
entry.halfPixel = this.halfPixel;
|
|
1121
1159
|
var leftOffset = this.maxCanvasElementWidth * this.canvases.length; // wave
|
|
1122
1160
|
|
|
1123
|
-
|
|
1161
|
+
var wave = util.withOrientation(this.wrapper.appendChild(document.createElement('canvas')), this.params.vertical);
|
|
1162
|
+
this.style(wave, {
|
|
1124
1163
|
position: 'absolute',
|
|
1125
1164
|
zIndex: 2,
|
|
1126
1165
|
left: leftOffset + 'px',
|
|
@@ -1128,16 +1167,19 @@ var MultiCanvas = /*#__PURE__*/function (_Drawer) {
|
|
|
1128
1167
|
bottom: 0,
|
|
1129
1168
|
height: '100%',
|
|
1130
1169
|
pointerEvents: 'none'
|
|
1131
|
-
})
|
|
1170
|
+
});
|
|
1171
|
+
entry.initWave(wave); // progress
|
|
1132
1172
|
|
|
1133
1173
|
if (this.hasProgressCanvas) {
|
|
1134
|
-
|
|
1174
|
+
var progress = util.withOrientation(this.progressWave.appendChild(document.createElement('canvas')), this.params.vertical);
|
|
1175
|
+
this.style(progress, {
|
|
1135
1176
|
position: 'absolute',
|
|
1136
1177
|
left: leftOffset + 'px',
|
|
1137
1178
|
top: 0,
|
|
1138
1179
|
bottom: 0,
|
|
1139
1180
|
height: '100%'
|
|
1140
|
-
})
|
|
1181
|
+
});
|
|
1182
|
+
entry.initProgress(progress);
|
|
1141
1183
|
}
|
|
1142
1184
|
|
|
1143
1185
|
this.canvases.push(entry);
|
|
@@ -1152,10 +1194,10 @@ var MultiCanvas = /*#__PURE__*/function (_Drawer) {
|
|
|
1152
1194
|
value: function removeCanvas() {
|
|
1153
1195
|
var lastEntry = this.canvases[this.canvases.length - 1]; // wave
|
|
1154
1196
|
|
|
1155
|
-
lastEntry.wave.parentElement.removeChild(lastEntry.wave); // progress
|
|
1197
|
+
lastEntry.wave.parentElement.removeChild(lastEntry.wave.domElement); // progress
|
|
1156
1198
|
|
|
1157
1199
|
if (this.hasProgressCanvas) {
|
|
1158
|
-
lastEntry.progress.parentElement.removeChild(lastEntry.progress);
|
|
1200
|
+
lastEntry.progress.parentElement.removeChild(lastEntry.progress.domElement);
|
|
1159
1201
|
} // cleanup
|
|
1160
1202
|
|
|
1161
1203
|
|
|
@@ -1252,7 +1294,9 @@ var MultiCanvas = /*#__PURE__*/function (_Drawer) {
|
|
|
1252
1294
|
/* in case of silences, allow the user to specify that we
|
|
1253
1295
|
* always draw *something* (normally a 1px high bar) */
|
|
1254
1296
|
|
|
1255
|
-
if (h == 0 && _this4.params.barMinHeight)
|
|
1297
|
+
if (h == 0 && _this4.params.barMinHeight) {
|
|
1298
|
+
h = _this4.params.barMinHeight;
|
|
1299
|
+
}
|
|
1256
1300
|
|
|
1257
1301
|
_this4.fillRect(i + _this4.halfPixel, halfH - h + offsetY, bar + _this4.halfPixel, h * 2, _this4.barRadius, ch);
|
|
1258
1302
|
}
|
|
@@ -1335,6 +1379,8 @@ var MultiCanvas = /*#__PURE__*/function (_Drawer) {
|
|
|
1335
1379
|
this.canvases.forEach(function (entry, i) {
|
|
1336
1380
|
_this6.setFillStyles(entry, waveColor, progressColor);
|
|
1337
1381
|
|
|
1382
|
+
_this6.applyCanvasTransforms(entry, _this6.params.vertical);
|
|
1383
|
+
|
|
1338
1384
|
entry.drawLines(peaks, absmax, halfH, offsetY, start, end);
|
|
1339
1385
|
});
|
|
1340
1386
|
}
|
|
@@ -1372,6 +1418,7 @@ var MultiCanvas = /*#__PURE__*/function (_Drawer) {
|
|
|
1372
1418
|
progressColor = _ref4.progressColor;
|
|
1373
1419
|
|
|
1374
1420
|
this.setFillStyles(entry, waveColor, progressColor);
|
|
1421
|
+
this.applyCanvasTransforms(entry, this.params.vertical);
|
|
1375
1422
|
entry.fillRects(intersection.x1 - leftOffset, intersection.y1, intersection.x2 - intersection.x1, intersection.y2 - intersection.y1, radius);
|
|
1376
1423
|
}
|
|
1377
1424
|
}
|
|
@@ -1495,6 +1542,19 @@ var MultiCanvas = /*#__PURE__*/function (_Drawer) {
|
|
|
1495
1542
|
var progressColor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.params.progressColor;
|
|
1496
1543
|
entry.setFillStyles(waveColor, progressColor);
|
|
1497
1544
|
}
|
|
1545
|
+
/**
|
|
1546
|
+
* Set the canvas transforms for a certain entry (wave and progress)
|
|
1547
|
+
*
|
|
1548
|
+
* @param {CanvasEntry} entry Target entry
|
|
1549
|
+
* @param {boolean} vertical Whether to render the waveform vertically
|
|
1550
|
+
*/
|
|
1551
|
+
|
|
1552
|
+
}, {
|
|
1553
|
+
key: "applyCanvasTransforms",
|
|
1554
|
+
value: function applyCanvasTransforms(entry) {
|
|
1555
|
+
var vertical = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1556
|
+
entry.applyCanvasTransforms(vertical);
|
|
1557
|
+
}
|
|
1498
1558
|
/**
|
|
1499
1559
|
* Return image data of the multi-canvas
|
|
1500
1560
|
*
|
|
@@ -1587,7 +1647,7 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
1587
1647
|
|
|
1588
1648
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
1589
1649
|
|
|
1590
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
1650
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
1591
1651
|
|
|
1592
1652
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
1593
1653
|
|
|
@@ -1716,9 +1776,9 @@ var _webaudio = _interopRequireDefault(__webpack_require__(/*! ./webaudio */ "./
|
|
|
1716
1776
|
|
|
1717
1777
|
var util = _interopRequireWildcard(__webpack_require__(/*! ./util */ "./src/util/index.js"));
|
|
1718
1778
|
|
|
1719
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
1779
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
1720
1780
|
|
|
1721
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
1781
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
1722
1782
|
|
|
1723
1783
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1724
1784
|
|
|
@@ -1742,7 +1802,7 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
1742
1802
|
|
|
1743
1803
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
1744
1804
|
|
|
1745
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
1805
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
1746
1806
|
|
|
1747
1807
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
1748
1808
|
|
|
@@ -2918,6 +2978,12 @@ Object.defineProperty(exports, "clamp", ({
|
|
|
2918
2978
|
return _clamp.default;
|
|
2919
2979
|
}
|
|
2920
2980
|
}));
|
|
2981
|
+
Object.defineProperty(exports, "withOrientation", ({
|
|
2982
|
+
enumerable: true,
|
|
2983
|
+
get: function get() {
|
|
2984
|
+
return _orientation.default;
|
|
2985
|
+
}
|
|
2986
|
+
}));
|
|
2921
2987
|
|
|
2922
2988
|
var _getId = _interopRequireDefault(__webpack_require__(/*! ./get-id */ "./src/util/get-id.js"));
|
|
2923
2989
|
|
|
@@ -2943,6 +3009,8 @@ var _fetch = _interopRequireDefault(__webpack_require__(/*! ./fetch */ "./src/ut
|
|
|
2943
3009
|
|
|
2944
3010
|
var _clamp = _interopRequireDefault(__webpack_require__(/*! ./clamp */ "./src/util/clamp.js"));
|
|
2945
3011
|
|
|
3012
|
+
var _orientation = _interopRequireDefault(__webpack_require__(/*! ./orientation */ "./src/util/orientation.js"));
|
|
3013
|
+
|
|
2946
3014
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2947
3015
|
|
|
2948
3016
|
/***/ }),
|
|
@@ -3224,6 +3292,113 @@ module.exports = exports.default;
|
|
|
3224
3292
|
|
|
3225
3293
|
/***/ }),
|
|
3226
3294
|
|
|
3295
|
+
/***/ "./src/util/orientation.js":
|
|
3296
|
+
/*!*********************************!*\
|
|
3297
|
+
!*** ./src/util/orientation.js ***!
|
|
3298
|
+
\*********************************/
|
|
3299
|
+
/***/ ((module, exports) => {
|
|
3300
|
+
|
|
3301
|
+
"use strict";
|
|
3302
|
+
|
|
3303
|
+
|
|
3304
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
3305
|
+
value: true
|
|
3306
|
+
}));
|
|
3307
|
+
exports.default = withOrientation;
|
|
3308
|
+
var verticalPropMap = {
|
|
3309
|
+
width: 'height',
|
|
3310
|
+
height: 'width',
|
|
3311
|
+
overflowX: 'overflowY',
|
|
3312
|
+
overflowY: 'overflowX',
|
|
3313
|
+
clientWidth: 'clientHeight',
|
|
3314
|
+
clientHeight: 'clientWidth',
|
|
3315
|
+
clientX: 'clientY',
|
|
3316
|
+
clientY: 'clientX',
|
|
3317
|
+
scrollWidth: 'scrollHeight',
|
|
3318
|
+
scrollLeft: 'scrollTop',
|
|
3319
|
+
offsetLeft: 'offsetTop',
|
|
3320
|
+
offsetTop: 'offsetLeft',
|
|
3321
|
+
offsetHeight: 'offsetWidth',
|
|
3322
|
+
offsetWidth: 'offsetHeight',
|
|
3323
|
+
left: 'top',
|
|
3324
|
+
right: 'bottom',
|
|
3325
|
+
top: 'left',
|
|
3326
|
+
bottom: 'right',
|
|
3327
|
+
borderRightStyle: 'borderBottomStyle',
|
|
3328
|
+
borderRightWidth: 'borderBottomWidth',
|
|
3329
|
+
borderRightColor: 'borderBottomColor'
|
|
3330
|
+
};
|
|
3331
|
+
/**
|
|
3332
|
+
* Convert a horizontally-oriented property name to a vertical one.
|
|
3333
|
+
*
|
|
3334
|
+
* @param {string} prop A property name
|
|
3335
|
+
* @param {bool} vertical Whether the element is oriented vertically
|
|
3336
|
+
* @returns {string} prop, converted appropriately
|
|
3337
|
+
*/
|
|
3338
|
+
|
|
3339
|
+
function mapProp(prop, vertical) {
|
|
3340
|
+
if (Object.prototype.hasOwnProperty.call(verticalPropMap, prop)) {
|
|
3341
|
+
return vertical ? verticalPropMap[prop] : prop;
|
|
3342
|
+
} else {
|
|
3343
|
+
return prop;
|
|
3344
|
+
}
|
|
3345
|
+
}
|
|
3346
|
+
|
|
3347
|
+
var isProxy = Symbol("isProxy");
|
|
3348
|
+
/**
|
|
3349
|
+
* Returns an appropriately oriented object based on vertical.
|
|
3350
|
+
* If vertical is true, attribute getting and setting will be mapped through
|
|
3351
|
+
* verticalPropMap, so that e.g. getting the object's .width will give its
|
|
3352
|
+
* .height instead.
|
|
3353
|
+
* Certain methods of an oriented object will return oriented objects as well.
|
|
3354
|
+
* Oriented objects can't be added to the DOM directly since they are Proxy objects
|
|
3355
|
+
* and thus fail typechecks. Use domElement to get the actual element for this.
|
|
3356
|
+
*
|
|
3357
|
+
* @param {object} target The object to be wrapped and oriented
|
|
3358
|
+
* @param {bool} vertical Whether the element is oriented vertically
|
|
3359
|
+
* @returns {Proxy} An oriented object with attr translation via verticalAttrMap
|
|
3360
|
+
* @since 5.0.0
|
|
3361
|
+
*/
|
|
3362
|
+
|
|
3363
|
+
function withOrientation(target, vertical) {
|
|
3364
|
+
if (target[isProxy]) {
|
|
3365
|
+
return target;
|
|
3366
|
+
} else {
|
|
3367
|
+
return new Proxy(target, {
|
|
3368
|
+
get: function get(obj, prop, receiver) {
|
|
3369
|
+
if (prop === isProxy) {
|
|
3370
|
+
return true;
|
|
3371
|
+
} else if (prop === 'domElement') {
|
|
3372
|
+
return obj;
|
|
3373
|
+
} else if (prop === 'style') {
|
|
3374
|
+
return withOrientation(obj.style, vertical);
|
|
3375
|
+
} else if (prop === 'canvas') {
|
|
3376
|
+
return withOrientation(obj.canvas, vertical);
|
|
3377
|
+
} else if (prop === 'getBoundingClientRect') {
|
|
3378
|
+
return function () {
|
|
3379
|
+
return withOrientation(obj.getBoundingClientRect.apply(obj, arguments), vertical);
|
|
3380
|
+
};
|
|
3381
|
+
} else if (prop === 'getContext') {
|
|
3382
|
+
return function () {
|
|
3383
|
+
return withOrientation(obj.getContext.apply(obj, arguments), vertical);
|
|
3384
|
+
};
|
|
3385
|
+
} else {
|
|
3386
|
+
var value = obj[mapProp(prop, vertical)];
|
|
3387
|
+
return typeof value == 'function' ? value.bind(obj) : value;
|
|
3388
|
+
}
|
|
3389
|
+
},
|
|
3390
|
+
set: function set(obj, prop, value) {
|
|
3391
|
+
obj[mapProp(prop, vertical)] = value;
|
|
3392
|
+
return true;
|
|
3393
|
+
}
|
|
3394
|
+
});
|
|
3395
|
+
}
|
|
3396
|
+
}
|
|
3397
|
+
|
|
3398
|
+
module.exports = exports.default;
|
|
3399
|
+
|
|
3400
|
+
/***/ }),
|
|
3401
|
+
|
|
3227
3402
|
/***/ "./src/util/prevent-click.js":
|
|
3228
3403
|
/*!***********************************!*\
|
|
3229
3404
|
!*** ./src/util/prevent-click.js ***!
|
|
@@ -3359,9 +3534,9 @@ var _mediaelementWebaudio = _interopRequireDefault(__webpack_require__(/*! ./med
|
|
|
3359
3534
|
|
|
3360
3535
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
3361
3536
|
|
|
3362
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
3537
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
3363
3538
|
|
|
3364
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
3539
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
3365
3540
|
|
|
3366
3541
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
3367
3542
|
|
|
@@ -3373,7 +3548,7 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
3373
3548
|
|
|
3374
3549
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
3375
3550
|
|
|
3376
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
3551
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
3377
3552
|
|
|
3378
3553
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
3379
3554
|
|
|
@@ -3499,6 +3674,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
3499
3674
|
* @property {boolean} splitChannels=false Render with separate waveforms for
|
|
3500
3675
|
* the channels of the audio
|
|
3501
3676
|
* @property {SplitChannelOptions} splitChannelsOptions={} Options for splitChannel rendering
|
|
3677
|
+
* @property {boolean} vertical=false Render the waveform vertically instead of horizontally.
|
|
3502
3678
|
* @property {string} waveColor='#999' The fill color of the waveform after the
|
|
3503
3679
|
* cursor.
|
|
3504
3680
|
* @property {object} xhr={} XHR options. For example:
|
|
@@ -3566,29 +3742,12 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
3566
3742
|
* @extends {Observer}
|
|
3567
3743
|
*/
|
|
3568
3744
|
var PluginClass = /*#__PURE__*/function () {
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
* This function must be used to create a plugin definition which can be
|
|
3576
|
-
* used by wavesurfer to correctly instantiate the plugin.
|
|
3577
|
-
*
|
|
3578
|
-
* It returns a `PluginDefinition` object representing the plugin.
|
|
3579
|
-
*
|
|
3580
|
-
* @param {Object} params={} The plugin params (specific to the plugin)
|
|
3581
|
-
*/
|
|
3582
|
-
value: function create(params) {}
|
|
3583
|
-
/**
|
|
3584
|
-
* Construct the plugin
|
|
3585
|
-
*
|
|
3586
|
-
* @param {Object} params={} The plugin params (specific to the plugin)
|
|
3587
|
-
* @param {Object} ws The wavesurfer instance
|
|
3588
|
-
*/
|
|
3589
|
-
|
|
3590
|
-
}]);
|
|
3591
|
-
|
|
3745
|
+
/**
|
|
3746
|
+
* Construct the plugin
|
|
3747
|
+
*
|
|
3748
|
+
* @param {Object} params={} The plugin params (specific to the plugin)
|
|
3749
|
+
* @param {Object} ws The wavesurfer instance
|
|
3750
|
+
*/
|
|
3592
3751
|
function PluginClass(params, ws) {
|
|
3593
3752
|
_classCallCheck(this, PluginClass);
|
|
3594
3753
|
}
|
|
@@ -3601,6 +3760,20 @@ var PluginClass = /*#__PURE__*/function () {
|
|
|
3601
3760
|
|
|
3602
3761
|
|
|
3603
3762
|
_createClass(PluginClass, [{
|
|
3763
|
+
key: "create",
|
|
3764
|
+
value:
|
|
3765
|
+
/**
|
|
3766
|
+
* Plugin definition factory
|
|
3767
|
+
*
|
|
3768
|
+
* This function must be used to create a plugin definition which can be
|
|
3769
|
+
* used by wavesurfer to correctly instantiate the plugin.
|
|
3770
|
+
*
|
|
3771
|
+
* It returns a `PluginDefinition` object representing the plugin.
|
|
3772
|
+
*
|
|
3773
|
+
* @param {Object} params={} The plugin params (specific to the plugin)
|
|
3774
|
+
*/
|
|
3775
|
+
function create(params) {}
|
|
3776
|
+
}, {
|
|
3604
3777
|
key: "init",
|
|
3605
3778
|
value: function init() {}
|
|
3606
3779
|
/**
|
|
@@ -3645,35 +3818,6 @@ var WaveSurfer = /*#__PURE__*/function (_util$Observer) {
|
|
|
3645
3818
|
|
|
3646
3819
|
var _super = _createSuper(WaveSurfer);
|
|
3647
3820
|
|
|
3648
|
-
_createClass(WaveSurfer, null, [{
|
|
3649
|
-
key: "create",
|
|
3650
|
-
|
|
3651
|
-
/** @private */
|
|
3652
|
-
|
|
3653
|
-
/** @private */
|
|
3654
|
-
|
|
3655
|
-
/**
|
|
3656
|
-
* Instantiate this class, call its `init` function and returns it
|
|
3657
|
-
*
|
|
3658
|
-
* @param {WavesurferParams} params The wavesurfer parameters
|
|
3659
|
-
* @return {Object} WaveSurfer instance
|
|
3660
|
-
* @example const wavesurfer = WaveSurfer.create(params);
|
|
3661
|
-
*/
|
|
3662
|
-
value: function create(params) {
|
|
3663
|
-
var wavesurfer = new WaveSurfer(params);
|
|
3664
|
-
return wavesurfer.init();
|
|
3665
|
-
}
|
|
3666
|
-
/**
|
|
3667
|
-
* The library version number is available as a static property of the
|
|
3668
|
-
* WaveSurfer class
|
|
3669
|
-
*
|
|
3670
|
-
* @type {String}
|
|
3671
|
-
* @example
|
|
3672
|
-
* console.log('Using wavesurfer.js ' + WaveSurfer.VERSION);
|
|
3673
|
-
*/
|
|
3674
|
-
|
|
3675
|
-
}]);
|
|
3676
|
-
|
|
3677
3821
|
/**
|
|
3678
3822
|
* Initialise wavesurfer instance
|
|
3679
3823
|
*
|
|
@@ -3746,6 +3890,7 @@ var WaveSurfer = /*#__PURE__*/function (_util$Observer) {
|
|
|
3746
3890
|
filterChannels: [],
|
|
3747
3891
|
relativeNormalization: false
|
|
3748
3892
|
},
|
|
3893
|
+
vertical: false,
|
|
3749
3894
|
waveColor: '#999',
|
|
3750
3895
|
xhr: {}
|
|
3751
3896
|
};
|
|
@@ -3787,9 +3932,15 @@ var WaveSurfer = /*#__PURE__*/function (_util$Observer) {
|
|
|
3787
3932
|
}
|
|
3788
3933
|
|
|
3789
3934
|
if (_this.params.rtl === true) {
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3935
|
+
if (_this.params.vertical === true) {
|
|
3936
|
+
util.style(_this.container, {
|
|
3937
|
+
transform: 'rotateX(180deg)'
|
|
3938
|
+
});
|
|
3939
|
+
} else {
|
|
3940
|
+
util.style(_this.container, {
|
|
3941
|
+
transform: 'rotateY(180deg)'
|
|
3942
|
+
});
|
|
3943
|
+
}
|
|
3793
3944
|
}
|
|
3794
3945
|
|
|
3795
3946
|
if (_this.params.backgroundColor) {
|
|
@@ -5102,7 +5253,8 @@ var WaveSurfer = /*#__PURE__*/function (_util$Observer) {
|
|
|
5102
5253
|
this.fireEvent('loading', Math.round(percentComplete * 100), e.target);
|
|
5103
5254
|
}
|
|
5104
5255
|
/**
|
|
5105
|
-
* Exports PCM data into a JSON array and opens in a new window
|
|
5256
|
+
* Exports PCM data into a JSON array and optionally opens in a new window
|
|
5257
|
+
* as valid JSON Blob instance.
|
|
5106
5258
|
*
|
|
5107
5259
|
* @param {number} length=1024 The scale in which to export the peaks
|
|
5108
5260
|
* @param {number} accuracy=10000
|
|
@@ -5125,13 +5277,16 @@ var WaveSurfer = /*#__PURE__*/function (_util$Observer) {
|
|
|
5125
5277
|
return Math.round(val * accuracy) / accuracy;
|
|
5126
5278
|
});
|
|
5127
5279
|
return new Promise(function (resolve, reject) {
|
|
5128
|
-
var json = JSON.stringify(arr);
|
|
5129
|
-
|
|
5130
5280
|
if (!noWindow) {
|
|
5131
|
-
|
|
5281
|
+
var blobJSON = new Blob([JSON.stringify(arr)], {
|
|
5282
|
+
type: 'application/json;charset=utf-8'
|
|
5283
|
+
});
|
|
5284
|
+
var objURL = URL.createObjectURL(blobJSON);
|
|
5285
|
+
window.open(objURL);
|
|
5286
|
+
URL.revokeObjectURL(objURL);
|
|
5132
5287
|
}
|
|
5133
5288
|
|
|
5134
|
-
resolve(
|
|
5289
|
+
resolve(arr);
|
|
5135
5290
|
});
|
|
5136
5291
|
}
|
|
5137
5292
|
/**
|
|
@@ -5257,13 +5412,40 @@ var WaveSurfer = /*#__PURE__*/function (_util$Observer) {
|
|
|
5257
5412
|
this.isReady = false;
|
|
5258
5413
|
this.arraybuffer = null;
|
|
5259
5414
|
}
|
|
5415
|
+
}], [{
|
|
5416
|
+
key: "create",
|
|
5417
|
+
value:
|
|
5418
|
+
/** @private */
|
|
5419
|
+
|
|
5420
|
+
/** @private */
|
|
5421
|
+
|
|
5422
|
+
/**
|
|
5423
|
+
* Instantiate this class, call its `init` function and returns it
|
|
5424
|
+
*
|
|
5425
|
+
* @param {WavesurferParams} params The wavesurfer parameters
|
|
5426
|
+
* @return {Object} WaveSurfer instance
|
|
5427
|
+
* @example const wavesurfer = WaveSurfer.create(params);
|
|
5428
|
+
*/
|
|
5429
|
+
function create(params) {
|
|
5430
|
+
var wavesurfer = new WaveSurfer(params);
|
|
5431
|
+
return wavesurfer.init();
|
|
5432
|
+
}
|
|
5433
|
+
/**
|
|
5434
|
+
* The library version number is available as a static property of the
|
|
5435
|
+
* WaveSurfer class
|
|
5436
|
+
*
|
|
5437
|
+
* @type {String}
|
|
5438
|
+
* @example
|
|
5439
|
+
* console.log('Using wavesurfer.js ' + WaveSurfer.VERSION);
|
|
5440
|
+
*/
|
|
5441
|
+
|
|
5260
5442
|
}]);
|
|
5261
5443
|
|
|
5262
5444
|
return WaveSurfer;
|
|
5263
5445
|
}(util.Observer);
|
|
5264
5446
|
|
|
5265
5447
|
exports.default = WaveSurfer;
|
|
5266
|
-
WaveSurfer.VERSION = "
|
|
5448
|
+
WaveSurfer.VERSION = "5.1.0";
|
|
5267
5449
|
WaveSurfer.util = util;
|
|
5268
5450
|
module.exports = exports.default;
|
|
5269
5451
|
|
|
@@ -5287,9 +5469,9 @@ exports.default = void 0;
|
|
|
5287
5469
|
|
|
5288
5470
|
var util = _interopRequireWildcard(__webpack_require__(/*! ./util */ "./src/util/index.js"));
|
|
5289
5471
|
|
|
5290
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
5472
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
5291
5473
|
|
|
5292
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
5474
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
5293
5475
|
|
|
5294
5476
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5295
5477
|
|
|
@@ -5309,7 +5491,7 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
5309
5491
|
|
|
5310
5492
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
5311
5493
|
|
|
5312
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
5494
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
5313
5495
|
|
|
5314
5496
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
5315
5497
|
|
|
@@ -5328,65 +5510,11 @@ var WebAudio = /*#__PURE__*/function (_util$Observer) {
|
|
|
5328
5510
|
|
|
5329
5511
|
var _super = _createSuper(WebAudio);
|
|
5330
5512
|
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
/** audioContext: allows to process audio with WebAudio API */
|
|
5337
|
-
|
|
5338
|
-
/** @private */
|
|
5339
|
-
|
|
5340
|
-
/** @private */
|
|
5341
|
-
|
|
5342
|
-
/**
|
|
5343
|
-
* Does the browser support this backend
|
|
5344
|
-
*
|
|
5345
|
-
* @return {boolean} Whether or not this browser supports this backend
|
|
5346
|
-
*/
|
|
5347
|
-
value: function supportsWebAudio() {
|
|
5348
|
-
return !!(window.AudioContext || window.webkitAudioContext);
|
|
5349
|
-
}
|
|
5350
|
-
/**
|
|
5351
|
-
* Get the audio context used by this backend or create one
|
|
5352
|
-
*
|
|
5353
|
-
* @return {AudioContext} Existing audio context, or creates a new one
|
|
5354
|
-
*/
|
|
5355
|
-
|
|
5356
|
-
}, {
|
|
5357
|
-
key: "getAudioContext",
|
|
5358
|
-
value: function getAudioContext() {
|
|
5359
|
-
if (!window.WaveSurferAudioContext) {
|
|
5360
|
-
window.WaveSurferAudioContext = new (window.AudioContext || window.webkitAudioContext)();
|
|
5361
|
-
}
|
|
5362
|
-
|
|
5363
|
-
return window.WaveSurferAudioContext;
|
|
5364
|
-
}
|
|
5365
|
-
/**
|
|
5366
|
-
* Get the offline audio context used by this backend or create one
|
|
5367
|
-
*
|
|
5368
|
-
* @param {number} sampleRate The sample rate to use
|
|
5369
|
-
* @return {OfflineAudioContext} Existing offline audio context, or creates
|
|
5370
|
-
* a new one
|
|
5371
|
-
*/
|
|
5372
|
-
|
|
5373
|
-
}, {
|
|
5374
|
-
key: "getOfflineAudioContext",
|
|
5375
|
-
value: function getOfflineAudioContext(sampleRate) {
|
|
5376
|
-
if (!window.WaveSurferOfflineAudioContext) {
|
|
5377
|
-
window.WaveSurferOfflineAudioContext = new (window.OfflineAudioContext || window.webkitOfflineAudioContext)(1, 2, sampleRate);
|
|
5378
|
-
}
|
|
5379
|
-
|
|
5380
|
-
return window.WaveSurferOfflineAudioContext;
|
|
5381
|
-
}
|
|
5382
|
-
/**
|
|
5383
|
-
* Construct the backend
|
|
5384
|
-
*
|
|
5385
|
-
* @param {WavesurferParams} params Wavesurfer parameters
|
|
5386
|
-
*/
|
|
5387
|
-
|
|
5388
|
-
}]);
|
|
5389
|
-
|
|
5513
|
+
/**
|
|
5514
|
+
* Construct the backend
|
|
5515
|
+
*
|
|
5516
|
+
* @param {WavesurferParams} params Wavesurfer parameters
|
|
5517
|
+
*/
|
|
5390
5518
|
function WebAudio(params) {
|
|
5391
5519
|
var _this$stateBehaviors, _this$states;
|
|
5392
5520
|
|
|
@@ -5501,6 +5629,57 @@ var WebAudio = /*#__PURE__*/function (_util$Observer) {
|
|
|
5501
5629
|
|
|
5502
5630
|
|
|
5503
5631
|
_createClass(WebAudio, [{
|
|
5632
|
+
key: "supportsWebAudio",
|
|
5633
|
+
value:
|
|
5634
|
+
/** scriptBufferSize: size of the processing buffer */
|
|
5635
|
+
|
|
5636
|
+
/** audioContext: allows to process audio with WebAudio API */
|
|
5637
|
+
|
|
5638
|
+
/** @private */
|
|
5639
|
+
|
|
5640
|
+
/** @private */
|
|
5641
|
+
|
|
5642
|
+
/**
|
|
5643
|
+
* Does the browser support this backend
|
|
5644
|
+
*
|
|
5645
|
+
* @return {boolean} Whether or not this browser supports this backend
|
|
5646
|
+
*/
|
|
5647
|
+
function supportsWebAudio() {
|
|
5648
|
+
return !!(window.AudioContext || window.webkitAudioContext);
|
|
5649
|
+
}
|
|
5650
|
+
/**
|
|
5651
|
+
* Get the audio context used by this backend or create one
|
|
5652
|
+
*
|
|
5653
|
+
* @return {AudioContext} Existing audio context, or creates a new one
|
|
5654
|
+
*/
|
|
5655
|
+
|
|
5656
|
+
}, {
|
|
5657
|
+
key: "getAudioContext",
|
|
5658
|
+
value: function getAudioContext() {
|
|
5659
|
+
if (!window.WaveSurferAudioContext) {
|
|
5660
|
+
window.WaveSurferAudioContext = new (window.AudioContext || window.webkitAudioContext)();
|
|
5661
|
+
}
|
|
5662
|
+
|
|
5663
|
+
return window.WaveSurferAudioContext;
|
|
5664
|
+
}
|
|
5665
|
+
/**
|
|
5666
|
+
* Get the offline audio context used by this backend or create one
|
|
5667
|
+
*
|
|
5668
|
+
* @param {number} sampleRate The sample rate to use
|
|
5669
|
+
* @return {OfflineAudioContext} Existing offline audio context, or creates
|
|
5670
|
+
* a new one
|
|
5671
|
+
*/
|
|
5672
|
+
|
|
5673
|
+
}, {
|
|
5674
|
+
key: "getOfflineAudioContext",
|
|
5675
|
+
value: function getOfflineAudioContext(sampleRate) {
|
|
5676
|
+
if (!window.WaveSurferOfflineAudioContext) {
|
|
5677
|
+
window.WaveSurferOfflineAudioContext = new (window.OfflineAudioContext || window.webkitOfflineAudioContext)(1, 2, sampleRate);
|
|
5678
|
+
}
|
|
5679
|
+
|
|
5680
|
+
return window.WaveSurferOfflineAudioContext;
|
|
5681
|
+
}
|
|
5682
|
+
}, {
|
|
5504
5683
|
key: "init",
|
|
5505
5684
|
value: function init() {
|
|
5506
5685
|
this.createVolumeNode();
|
|
@@ -5622,7 +5801,7 @@ var WebAudio = /*#__PURE__*/function (_util$Observer) {
|
|
|
5622
5801
|
}, {
|
|
5623
5802
|
key: "removeOnAudioProcess",
|
|
5624
5803
|
value: function removeOnAudioProcess() {
|
|
5625
|
-
this.scriptNode.onaudioprocess =
|
|
5804
|
+
this.scriptNode.onaudioprocess = null;
|
|
5626
5805
|
}
|
|
5627
5806
|
/** Create analyser node to perform audio analysis */
|
|
5628
5807
|
|
|
@@ -5721,17 +5900,18 @@ var WebAudio = /*#__PURE__*/function (_util$Observer) {
|
|
|
5721
5900
|
this.offlineAc = this.getOfflineAudioContext(this.ac && this.ac.sampleRate ? this.ac.sampleRate : 44100);
|
|
5722
5901
|
}
|
|
5723
5902
|
|
|
5724
|
-
if ('
|
|
5903
|
+
if ('webkitAudioContext' in window) {
|
|
5904
|
+
// Safari: no support for Promise-based decodeAudioData enabled
|
|
5905
|
+
// Enable it in Safari using the Experimental Features > Modern WebAudio API option
|
|
5906
|
+
this.offlineAc.decodeAudioData(arraybuffer, function (data) {
|
|
5907
|
+
return callback(data);
|
|
5908
|
+
}, errback);
|
|
5909
|
+
} else {
|
|
5725
5910
|
this.offlineAc.decodeAudioData(arraybuffer).then(function (data) {
|
|
5726
5911
|
return callback(data);
|
|
5727
5912
|
}).catch(function (err) {
|
|
5728
5913
|
return errback(err);
|
|
5729
5914
|
});
|
|
5730
|
-
} else {
|
|
5731
|
-
// Safari: no support for Promise-based decodeAudioData yet
|
|
5732
|
-
this.offlineAc.decodeAudioData(arraybuffer, function (data) {
|
|
5733
|
-
return callback(data);
|
|
5734
|
-
}, errback);
|
|
5735
5915
|
}
|
|
5736
5916
|
}
|
|
5737
5917
|
/**
|
|
@@ -6251,8 +6431,9 @@ module.exports = debounce;
|
|
|
6251
6431
|
/******/ // The require function
|
|
6252
6432
|
/******/ function __webpack_require__(moduleId) {
|
|
6253
6433
|
/******/ // Check if module is in cache
|
|
6254
|
-
/******/
|
|
6255
|
-
/******/
|
|
6434
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
6435
|
+
/******/ if (cachedModule !== undefined) {
|
|
6436
|
+
/******/ return cachedModule.exports;
|
|
6256
6437
|
/******/ }
|
|
6257
6438
|
/******/ // Create a new module (and put it into the cache)
|
|
6258
6439
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
@@ -6269,10 +6450,13 @@ module.exports = debounce;
|
|
|
6269
6450
|
/******/ }
|
|
6270
6451
|
/******/
|
|
6271
6452
|
/************************************************************************/
|
|
6272
|
-
/******/
|
|
6453
|
+
/******/
|
|
6273
6454
|
/******/ // startup
|
|
6274
6455
|
/******/ // Load entry module and return exports
|
|
6275
|
-
/******/
|
|
6456
|
+
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
6457
|
+
/******/ var __webpack_exports__ = __webpack_require__("./src/wavesurfer.js");
|
|
6458
|
+
/******/
|
|
6459
|
+
/******/ return __webpack_exports__;
|
|
6276
6460
|
/******/ })()
|
|
6277
6461
|
;
|
|
6278
6462
|
});
|