videomail-client 16.0.2 → 16.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/README.md +19 -19
- package/dist/cjs/index.cjs +340 -55
- package/dist/esm/client.d.ts +2 -0
- package/dist/esm/index.js +269 -53
- package/dist/esm/types/events/index.d.ts +3 -1
- package/dist/esm/types/events/params.d.ts +4 -0
- package/dist/esm/util/Despot.d.ts +2 -0
- package/dist/esm/util/html/media/AudioRecorder.d.ts +3 -0
- package/dist/esm/wrappers/container.d.ts +2 -0
- package/dist/esm/wrappers/form.d.ts +9 -2
- package/dist/esm/wrappers/visuals/recorder.d.ts +9 -0
- package/dist/esm/wrappers/visuals/userMedia.d.ts +8 -3
- package/dist/esm/wrappers/visuals.d.ts +3 -0
- package/dist/umd/index.js +280 -51
- package/package.json +3 -3
package/dist/cjs/index.cjs
CHANGED
|
@@ -11115,7 +11115,7 @@ var __webpack_exports__ = {};
|
|
|
11115
11115
|
var client = __webpack_require__("Q");
|
|
11116
11116
|
var client_default = /*#__PURE__*/ __webpack_require__.n(client);
|
|
11117
11117
|
var package_namespaceObject = {
|
|
11118
|
-
rE: "16.0
|
|
11118
|
+
rE: "16.1.0"
|
|
11119
11119
|
};
|
|
11120
11120
|
function isAudioEnabled(options) {
|
|
11121
11121
|
return Boolean(options.audio.enabled);
|
|
@@ -15271,13 +15271,35 @@ var __webpack_exports__ = {};
|
|
|
15271
15271
|
if ((null == type ? void 0 : type.toLowerCase()) === "hidden") inputElement.value = "";
|
|
15272
15272
|
}
|
|
15273
15273
|
}
|
|
15274
|
-
|
|
15274
|
+
connectSubmitButton() {
|
|
15275
15275
|
const submitButton = this.container.getSubmitButton();
|
|
15276
|
-
if (submitButton)
|
|
15276
|
+
if (!submitButton) return;
|
|
15277
|
+
if (submitButton.form === this.formElement) return;
|
|
15278
|
+
if (!this.formElement.id) {
|
|
15279
|
+
let formId;
|
|
15280
|
+
do formId = `videomail-form-${Form.nextFormId++}`;
|
|
15281
|
+
while (document.getElementById(formId))
|
|
15282
|
+
this.formElement.id = formId;
|
|
15283
|
+
this.generatedFormId = formId;
|
|
15284
|
+
}
|
|
15285
|
+
this.submitButton = submitButton;
|
|
15286
|
+
this.submitButtonFormAttribute = submitButton.getAttribute("form");
|
|
15287
|
+
submitButton.setAttribute("form", this.formElement.id);
|
|
15288
|
+
}
|
|
15289
|
+
startListeningToSubmitEvents() {
|
|
15290
|
+
this.connectSubmitButton();
|
|
15291
|
+
this.formElement.addEventListener("submit", this.handleSubmit);
|
|
15277
15292
|
}
|
|
15278
15293
|
stopListeningToSubmitEvents() {
|
|
15279
|
-
|
|
15280
|
-
if (submitButton)
|
|
15294
|
+
this.formElement.removeEventListener("submit", this.handleSubmit);
|
|
15295
|
+
if (this.submitButton) {
|
|
15296
|
+
if (null === this.submitButtonFormAttribute) this.submitButton.removeAttribute("form");
|
|
15297
|
+
else this.submitButton.setAttribute("form", this.submitButtonFormAttribute);
|
|
15298
|
+
this.submitButton = void 0;
|
|
15299
|
+
this.submitButtonFormAttribute = null;
|
|
15300
|
+
}
|
|
15301
|
+
if (this.generatedFormId === this.formElement.id) this.formElement.removeAttribute("id");
|
|
15302
|
+
this.generatedFormId = void 0;
|
|
15281
15303
|
}
|
|
15282
15304
|
doTheSubmit(e) {
|
|
15283
15305
|
return _async_to_generator(function*() {
|
|
@@ -15286,6 +15308,7 @@ var __webpack_exports__ = {};
|
|
|
15286
15308
|
this.options.logger.debug(`Form: doTheSubmit(${string_pretty(e)})`);
|
|
15287
15309
|
e.preventDefault();
|
|
15288
15310
|
} else this.options.logger.debug("Form: doTheSubmit()");
|
|
15311
|
+
if (this.isSubmitting) return false;
|
|
15289
15312
|
const hasHostAction = this.formElement.hasAttribute("action");
|
|
15290
15313
|
const url = null != (_this_formElement_getAttribute = this.formElement.getAttribute("action")) ? _this_formElement_getAttribute : this.options.apiUrl;
|
|
15291
15314
|
const method = this.formElement.getAttribute("method");
|
|
@@ -15300,7 +15323,14 @@ var __webpack_exports__ = {};
|
|
|
15300
15323
|
default:
|
|
15301
15324
|
chosenMethod = FormMethod.POST;
|
|
15302
15325
|
}
|
|
15303
|
-
if (this.container.hasElement())
|
|
15326
|
+
if (this.container.hasElement()) {
|
|
15327
|
+
this.isSubmitting = true;
|
|
15328
|
+
try {
|
|
15329
|
+
yield this.container.submitAll(this.getData(), chosenMethod, url, hasHostAction);
|
|
15330
|
+
} finally{
|
|
15331
|
+
this.isSubmitting = false;
|
|
15332
|
+
}
|
|
15333
|
+
}
|
|
15304
15334
|
return false;
|
|
15305
15335
|
}).call(this);
|
|
15306
15336
|
}
|
|
@@ -15322,9 +15352,11 @@ var __webpack_exports__ = {};
|
|
|
15322
15352
|
html_showElement(this.formElement);
|
|
15323
15353
|
}
|
|
15324
15354
|
constructor(container, formElement, options){
|
|
15325
|
-
super("Form", options), form_define_property(this, "container", void 0), form_define_property(this, "formElement", void 0), form_define_property(this, "validate", (event)=>{
|
|
15355
|
+
super("Form", options), form_define_property(this, "container", void 0), form_define_property(this, "formElement", void 0), form_define_property(this, "keyInput", void 0), form_define_property(this, "submitButton", void 0), form_define_property(this, "submitButtonFormAttribute", null), form_define_property(this, "generatedFormId", void 0), form_define_property(this, "isSubmitting", false), form_define_property(this, "FORM_FIELDS", {}), form_define_property(this, "validate", (event)=>{
|
|
15326
15356
|
this.container.validate(event);
|
|
15327
|
-
}), form_define_property(this, "
|
|
15357
|
+
}), form_define_property(this, "handleSubmit", (event)=>{
|
|
15358
|
+
if (!event.defaultPrevented) this.doTheSubmit(event);
|
|
15359
|
+
});
|
|
15328
15360
|
this.container = container;
|
|
15329
15361
|
this.formElement = formElement;
|
|
15330
15362
|
this.FORM_FIELDS = {
|
|
@@ -15340,6 +15372,7 @@ var __webpack_exports__ = {};
|
|
|
15340
15372
|
};
|
|
15341
15373
|
}
|
|
15342
15374
|
}
|
|
15375
|
+
form_define_property(Form, "nextFormId", 0);
|
|
15343
15376
|
const wrappers_form = Form;
|
|
15344
15377
|
function resource_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
15345
15378
|
try {
|
|
@@ -18025,7 +18058,7 @@ var __webpack_exports__ = {};
|
|
|
18025
18058
|
html_disableElement(radioButtonElement);
|
|
18026
18059
|
return radioButtonElement;
|
|
18027
18060
|
}
|
|
18028
|
-
makeButton(buttonClass, text, clickHandler, show, id, type, selector, disabled = true) {
|
|
18061
|
+
makeButton(buttonClass, text, clickHandler, show, id, type = "button", selector, disabled = true) {
|
|
18029
18062
|
let buttonElement;
|
|
18030
18063
|
if (id) buttonElement = document.querySelector(`#${id}`);
|
|
18031
18064
|
else if (selector) buttonElement = document.querySelector(selector);
|
|
@@ -18811,10 +18844,15 @@ var __webpack_exports__ = {};
|
|
|
18811
18844
|
var _this_facingMode;
|
|
18812
18845
|
null == (_this_facingMode = this.facingMode) || _this_facingMode.show();
|
|
18813
18846
|
});
|
|
18847
|
+
this.on("CAMERA_RECOVERING", ()=>{
|
|
18848
|
+
var _this_facingMode;
|
|
18849
|
+
null == (_this_facingMode = this.facingMode) || _this_facingMode.hide();
|
|
18850
|
+
});
|
|
18814
18851
|
this.on("RECORDING", ()=>{
|
|
18815
18852
|
this.startRecording();
|
|
18816
18853
|
});
|
|
18817
18854
|
this.on("RESUMING", ()=>{
|
|
18855
|
+
this.hidePause();
|
|
18818
18856
|
this.resumeRecording();
|
|
18819
18857
|
});
|
|
18820
18858
|
this.on("STOPPING", ()=>{
|
|
@@ -19458,6 +19496,32 @@ var __webpack_exports__ = {};
|
|
|
19458
19496
|
const esm = esm_src;
|
|
19459
19497
|
var is_power_of_two = __webpack_require__("dZ");
|
|
19460
19498
|
var is_power_of_two_default = /*#__PURE__*/ __webpack_require__.n(is_power_of_two);
|
|
19499
|
+
function AudioRecorder_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
19500
|
+
try {
|
|
19501
|
+
var info = gen[key](arg);
|
|
19502
|
+
var value = info.value;
|
|
19503
|
+
} catch (error) {
|
|
19504
|
+
reject(error);
|
|
19505
|
+
return;
|
|
19506
|
+
}
|
|
19507
|
+
if (info.done) resolve(value);
|
|
19508
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
19509
|
+
}
|
|
19510
|
+
function AudioRecorder_async_to_generator(fn) {
|
|
19511
|
+
return function() {
|
|
19512
|
+
var self1 = this, args = arguments;
|
|
19513
|
+
return new Promise(function(resolve, reject) {
|
|
19514
|
+
var gen = fn.apply(self1, args);
|
|
19515
|
+
function _next(value) {
|
|
19516
|
+
AudioRecorder_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
19517
|
+
}
|
|
19518
|
+
function _throw(err) {
|
|
19519
|
+
AudioRecorder_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
19520
|
+
}
|
|
19521
|
+
_next(void 0);
|
|
19522
|
+
});
|
|
19523
|
+
};
|
|
19524
|
+
}
|
|
19461
19525
|
function AudioRecorder_define_property(obj, key, value) {
|
|
19462
19526
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
19463
19527
|
value: value,
|
|
@@ -19488,9 +19552,20 @@ var __webpack_exports__ = {};
|
|
|
19488
19552
|
const float32Array = e.inputBuffer.getChannelData(0);
|
|
19489
19553
|
cb(new esm(float32Array));
|
|
19490
19554
|
}
|
|
19555
|
+
disconnect() {
|
|
19556
|
+
var _this_audioInput, _this_volume;
|
|
19557
|
+
if (this.scriptProcessor) {
|
|
19558
|
+
this.scriptProcessor.onaudioprocess = null;
|
|
19559
|
+
this.scriptProcessor.disconnect();
|
|
19560
|
+
}
|
|
19561
|
+
null == (_this_audioInput = this.audioInput) || _this_audioInput.disconnect();
|
|
19562
|
+
null == (_this_volume = this.volume) || _this_volume.disconnect();
|
|
19563
|
+
}
|
|
19491
19564
|
init(localMediaStream) {
|
|
19492
19565
|
this.options.logger.debug("AudioRecorder: init()");
|
|
19566
|
+
this.disconnect();
|
|
19493
19567
|
const volume = this.getAudioContext().createGain();
|
|
19568
|
+
this.volume = volume;
|
|
19494
19569
|
try {
|
|
19495
19570
|
this.audioInput = this.getAudioContext().createMediaStreamSource(localMediaStream);
|
|
19496
19571
|
} catch (exc) {
|
|
@@ -19522,10 +19597,15 @@ var __webpack_exports__ = {};
|
|
|
19522
19597
|
this.onAudioProcess(e, cb);
|
|
19523
19598
|
};
|
|
19524
19599
|
}
|
|
19600
|
+
resume() {
|
|
19601
|
+
return AudioRecorder_async_to_generator(function*() {
|
|
19602
|
+
const context = this.getAudioContext();
|
|
19603
|
+
if ("running" !== context.state) yield context.resume();
|
|
19604
|
+
}).call(this);
|
|
19605
|
+
}
|
|
19525
19606
|
stop() {
|
|
19526
19607
|
this.options.logger.debug("AudioRecorder: stop()");
|
|
19527
|
-
|
|
19528
|
-
if (this.audioInput) this.audioInput.disconnect();
|
|
19608
|
+
this.disconnect();
|
|
19529
19609
|
if (this.hasAudioContext()) this.getAudioContext().close().then(()=>{
|
|
19530
19610
|
this.options.logger.debug("AudioRecorder: audio context is closed");
|
|
19531
19611
|
this.vcAudioContext = void 0;
|
|
@@ -19544,6 +19624,7 @@ var __webpack_exports__ = {};
|
|
|
19544
19624
|
constructor(userMedia, options){
|
|
19545
19625
|
AudioRecorder_define_property(this, "scriptProcessor", void 0);
|
|
19546
19626
|
AudioRecorder_define_property(this, "audioInput", void 0);
|
|
19627
|
+
AudioRecorder_define_property(this, "volume", void 0);
|
|
19547
19628
|
AudioRecorder_define_property(this, "vcAudioContext", void 0);
|
|
19548
19629
|
AudioRecorder_define_property(this, "userMedia", void 0);
|
|
19549
19630
|
AudioRecorder_define_property(this, "options", void 0);
|
|
@@ -19567,6 +19648,32 @@ var __webpack_exports__ = {};
|
|
|
19567
19648
|
return isVirtual;
|
|
19568
19649
|
}
|
|
19569
19650
|
const util_isVirtualCamera = isVirtualCamera;
|
|
19651
|
+
function userMedia_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
19652
|
+
try {
|
|
19653
|
+
var info = gen[key](arg);
|
|
19654
|
+
var value = info.value;
|
|
19655
|
+
} catch (error) {
|
|
19656
|
+
reject(error);
|
|
19657
|
+
return;
|
|
19658
|
+
}
|
|
19659
|
+
if (info.done) resolve(value);
|
|
19660
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
19661
|
+
}
|
|
19662
|
+
function userMedia_async_to_generator(fn) {
|
|
19663
|
+
return function() {
|
|
19664
|
+
var self1 = this, args = arguments;
|
|
19665
|
+
return new Promise(function(resolve, reject) {
|
|
19666
|
+
var gen = fn.apply(self1, args);
|
|
19667
|
+
function _next(value) {
|
|
19668
|
+
userMedia_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
19669
|
+
}
|
|
19670
|
+
function _throw(err) {
|
|
19671
|
+
userMedia_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
19672
|
+
}
|
|
19673
|
+
_next(void 0);
|
|
19674
|
+
});
|
|
19675
|
+
};
|
|
19676
|
+
}
|
|
19570
19677
|
function userMedia_define_property(obj, key, value) {
|
|
19571
19678
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
19572
19679
|
value: value,
|
|
@@ -19603,6 +19710,20 @@ var __webpack_exports__ = {};
|
|
|
19603
19710
|
this.currentVisualStream = void 0;
|
|
19604
19711
|
}
|
|
19605
19712
|
}
|
|
19713
|
+
restorePlayback() {
|
|
19714
|
+
return userMedia_async_to_generator(function*() {
|
|
19715
|
+
var _this_audioRecorder;
|
|
19716
|
+
if (!this.rawVisualUserMedia) throw new Error("No camera preview is available.");
|
|
19717
|
+
yield this.rawVisualUserMedia.play();
|
|
19718
|
+
yield null == (_this_audioRecorder = this.audioRecorder) ? void 0 : _this_audioRecorder.resume();
|
|
19719
|
+
}).call(this);
|
|
19720
|
+
}
|
|
19721
|
+
hasLiveStream() {
|
|
19722
|
+
var _this_currentVisualStream, _this_currentVisualStream1, _this_currentVisualStream2;
|
|
19723
|
+
const videoReady = null == (_this_currentVisualStream = this.currentVisualStream) ? void 0 : _this_currentVisualStream.getVideoTracks().some((track)=>"live" === track.readyState && track.enabled && !track.muted);
|
|
19724
|
+
const audioReady = !isAudioEnabled(this.options) || (null == (_this_currentVisualStream1 = this.currentVisualStream) ? void 0 : _this_currentVisualStream1.getAudioTracks().some((track)=>"live" === track.readyState && track.enabled && !track.muted));
|
|
19725
|
+
return Boolean((null == (_this_currentVisualStream2 = this.currentVisualStream) ? void 0 : _this_currentVisualStream2.active) && videoReady && audioReady);
|
|
19726
|
+
}
|
|
19606
19727
|
hasEnded() {
|
|
19607
19728
|
var _this_rawVisualUserMedia, _this_currentVisualStream;
|
|
19608
19729
|
if (null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) ? void 0 : _this_rawVisualUserMedia.ended) return this.rawVisualUserMedia.ended;
|
|
@@ -19617,8 +19738,9 @@ var __webpack_exports__ = {};
|
|
|
19617
19738
|
this.options.logger.debug(`UserMedia: ... ${EVENT_ASCII} event ${eventType}: ${string_pretty(params)}`);
|
|
19618
19739
|
}
|
|
19619
19740
|
unloadRemainingEventListeners() {
|
|
19620
|
-
var _this_rawVisualUserMedia;
|
|
19741
|
+
var _this_clearInitializationListeners, _this, _this_rawVisualUserMedia;
|
|
19621
19742
|
this.options.logger.debug("UserMedia: unloadRemainingEventListeners()");
|
|
19743
|
+
null == (_this_clearInitializationListeners = (_this = this).clearInitializationListeners) || _this_clearInitializationListeners.call(_this);
|
|
19622
19744
|
mediaEvents.forEach((eventName)=>{
|
|
19623
19745
|
var _this_rawVisualUserMedia;
|
|
19624
19746
|
null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.removeEventListener(eventName, this.outputEvent);
|
|
@@ -19630,11 +19752,14 @@ var __webpack_exports__ = {};
|
|
|
19630
19752
|
this.removeListener("SENDING_FIRST_FRAME");
|
|
19631
19753
|
null == (_this_audioRecorder = this.audioRecorder) || _this_audioRecorder.record(audioCallback);
|
|
19632
19754
|
}
|
|
19633
|
-
init(localMediaStream, videoCallback, audioCallback, endedEarlyCallback,
|
|
19755
|
+
init(localMediaStream, videoCallback, audioCallback, endedEarlyCallback, params) {
|
|
19756
|
+
var _this_clearInitializationListeners, _this;
|
|
19757
|
+
null == (_this_clearInitializationListeners = (_this = this).clearInitializationListeners) || _this_clearInitializationListeners.call(_this);
|
|
19634
19758
|
this.stop(localMediaStream, {
|
|
19635
19759
|
aboutToInitialize: true,
|
|
19636
|
-
switchingFacingMode
|
|
19760
|
+
preserveRecordingState: Boolean((null == params ? void 0 : params.switchingFacingMode) || (null == params ? void 0 : params.recovering))
|
|
19637
19761
|
});
|
|
19762
|
+
const initializationId = ++this.initializationId;
|
|
19638
19763
|
this.onPlayReached = false;
|
|
19639
19764
|
this.onLoadedMetaDataReached = false;
|
|
19640
19765
|
this.playingPromiseReached = false;
|
|
@@ -19648,6 +19773,12 @@ var __webpack_exports__ = {};
|
|
|
19648
19773
|
null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.removeEventListener("play", onPlay);
|
|
19649
19774
|
null == (_this_rawVisualUserMedia1 = this.rawVisualUserMedia) || _this_rawVisualUserMedia1.removeEventListener("loadedmetadata", onLoadedMetaData);
|
|
19650
19775
|
};
|
|
19776
|
+
this.clearInitializationListeners = ()=>{
|
|
19777
|
+
var _this_rawVisualUserMedia, _this_rawVisualUserMedia1;
|
|
19778
|
+
null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.removeEventListener("play", onPlay);
|
|
19779
|
+
null == (_this_rawVisualUserMedia1 = this.rawVisualUserMedia) || _this_rawVisualUserMedia1.removeEventListener("loadedmetadata", onLoadedMetaData);
|
|
19780
|
+
this.clearInitializationListeners = void 0;
|
|
19781
|
+
};
|
|
19651
19782
|
const play = ()=>{
|
|
19652
19783
|
try {
|
|
19653
19784
|
var _this_rawVisualUserMedia, _this_rawVisualUserMedia1;
|
|
@@ -19655,12 +19786,14 @@ var __webpack_exports__ = {};
|
|
|
19655
19786
|
if (null == (_this_rawVisualUserMedia1 = this.rawVisualUserMedia) ? void 0 : _this_rawVisualUserMedia1.paused) {
|
|
19656
19787
|
this.options.logger.debug(`UserMedia: play(): media.readyState=${this.rawVisualUserMedia.readyState}, media.paused=${this.rawVisualUserMedia.paused}, media.ended=${this.rawVisualUserMedia.ended}, media.played=${string_pretty(this.rawVisualUserMedia.played)}`);
|
|
19657
19788
|
this.rawVisualUserMedia.play().then(()=>{
|
|
19789
|
+
if (initializationId !== this.initializationId) return;
|
|
19658
19790
|
if (!this.playingPromiseReached) {
|
|
19659
19791
|
this.options.logger.debug("UserMedia: play promise successful. Playing now.");
|
|
19660
19792
|
this.playingPromiseReached = true;
|
|
19661
19793
|
}
|
|
19662
19794
|
}).catch((exc)=>{
|
|
19663
|
-
if (
|
|
19795
|
+
if (initializationId !== this.initializationId) return;
|
|
19796
|
+
if (exc instanceof Error && !(null == params ? void 0 : params.recovering)) this.options.logger.warn(`Caught pending user media promise exception: ${exc.toString()}`);
|
|
19664
19797
|
else {
|
|
19665
19798
|
unloadAllEventListeners();
|
|
19666
19799
|
endedEarlyCallback(error_createError({
|
|
@@ -19682,16 +19815,30 @@ var __webpack_exports__ = {};
|
|
|
19682
19815
|
this.options.logger.debug(`UserMedia: fireCallbacks(readyState=${readyState}, onPlayReached=${this.onPlayReached}, onLoadedMetaDataReached=${this.onLoadedMetaDataReached})`);
|
|
19683
19816
|
if (this.onPlayReached && this.onLoadedMetaDataReached) if (this.audioRecorder) try {
|
|
19684
19817
|
this.audioRecorder.init(localMediaStream);
|
|
19685
|
-
|
|
19686
|
-
|
|
19687
|
-
|
|
19688
|
-
|
|
19818
|
+
const onAudioReady = ()=>{
|
|
19819
|
+
var _this_clearInitializationListeners, _this;
|
|
19820
|
+
if (initializationId !== this.initializationId || this.currentVisualStream !== localMediaStream) return;
|
|
19821
|
+
if (this.recording) this.audioRecord(audioCallback);
|
|
19822
|
+
else this.on("SENDING_FIRST_FRAME", ()=>{
|
|
19823
|
+
this.audioRecord(audioCallback);
|
|
19824
|
+
});
|
|
19825
|
+
null == (_this_clearInitializationListeners = (_this = this).clearInitializationListeners) || _this_clearInitializationListeners.call(_this);
|
|
19826
|
+
videoCallback();
|
|
19827
|
+
};
|
|
19828
|
+
if (null == params ? void 0 : params.recovering) this.audioRecorder.resume().then(onAudioReady).catch(endedEarlyCallback);
|
|
19829
|
+
else onAudioReady();
|
|
19689
19830
|
} catch (exc) {
|
|
19690
19831
|
unloadAllEventListeners();
|
|
19691
|
-
this.stop(
|
|
19832
|
+
this.stop(void 0, {
|
|
19833
|
+
preserveRecordingState: Boolean(null == params ? void 0 : params.recovering)
|
|
19834
|
+
});
|
|
19692
19835
|
endedEarlyCallback(exc);
|
|
19693
19836
|
}
|
|
19694
|
-
else
|
|
19837
|
+
else {
|
|
19838
|
+
var _this_clearInitializationListeners, _this;
|
|
19839
|
+
null == (_this_clearInitializationListeners = (_this = this).clearInitializationListeners) || _this_clearInitializationListeners.call(_this);
|
|
19840
|
+
videoCallback();
|
|
19841
|
+
}
|
|
19695
19842
|
};
|
|
19696
19843
|
const onPlay = ()=>{
|
|
19697
19844
|
try {
|
|
@@ -19764,9 +19911,8 @@ var __webpack_exports__ = {};
|
|
|
19764
19911
|
this.setVisualStream(localMediaStream);
|
|
19765
19912
|
play();
|
|
19766
19913
|
} catch (exc) {
|
|
19767
|
-
|
|
19768
|
-
|
|
19769
|
-
});
|
|
19914
|
+
unloadAllEventListeners();
|
|
19915
|
+
endedEarlyCallback(exc);
|
|
19770
19916
|
}
|
|
19771
19917
|
}
|
|
19772
19918
|
getVideoTrackLabel() {
|
|
@@ -19780,7 +19926,9 @@ var __webpack_exports__ = {};
|
|
|
19780
19926
|
try {
|
|
19781
19927
|
let chosenStream = visualStream;
|
|
19782
19928
|
if (!(null == params ? void 0 : params.aboutToInitialize)) {
|
|
19783
|
-
var _this_audioRecorder;
|
|
19929
|
+
var _this_clearInitializationListeners, _this, _this_audioRecorder;
|
|
19930
|
+
this.initializationId++;
|
|
19931
|
+
null == (_this_clearInitializationListeners = (_this = this).clearInitializationListeners) || _this_clearInitializationListeners.call(_this);
|
|
19784
19932
|
null != chosenStream || (chosenStream = this.currentVisualStream);
|
|
19785
19933
|
const tracks = null == chosenStream ? void 0 : chosenStream.getTracks();
|
|
19786
19934
|
if (tracks) tracks.forEach((track)=>{
|
|
@@ -19790,7 +19938,7 @@ var __webpack_exports__ = {};
|
|
|
19790
19938
|
null == (_this_audioRecorder = this.audioRecorder) || _this_audioRecorder.stop();
|
|
19791
19939
|
this.audioRecorder = void 0;
|
|
19792
19940
|
}
|
|
19793
|
-
if (!(null == params ? void 0 : params.
|
|
19941
|
+
if (!(null == params ? void 0 : params.preserveRecordingState)) this.paused = this.recording = false;
|
|
19794
19942
|
} catch (exc) {
|
|
19795
19943
|
this.emit("ERROR", {
|
|
19796
19944
|
exc
|
|
@@ -19878,7 +20026,7 @@ var __webpack_exports__ = {};
|
|
|
19878
20026
|
};
|
|
19879
20027
|
}
|
|
19880
20028
|
constructor(recorder, options){
|
|
19881
|
-
super("UserMedia", options), userMedia_define_property(this, "recorder", void 0), userMedia_define_property(this, "rawVisualUserMedia", void 0), userMedia_define_property(this, "paused", false), userMedia_define_property(this, "recording", false), userMedia_define_property(this, "audioRecorder", void 0), userMedia_define_property(this, "currentVisualStream", void 0), userMedia_define_property(this, "onPlayReached", false), userMedia_define_property(this, "onLoadedMetaDataReached", false), userMedia_define_property(this, "playingPromiseReached", false), userMedia_define_property(this, "videoTrackLabel", void 0), userMedia_define_property(this, "outputEvent", (e)=>{
|
|
20029
|
+
super("UserMedia", options), userMedia_define_property(this, "recorder", void 0), userMedia_define_property(this, "rawVisualUserMedia", void 0), userMedia_define_property(this, "paused", false), userMedia_define_property(this, "recording", false), userMedia_define_property(this, "audioRecorder", void 0), userMedia_define_property(this, "currentVisualStream", void 0), userMedia_define_property(this, "onPlayReached", false), userMedia_define_property(this, "onLoadedMetaDataReached", false), userMedia_define_property(this, "playingPromiseReached", false), userMedia_define_property(this, "videoTrackLabel", void 0), userMedia_define_property(this, "clearInitializationListeners", void 0), userMedia_define_property(this, "initializationId", 0), userMedia_define_property(this, "outputEvent", (e)=>{
|
|
19882
20030
|
var _this_rawVisualUserMedia, _this_rawVisualUserMedia1;
|
|
19883
20031
|
this.logEvent(e.type, {
|
|
19884
20032
|
readyState: null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) ? void 0 : _this_rawVisualUserMedia.readyState
|
|
@@ -20160,7 +20308,10 @@ var __webpack_exports__ = {};
|
|
|
20160
20308
|
this.pingInterval = void 0;
|
|
20161
20309
|
}
|
|
20162
20310
|
onAudioSample(audioSample) {
|
|
20163
|
-
|
|
20311
|
+
var _this_userMedia;
|
|
20312
|
+
if (this.recordingTransportFailed || this.cameraRecovery) return;
|
|
20313
|
+
const sampleRate = null == (_this_userMedia = this.userMedia) ? void 0 : _this_userMedia.getAudioSampleRate();
|
|
20314
|
+
if (sampleRate && sampleRate > 0) null != this.recordingAudioSampleRate || (this.recordingAudioSampleRate = sampleRate);
|
|
20164
20315
|
this.samplesCount++;
|
|
20165
20316
|
this.mediaTransmissionStarted = true;
|
|
20166
20317
|
const audioBuffer = audioSample.toBuffer();
|
|
@@ -20173,19 +20324,27 @@ var __webpack_exports__ = {};
|
|
|
20173
20324
|
try {
|
|
20174
20325
|
this.options.logger.debug(`Recorder: onUserMediaReady(${params ? string_pretty(params) : ""})`);
|
|
20175
20326
|
const switchingFacingMode = null == params ? void 0 : params.switchingFacingMode;
|
|
20327
|
+
if (null == params ? void 0 : params.recovering) {
|
|
20328
|
+
var _this_userMedia;
|
|
20329
|
+
if (!(null == (_this_userMedia = this.userMedia) ? void 0 : _this_userMedia.hasLiveStream())) return void this.failCameraRecovery(new Error("The restored camera has no live tracks."));
|
|
20330
|
+
if (void 0 !== this.recordingAudioSampleRate && this.userMedia.getAudioSampleRate() !== this.recordingAudioSampleRate) return void this.failCameraRecovery(new Error("The audio sample rate changed during recovery."));
|
|
20331
|
+
}
|
|
20176
20332
|
this.userMediaLoading = this.blocking = this.unloaded = this.submitting = false;
|
|
20177
20333
|
this.userMediaLoaded = true;
|
|
20178
20334
|
this.clearUserMediaTimeout();
|
|
20179
|
-
if (!switchingFacingMode) this.loop = this.createLoop();
|
|
20335
|
+
if (!switchingFacingMode && !(null == params ? void 0 : params.recovering)) this.loop = this.createLoop();
|
|
20180
20336
|
this.show();
|
|
20181
20337
|
if (null == params ? void 0 : params.recordWhenReady) this.record();
|
|
20182
20338
|
this.emit("USER_MEDIA_READY", {
|
|
20183
20339
|
switchingFacingMode: null == params ? void 0 : params.switchingFacingMode,
|
|
20340
|
+
recovering: null == params ? void 0 : params.recovering,
|
|
20184
20341
|
paused: this.isPaused(),
|
|
20185
20342
|
recordWhenReady: null == params ? void 0 : params.recordWhenReady
|
|
20186
20343
|
});
|
|
20344
|
+
if (null == params ? void 0 : params.recovering) this.finishCameraRecovery(true);
|
|
20187
20345
|
} catch (exc) {
|
|
20188
|
-
this.
|
|
20346
|
+
if (null == params ? void 0 : params.recovering) this.failCameraRecovery(exc);
|
|
20347
|
+
else this.emit("ERROR", {
|
|
20189
20348
|
exc
|
|
20190
20349
|
});
|
|
20191
20350
|
}
|
|
@@ -20560,6 +20719,7 @@ var __webpack_exports__ = {};
|
|
|
20560
20719
|
}
|
|
20561
20720
|
userMediaErrorCallback(err, usedConstraints) {
|
|
20562
20721
|
var _this_userMedia;
|
|
20722
|
+
if (this.cameraRecovery) return void this.failCameraRecovery(err);
|
|
20563
20723
|
if (this.unloaded) return void this.options.logger.debug(`Recorder: already unloaded. Not going to throw error ${string_pretty(err)}`);
|
|
20564
20724
|
this.userMediaLoading = false;
|
|
20565
20725
|
this.clearUserMediaTimeout();
|
|
@@ -20591,7 +20751,7 @@ var __webpack_exports__ = {};
|
|
|
20591
20751
|
});
|
|
20592
20752
|
}
|
|
20593
20753
|
}
|
|
20594
|
-
getUserMediaCallback(localStream, params) {
|
|
20754
|
+
getUserMediaCallback(localStream, params, requestId = this.mediaRequestId) {
|
|
20595
20755
|
if (!this.userMedia) {
|
|
20596
20756
|
localStream.getTracks().forEach((track)=>{
|
|
20597
20757
|
track.stop();
|
|
@@ -20604,20 +20764,20 @@ var __webpack_exports__ = {};
|
|
|
20604
20764
|
this.options.logger.debug(`Recorder: getUserMediaCallback(${params ? string_pretty(params) : ""})`);
|
|
20605
20765
|
if (this.showUserMedia()) try {
|
|
20606
20766
|
this.userMedia.init(localStream, ()=>{
|
|
20607
|
-
if (!this.unloaded) this.onUserMediaReady(params);
|
|
20767
|
+
if (!this.unloaded && requestId === this.mediaRequestId) this.onUserMediaReady(params);
|
|
20608
20768
|
}, this.onAudioSample.bind(this), (err)=>{
|
|
20609
|
-
if (!this.unloaded) this.userMediaErrorCallback(err, {
|
|
20769
|
+
if (!this.unloaded && requestId === this.mediaRequestId) this.userMediaErrorCallback(err, {
|
|
20610
20770
|
audio: isAudioEnabled(this.options)
|
|
20611
20771
|
});
|
|
20612
|
-
},
|
|
20772
|
+
}, params);
|
|
20613
20773
|
} catch (exc) {
|
|
20614
20774
|
localStream.getTracks().forEach((track)=>{
|
|
20615
20775
|
track.stop();
|
|
20616
20776
|
});
|
|
20617
20777
|
this.userMediaLoading = false;
|
|
20618
20778
|
this.clearUserMediaTimeout();
|
|
20619
|
-
this.
|
|
20620
|
-
|
|
20779
|
+
this.userMediaErrorCallback(exc, {
|
|
20780
|
+
audio: isAudioEnabled(this.options)
|
|
20621
20781
|
});
|
|
20622
20782
|
}
|
|
20623
20783
|
else {
|
|
@@ -20626,12 +20786,14 @@ var __webpack_exports__ = {};
|
|
|
20626
20786
|
});
|
|
20627
20787
|
this.userMediaLoading = false;
|
|
20628
20788
|
this.clearUserMediaTimeout();
|
|
20789
|
+
this.cancelCameraRecovery();
|
|
20629
20790
|
}
|
|
20630
20791
|
}
|
|
20631
20792
|
loadGenuineUserMedia(params) {
|
|
20632
20793
|
this.options.logger.debug(`Recorder: loadGenuineUserMedia(${params ? string_pretty(params) : ""})`);
|
|
20633
20794
|
this.emit("ASKING_WEBCAM_PERMISSION");
|
|
20634
20795
|
this.userMediaLoading = true;
|
|
20796
|
+
const requestId = ++this.mediaRequestId;
|
|
20635
20797
|
const constraints = {
|
|
20636
20798
|
video: {
|
|
20637
20799
|
frameRate: {
|
|
@@ -20645,18 +20807,18 @@ var __webpack_exports__ = {};
|
|
|
20645
20807
|
this.options.logger.debug(string_summarize("Recorder: available webcam constraints are:", navigator.mediaDevices.getSupportedConstraints()));
|
|
20646
20808
|
const streamPromise = navigator.mediaDevices.getUserMedia(constraints);
|
|
20647
20809
|
streamPromise.then((localStream)=>{
|
|
20648
|
-
if (this.unloaded) return void localStream.getTracks().forEach((track)=>{
|
|
20810
|
+
if (this.unloaded || requestId !== this.mediaRequestId) return void localStream.getTracks().forEach((track)=>{
|
|
20649
20811
|
track.stop();
|
|
20650
20812
|
});
|
|
20651
|
-
this.getUserMediaCallback(localStream, params);
|
|
20813
|
+
this.getUserMediaCallback(localStream, params, requestId);
|
|
20652
20814
|
}).catch((reason)=>{
|
|
20653
|
-
if (!this.unloaded) this.userMediaErrorCallback(reason, constraints);
|
|
20815
|
+
if (!this.unloaded && requestId === this.mediaRequestId) this.userMediaErrorCallback(reason, constraints);
|
|
20654
20816
|
});
|
|
20655
20817
|
}
|
|
20656
20818
|
configureVideoConstraints(constraints, params) {
|
|
20657
20819
|
const videoConstraints = "object" == typeof constraints.video ? constraints.video : void 0;
|
|
20658
20820
|
if (!videoConstraints) return;
|
|
20659
|
-
if (null == params ? void 0 : params.switchingFacingMode) videoConstraints.facingMode = params.switchingFacingMode;
|
|
20821
|
+
if ((null == params ? void 0 : params.switchingFacingMode) || (null == params ? void 0 : params.recovering)) videoConstraints.facingMode = params.switchingFacingMode || this.facingMode;
|
|
20660
20822
|
if (this.options.video.width) videoConstraints.width = {
|
|
20661
20823
|
ideal: this.options.video.width
|
|
20662
20824
|
};
|
|
@@ -20684,8 +20846,8 @@ var __webpack_exports__ = {};
|
|
|
20684
20846
|
if (!this.userMediaLoaded) {
|
|
20685
20847
|
this.userMediaLoading = false;
|
|
20686
20848
|
const err = util_getBrowser(this.options).getNoAccessIssue();
|
|
20687
|
-
this.
|
|
20688
|
-
|
|
20849
|
+
this.userMediaErrorCallback(err, {
|
|
20850
|
+
audio: isAudioEnabled(this.options)
|
|
20689
20851
|
});
|
|
20690
20852
|
}
|
|
20691
20853
|
}, this.options.timeouts.userMedia);
|
|
@@ -20695,6 +20857,7 @@ var __webpack_exports__ = {};
|
|
|
20695
20857
|
this.clearUserMediaTimeout();
|
|
20696
20858
|
this.options.logger.debug("Recorder: failed to load genuine user media");
|
|
20697
20859
|
this.userMediaLoading = false;
|
|
20860
|
+
if (this.cameraRecovery) return void this.failCameraRecovery(exc);
|
|
20698
20861
|
const errorListeners = this.getListeners("ERROR");
|
|
20699
20862
|
if (null == errorListeners ? void 0 : errorListeners.length) this.emit("ERROR", {
|
|
20700
20863
|
exc
|
|
@@ -20822,11 +20985,13 @@ var __webpack_exports__ = {};
|
|
|
20822
20985
|
return this.recordingStats;
|
|
20823
20986
|
}
|
|
20824
20987
|
getAudioSampleRate() {
|
|
20988
|
+
var _this_recordingAudioSampleRate;
|
|
20825
20989
|
var _this_userMedia;
|
|
20826
|
-
return null == (_this_userMedia = this.userMedia) ? void 0 : _this_userMedia.getAudioSampleRate();
|
|
20990
|
+
return null != (_this_recordingAudioSampleRate = this.recordingAudioSampleRate) ? _this_recordingAudioSampleRate : null == (_this_userMedia = this.userMedia) ? void 0 : _this_userMedia.getAudioSampleRate();
|
|
20827
20991
|
}
|
|
20828
20992
|
stop(params) {
|
|
20829
20993
|
var _this_loop;
|
|
20994
|
+
this.cancelCameraRecovery();
|
|
20830
20995
|
if (!this.userMedia) throw new Error("No user media defined, unable to stop");
|
|
20831
20996
|
this.options.logger.debug(`Recorder: stop(${params ? string_pretty(params) : ""})`);
|
|
20832
20997
|
this.recordingActive = false;
|
|
@@ -20851,8 +21016,9 @@ var __webpack_exports__ = {};
|
|
|
20851
21016
|
};
|
|
20852
21017
|
if (this.userMedia) this.recordingStats.videoTrackLabel = this.userMedia.getVideoTrackLabel();
|
|
20853
21018
|
if (isAudioEnabled(this.options) && this.userMedia) {
|
|
21019
|
+
var _this_recordingAudioSampleRate;
|
|
20854
21020
|
this.recordingStats.samplesCount = this.samplesCount;
|
|
20855
|
-
this.recordingStats.sampleRate = this.userMedia.getAudioSampleRate();
|
|
21021
|
+
this.recordingStats.sampleRate = null != (_this_recordingAudioSampleRate = this.recordingAudioSampleRate) ? _this_recordingAudioSampleRate : this.userMedia.getAudioSampleRate();
|
|
20856
21022
|
}
|
|
20857
21023
|
this.writeCommand("stop", this.recordingStats, ()=>{
|
|
20858
21024
|
this.emit("STOPPED", {
|
|
@@ -20908,6 +21074,7 @@ var __webpack_exports__ = {};
|
|
|
20908
21074
|
this.built = this.connecting = this.connected = false;
|
|
20909
21075
|
}
|
|
20910
21076
|
reset() {
|
|
21077
|
+
this.cancelCameraRecovery();
|
|
20911
21078
|
if (!this.unloaded) {
|
|
20912
21079
|
var _this_userMedia;
|
|
20913
21080
|
this.options.logger.debug("Recorder: reset()");
|
|
@@ -20937,8 +21104,72 @@ var __webpack_exports__ = {};
|
|
|
20937
21104
|
var _this_userMedia;
|
|
20938
21105
|
return null == (_this_userMedia = this.userMedia) ? void 0 : _this_userMedia.isReady();
|
|
20939
21106
|
}
|
|
21107
|
+
finishCameraRecovery(restored) {
|
|
21108
|
+
this.clearUserMediaTimeout();
|
|
21109
|
+
const resolve = this.resolveCameraRecovery;
|
|
21110
|
+
const resumeRequested = restored && this.resumeAfterCameraRecovery;
|
|
21111
|
+
this.cameraRecovery = void 0;
|
|
21112
|
+
this.resolveCameraRecovery = void 0;
|
|
21113
|
+
this.resumeAfterCameraRecovery = false;
|
|
21114
|
+
null == resolve || resolve(restored);
|
|
21115
|
+
if (resumeRequested && this.isPaused()) this.resume();
|
|
21116
|
+
}
|
|
21117
|
+
cancelCameraRecovery() {
|
|
21118
|
+
var _this_userMedia;
|
|
21119
|
+
if (!this.cameraRecovery) return;
|
|
21120
|
+
this.mediaRequestId++;
|
|
21121
|
+
this.userMediaLoading = false;
|
|
21122
|
+
this.userMediaLoaded = false;
|
|
21123
|
+
this.clearUserMediaTimeout();
|
|
21124
|
+
null == (_this_userMedia = this.userMedia) || _this_userMedia.stop(void 0, {
|
|
21125
|
+
preserveRecordingState: true
|
|
21126
|
+
});
|
|
21127
|
+
this.finishCameraRecovery(false);
|
|
21128
|
+
}
|
|
21129
|
+
failCameraRecovery(exc) {
|
|
21130
|
+
this.cancelCameraRecovery();
|
|
21131
|
+
const err = error_createError({
|
|
21132
|
+
message: "Camera recovery failed",
|
|
21133
|
+
explanation: "Your recording is still paused. Check camera permissions, then try Resume again or stop to keep the recorded part.",
|
|
21134
|
+
exc,
|
|
21135
|
+
options: this.options
|
|
21136
|
+
});
|
|
21137
|
+
this.emit("CAMERA_RECOVERY_FAILED", {
|
|
21138
|
+
err
|
|
21139
|
+
});
|
|
21140
|
+
}
|
|
21141
|
+
recoverCamera() {
|
|
21142
|
+
if (this.cameraRecovery) return this.cameraRecovery;
|
|
21143
|
+
if (!this.built || this.unloaded || !this.userMedia || this.userMediaLoading || this.submitting || this.key || void 0 !== this.stopTimeout || this.recordingTransportFailed) return Promise.resolve(false);
|
|
21144
|
+
const liveStream = this.userMedia.hasLiveStream();
|
|
21145
|
+
if (liveStream && this.isRecording()) return Promise.resolve(true);
|
|
21146
|
+
if (!liveStream && this.recordingActive && !this.isPaused()) this.pause();
|
|
21147
|
+
const recovery = new Promise((resolve)=>{
|
|
21148
|
+
this.resolveCameraRecovery = resolve;
|
|
21149
|
+
});
|
|
21150
|
+
this.cameraRecovery = recovery;
|
|
21151
|
+
this.emit("CAMERA_RECOVERING");
|
|
21152
|
+
if (liveStream) {
|
|
21153
|
+
this.userMediaTimeout = window.setTimeout(()=>{
|
|
21154
|
+
this.failCameraRecovery(new Error("Camera playback recovery timed out."));
|
|
21155
|
+
}, this.options.timeouts.userMedia);
|
|
21156
|
+
this.userMedia.restorePlayback().then(()=>{
|
|
21157
|
+
if (this.cameraRecovery === recovery) this.finishCameraRecovery(true);
|
|
21158
|
+
}).catch((exc)=>{
|
|
21159
|
+
if (this.cameraRecovery === recovery) this.failCameraRecovery(exc);
|
|
21160
|
+
});
|
|
21161
|
+
} else {
|
|
21162
|
+
this.userMediaLoaded = false;
|
|
21163
|
+
this.loadUserMedia({
|
|
21164
|
+
recovering: true
|
|
21165
|
+
});
|
|
21166
|
+
}
|
|
21167
|
+
return recovery;
|
|
21168
|
+
}
|
|
20940
21169
|
pause(params) {
|
|
20941
21170
|
var _this_userMedia;
|
|
21171
|
+
this.cancelCameraRecovery();
|
|
21172
|
+
this.resumeAfterDrain = false;
|
|
20942
21173
|
if (params) this.options.logger.debug(`pause() at frame ${this.framesCount} with ${string_pretty(params)}`);
|
|
20943
21174
|
else this.options.logger.debug(`pause() at frame ${this.framesCount}`);
|
|
20944
21175
|
null == (_this_userMedia = this.userMedia) || _this_userMedia.pause();
|
|
@@ -20948,10 +21179,15 @@ var __webpack_exports__ = {};
|
|
|
20948
21179
|
}
|
|
20949
21180
|
resume() {
|
|
20950
21181
|
var _this_userMedia;
|
|
21182
|
+
if (this.cameraRecovery || !(null == (_this_userMedia = this.userMedia) ? void 0 : _this_userMedia.hasLiveStream())) {
|
|
21183
|
+
this.recoverCamera();
|
|
21184
|
+
this.resumeAfterCameraRecovery = Boolean(this.cameraRecovery);
|
|
21185
|
+
return;
|
|
21186
|
+
}
|
|
20951
21187
|
this.options.logger.debug(`Recorder: resume() with frame ${this.framesCount}`);
|
|
20952
21188
|
this.stopPings();
|
|
20953
21189
|
this.emit("RESUMING");
|
|
20954
|
-
|
|
21190
|
+
this.userMedia.resume();
|
|
20955
21191
|
if (this.streamBackpressured) this.resumeAfterDrain = true;
|
|
20956
21192
|
else this.loop.start();
|
|
20957
21193
|
}
|
|
@@ -21007,7 +21243,7 @@ var __webpack_exports__ = {};
|
|
|
21007
21243
|
return newLoop;
|
|
21008
21244
|
}
|
|
21009
21245
|
record() {
|
|
21010
|
-
if (this.unloaded) return;
|
|
21246
|
+
if (this.unloaded || this.cameraRecovery) return;
|
|
21011
21247
|
if (!this.connected) {
|
|
21012
21248
|
this.options.logger.debug("Recorder: reconnecting before recording …");
|
|
21013
21249
|
this.initSocket(()=>{
|
|
@@ -21080,6 +21316,7 @@ var __webpack_exports__ = {};
|
|
|
21080
21316
|
this.recordingActive = true;
|
|
21081
21317
|
this.recordingTransportFailed = false;
|
|
21082
21318
|
this.mediaTransmissionStarted = false;
|
|
21319
|
+
this.recordingAudioSampleRate = void 0;
|
|
21083
21320
|
this.userMedia.record();
|
|
21084
21321
|
this.emit("RECORDING", {
|
|
21085
21322
|
framesCount: this.framesCount
|
|
@@ -21141,7 +21378,7 @@ var __webpack_exports__ = {};
|
|
|
21141
21378
|
}
|
|
21142
21379
|
}
|
|
21143
21380
|
switchFacingMode() {
|
|
21144
|
-
if (!util_getBrowser(this.options).isMobile()) return;
|
|
21381
|
+
if (this.cameraRecovery || !util_getBrowser(this.options).isMobile()) return;
|
|
21145
21382
|
if ("user" === this.facingMode) this.facingMode = "environment";
|
|
21146
21383
|
else if ("environment" === this.facingMode) this.facingMode = "user";
|
|
21147
21384
|
else this.options.logger.warn(`Recorder: unsupported facing mode ${string_pretty(this.facingMode)}`);
|
|
@@ -21152,12 +21389,14 @@ var __webpack_exports__ = {};
|
|
|
21152
21389
|
initEvents() {
|
|
21153
21390
|
this.options.logger.debug("Recorder: initEvents()");
|
|
21154
21391
|
this.on("SUBMITTING", ()=>{
|
|
21392
|
+
this.cancelCameraRecovery();
|
|
21155
21393
|
this.submitting = true;
|
|
21156
21394
|
});
|
|
21157
21395
|
this.on("SUBMITTED", ()=>{
|
|
21158
21396
|
this.submitting = false;
|
|
21159
21397
|
});
|
|
21160
21398
|
this.on("BLOCKING", ()=>{
|
|
21399
|
+
this.cancelCameraRecovery();
|
|
21161
21400
|
this.blocking = true;
|
|
21162
21401
|
this.clearUserMediaTimeout();
|
|
21163
21402
|
});
|
|
@@ -21333,7 +21572,7 @@ var __webpack_exports__ = {};
|
|
|
21333
21572
|
return this.userMediaLoaded;
|
|
21334
21573
|
}
|
|
21335
21574
|
constructor(visuals, replay, options){
|
|
21336
|
-
super("Recorder", options), recorder_define_property(this, "visuals", void 0), recorder_define_property(this, "replay", void 0), recorder_define_property(this, "pendingWrites", new boundedWriteQueue()), recorder_define_property(this, "loop", void 0), recorder_define_property(this, "originalAnimationFrameObject", void 0), recorder_define_property(this, "samplesCount", 0), recorder_define_property(this, "framesCount", 0), recorder_define_property(this, "recordingStats", void 0), recorder_define_property(this, "confirmedFrameNumber", 0), recorder_define_property(this, "confirmedSampleNumber", 0), recorder_define_property(this, "recorderElement", void 0), recorder_define_property(this, "userMedia", void 0), recorder_define_property(this, "userMediaTimeout", void 0), recorder_define_property(this, "retryTimeout", void 0), recorder_define_property(this, "reconnectTimeout", void 0), recorder_define_property(this, "connectionTimeout", void 0), recorder_define_property(this, "backpressureTimeout", void 0), recorder_define_property(this, "stopTimeout", void 0), recorder_define_property(this, "frameProgress", void 0), recorder_define_property(this, "sampleProgress", void 0), recorder_define_property(this, "canvas", void 0), recorder_define_property(this, "recordingDimensions", void 0), recorder_define_property(this, "ctx", void 0), recorder_define_property(this, "userMediaLoaded", void 0), recorder_define_property(this, "userMediaLoading", false), recorder_define_property(this, "submitting", false), recorder_define_property(this, "unloaded", void 0), recorder_define_property(this, "stopTime", void 0), recorder_define_property(this, "stream", void 0), recorder_define_property(this, "streamBackpressured", false), recorder_define_property(this, "resumeAfterDrain", false), recorder_define_property(this, "mediaTransmissionStarted", false), recorder_define_property(this, "recordingActive", false), recorder_define_property(this, "recordingTransportFailed", false), recorder_define_property(this, "connecting", false), recorder_define_property(this, "connected", false), recorder_define_property(this, "connectionFailed", false), recorder_define_property(this, "reconnecting", false), recorder_define_property(this, "reconnectAttempts", 0), recorder_define_property(this, "blocking", false), recorder_define_property(this, "built", false), recorder_define_property(this, "key", void 0), recorder_define_property(this, "waitingTime", void 0), recorder_define_property(this, "connectingStartedAt", void 0), recorder_define_property(this, "lastCloseEvent", void 0), recorder_define_property(this, "lastSocketError", void 0), recorder_define_property(this, "pingInterval", void 0), recorder_define_property(this, "frame", void 0), recorder_define_property(this, "recordingBuffer", void 0), recorder_define_property(this, "facingMode", void 0);
|
|
21575
|
+
super("Recorder", options), recorder_define_property(this, "visuals", void 0), recorder_define_property(this, "replay", void 0), recorder_define_property(this, "pendingWrites", new boundedWriteQueue()), recorder_define_property(this, "loop", void 0), recorder_define_property(this, "originalAnimationFrameObject", void 0), recorder_define_property(this, "samplesCount", 0), recorder_define_property(this, "framesCount", 0), recorder_define_property(this, "recordingAudioSampleRate", void 0), recorder_define_property(this, "recordingStats", void 0), recorder_define_property(this, "confirmedFrameNumber", 0), recorder_define_property(this, "confirmedSampleNumber", 0), recorder_define_property(this, "recorderElement", void 0), recorder_define_property(this, "userMedia", void 0), recorder_define_property(this, "userMediaTimeout", void 0), recorder_define_property(this, "retryTimeout", void 0), recorder_define_property(this, "reconnectTimeout", void 0), recorder_define_property(this, "connectionTimeout", void 0), recorder_define_property(this, "backpressureTimeout", void 0), recorder_define_property(this, "stopTimeout", void 0), recorder_define_property(this, "frameProgress", void 0), recorder_define_property(this, "sampleProgress", void 0), recorder_define_property(this, "canvas", void 0), recorder_define_property(this, "recordingDimensions", void 0), recorder_define_property(this, "ctx", void 0), recorder_define_property(this, "userMediaLoaded", void 0), recorder_define_property(this, "userMediaLoading", false), recorder_define_property(this, "mediaRequestId", 0), recorder_define_property(this, "cameraRecovery", void 0), recorder_define_property(this, "resolveCameraRecovery", void 0), recorder_define_property(this, "resumeAfterCameraRecovery", false), recorder_define_property(this, "submitting", false), recorder_define_property(this, "unloaded", void 0), recorder_define_property(this, "stopTime", void 0), recorder_define_property(this, "stream", void 0), recorder_define_property(this, "streamBackpressured", false), recorder_define_property(this, "resumeAfterDrain", false), recorder_define_property(this, "mediaTransmissionStarted", false), recorder_define_property(this, "recordingActive", false), recorder_define_property(this, "recordingTransportFailed", false), recorder_define_property(this, "connecting", false), recorder_define_property(this, "connected", false), recorder_define_property(this, "connectionFailed", false), recorder_define_property(this, "reconnecting", false), recorder_define_property(this, "reconnectAttempts", 0), recorder_define_property(this, "blocking", false), recorder_define_property(this, "built", false), recorder_define_property(this, "key", void 0), recorder_define_property(this, "waitingTime", void 0), recorder_define_property(this, "connectingStartedAt", void 0), recorder_define_property(this, "lastCloseEvent", void 0), recorder_define_property(this, "lastSocketError", void 0), recorder_define_property(this, "pingInterval", void 0), recorder_define_property(this, "frame", void 0), recorder_define_property(this, "recordingBuffer", void 0), recorder_define_property(this, "facingMode", void 0);
|
|
21337
21576
|
this.visuals = visuals;
|
|
21338
21577
|
this.replay = replay;
|
|
21339
21578
|
this.facingMode = options.video.facingMode;
|
|
@@ -21645,6 +21884,17 @@ var __webpack_exports__ = {};
|
|
|
21645
21884
|
this.endWaiting();
|
|
21646
21885
|
this.container.enableForm(false);
|
|
21647
21886
|
});
|
|
21887
|
+
this.on("CAMERA_RECOVERING", ()=>{
|
|
21888
|
+
this.clearCameraRecoveryNotice();
|
|
21889
|
+
});
|
|
21890
|
+
this.on("CAMERA_RECOVERY_FAILED", ({ err })=>{
|
|
21891
|
+
this.cameraRecoveryFailed = true;
|
|
21892
|
+
this.options.logger.warn(err);
|
|
21893
|
+
if (this.options.displayErrors) this.notifier.notify(err.message, err.explanation, {
|
|
21894
|
+
problem: true
|
|
21895
|
+
});
|
|
21896
|
+
this.endWaiting();
|
|
21897
|
+
});
|
|
21648
21898
|
this.on("PREVIEW", ()=>{
|
|
21649
21899
|
this.endWaiting();
|
|
21650
21900
|
});
|
|
@@ -21725,6 +21975,7 @@ var __webpack_exports__ = {};
|
|
|
21725
21975
|
child.remove();
|
|
21726
21976
|
}
|
|
21727
21977
|
reset() {
|
|
21978
|
+
this.clearCameraRecoveryNotice();
|
|
21728
21979
|
this.endWaiting();
|
|
21729
21980
|
this.recorder.reset();
|
|
21730
21981
|
}
|
|
@@ -21735,11 +21986,13 @@ var __webpack_exports__ = {};
|
|
|
21735
21986
|
this.container.endWaiting();
|
|
21736
21987
|
}
|
|
21737
21988
|
stop(params) {
|
|
21989
|
+
this.clearCameraRecoveryNotice();
|
|
21738
21990
|
this.recorder.stop(params);
|
|
21739
21991
|
this.recorderInsides.hidePause();
|
|
21740
21992
|
}
|
|
21741
21993
|
back(keepHidden = false, cb) {
|
|
21742
21994
|
this.options.logger.debug(`Visuals: back(keepHidden = ${keepHidden})`);
|
|
21995
|
+
this.cameraRecoveryFailed = false;
|
|
21743
21996
|
this.replay.hide();
|
|
21744
21997
|
this.notifier.hide();
|
|
21745
21998
|
if (keepHidden) {
|
|
@@ -21761,6 +22014,7 @@ var __webpack_exports__ = {};
|
|
|
21761
22014
|
if (!this.built) return;
|
|
21762
22015
|
const e = null == params ? void 0 : params.e;
|
|
21763
22016
|
this.options.logger.debug(`Visuals: unload(${e ? string_pretty(e) : ""})`);
|
|
22017
|
+
this.cameraRecoveryFailed = false;
|
|
21764
22018
|
this.recorder.unload(params);
|
|
21765
22019
|
this.recorderInsides.unload();
|
|
21766
22020
|
this.replay.unload(params);
|
|
@@ -21774,13 +22028,31 @@ var __webpack_exports__ = {};
|
|
|
21774
22028
|
this.recorder.pause(params);
|
|
21775
22029
|
this.recorderInsides.showPause();
|
|
21776
22030
|
}
|
|
22031
|
+
clearCameraRecoveryNotice() {
|
|
22032
|
+
if (this.cameraRecoveryFailed) {
|
|
22033
|
+
this.notifier.hide();
|
|
22034
|
+
this.recorder.show();
|
|
22035
|
+
this.cameraRecoveryFailed = false;
|
|
22036
|
+
}
|
|
22037
|
+
}
|
|
22038
|
+
recoverCamera() {
|
|
22039
|
+
if (this.replay.isShown() || this.isNotifying() && !this.cameraRecoveryFailed) return Promise.resolve(false);
|
|
22040
|
+
this.clearCameraRecoveryNotice();
|
|
22041
|
+
return this.recorder.recoverCamera();
|
|
22042
|
+
}
|
|
21777
22043
|
resume() {
|
|
21778
|
-
|
|
21779
|
-
|
|
21780
|
-
|
|
22044
|
+
this.clearCameraRecoveryNotice();
|
|
22045
|
+
if (this.recorderInsides.isCountingDown()) {
|
|
22046
|
+
this.recorderInsides.resumeCountdown();
|
|
22047
|
+
this.recorderInsides.hidePause();
|
|
22048
|
+
} else {
|
|
22049
|
+
this.recorder.resume();
|
|
22050
|
+
if (!this.recorder.isPaused()) this.recorderInsides.hidePause();
|
|
22051
|
+
}
|
|
21781
22052
|
}
|
|
21782
22053
|
pauseOrResume() {
|
|
21783
|
-
if (this.
|
|
22054
|
+
if (this.cameraRecoveryFailed && this.recorder.isPaused()) this.resume();
|
|
22055
|
+
else if (this.isRecordable()) {
|
|
21784
22056
|
if (this.isRecording()) this.pause();
|
|
21785
22057
|
else if (this.recorder.isPaused()) this.resume();
|
|
21786
22058
|
else if (this.recorder.isReady()) this.recorder.record();
|
|
@@ -21903,7 +22175,7 @@ var __webpack_exports__ = {};
|
|
|
21903
22175
|
return this.visualsElement;
|
|
21904
22176
|
}
|
|
21905
22177
|
constructor(container, options){
|
|
21906
|
-
super("Visuals", options), visuals_define_property(this, "container", void 0), visuals_define_property(this, "replay", void 0), visuals_define_property(this, "recorder", void 0), visuals_define_property(this, "recorderInsides", void 0), visuals_define_property(this, "notifier", void 0), visuals_define_property(this, "visualsElement", void 0), visuals_define_property(this, "built", false);
|
|
22178
|
+
super("Visuals", options), visuals_define_property(this, "container", void 0), visuals_define_property(this, "replay", void 0), visuals_define_property(this, "recorder", void 0), visuals_define_property(this, "recorderInsides", void 0), visuals_define_property(this, "notifier", void 0), visuals_define_property(this, "visualsElement", void 0), visuals_define_property(this, "built", false), visuals_define_property(this, "cameraRecoveryFailed", false);
|
|
21907
22179
|
this.container = container;
|
|
21908
22180
|
this.replay = new visuals_replay(this, options);
|
|
21909
22181
|
this.recorder = new visuals_recorder(this, this.replay, options);
|
|
@@ -22047,10 +22319,10 @@ var __webpack_exports__ = {};
|
|
|
22047
22319
|
});
|
|
22048
22320
|
if (!playerOnly) this.stopListeningToVisibility = this.visibility.onChange((visible)=>{
|
|
22049
22321
|
if (this.built) if (visible) {
|
|
22050
|
-
if (isAutoPauseEnabled(this.options)
|
|
22322
|
+
if (isAutoPauseEnabled(this.options)) this.recoverCamera();
|
|
22051
22323
|
this.emit("VISIBLE");
|
|
22052
22324
|
} else {
|
|
22053
|
-
if (isAutoPauseEnabled(this.options)
|
|
22325
|
+
if (isAutoPauseEnabled(this.options)) this.suspend();
|
|
22054
22326
|
this.emit("INVISIBLE");
|
|
22055
22327
|
}
|
|
22056
22328
|
});
|
|
@@ -22244,6 +22516,13 @@ var __webpack_exports__ = {};
|
|
|
22244
22516
|
pause(params) {
|
|
22245
22517
|
this.visuals.pause(params);
|
|
22246
22518
|
}
|
|
22519
|
+
suspend() {
|
|
22520
|
+
if (this.built && (this.isCountingDown() || this.isRecording() || this.isPaused())) this.pause();
|
|
22521
|
+
}
|
|
22522
|
+
recoverCamera() {
|
|
22523
|
+
if (!this.built || this.hasError || this.submitted) return Promise.resolve(false);
|
|
22524
|
+
return this.visuals.recoverCamera();
|
|
22525
|
+
}
|
|
22247
22526
|
validate(event, force = false) {
|
|
22248
22527
|
let runValidation = true;
|
|
22249
22528
|
let valid = true;
|
|
@@ -22631,6 +22910,12 @@ var __webpack_exports__ = {};
|
|
|
22631
22910
|
record() {
|
|
22632
22911
|
this.container.record();
|
|
22633
22912
|
}
|
|
22913
|
+
pause() {
|
|
22914
|
+
this.container.suspend();
|
|
22915
|
+
}
|
|
22916
|
+
recoverCamera() {
|
|
22917
|
+
return this.container.recoverCamera();
|
|
22918
|
+
}
|
|
22634
22919
|
getLogLines() {
|
|
22635
22920
|
if (this.options.logger.getLines) return this.options.logger.getLines();
|
|
22636
22921
|
}
|