videomail-client 15.7.18 → 15.8.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.
@@ -10972,7 +10972,7 @@ var __webpack_exports__ = {};
10972
10972
  var client = __webpack_require__("Q");
10973
10973
  var client_default = /*#__PURE__*/ __webpack_require__.n(client);
10974
10974
  var package_namespaceObject = {
10975
- rE: "15.7.18"
10975
+ rE: "15.8.0"
10976
10976
  };
10977
10977
  function isAudioEnabled(options) {
10978
10978
  return Boolean(options.audio.enabled);
@@ -19276,9 +19276,10 @@ var __webpack_exports__ = {};
19276
19276
  setVisualStream(localMediaStream) {
19277
19277
  if (localMediaStream) this.attachMediaStream(localMediaStream);
19278
19278
  else {
19279
- var _this_rawVisualUserMedia, _this_rawVisualUserMedia1;
19280
- null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.removeAttribute("srcObject");
19281
- null == (_this_rawVisualUserMedia1 = this.rawVisualUserMedia) || _this_rawVisualUserMedia1.removeAttribute("src");
19279
+ if (this.rawVisualUserMedia) {
19280
+ this.rawVisualUserMedia.srcObject = null;
19281
+ this.rawVisualUserMedia.removeAttribute("src");
19282
+ }
19282
19283
  this.currentVisualStream = void 0;
19283
19284
  }
19284
19285
  }
@@ -19288,26 +19289,21 @@ var __webpack_exports__ = {};
19288
19289
  return !(null == (_this_currentVisualStream = this.currentVisualStream) ? void 0 : _this_currentVisualStream.active);
19289
19290
  }
19290
19291
  hasInvalidDimensions() {
19291
- var _this_rawVisualUserMedia, _this_rawVisualUserMedia1;
19292
- if ((null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) ? void 0 : _this_rawVisualUserMedia.videoWidth) && this.rawVisualUserMedia.videoWidth < 3 || (null == (_this_rawVisualUserMedia1 = this.rawVisualUserMedia) ? void 0 : _this_rawVisualUserMedia1.height) && this.rawVisualUserMedia.height < 3) return true;
19293
- return false;
19292
+ if (!this.rawVisualUserMedia) return false;
19293
+ const { videoWidth, videoHeight } = this.rawVisualUserMedia;
19294
+ return videoWidth > 0 && videoWidth < 3 || videoHeight > 0 && videoHeight < 3;
19294
19295
  }
19295
19296
  logEvent(eventType, params) {
19296
19297
  this.options.logger.debug(`UserMedia: ... ${EVENT_ASCII} event ${eventType}: ${util_pretty(params)}`);
19297
19298
  }
19298
- outputEvent(e) {
19299
- var _this_rawVisualUserMedia, _this_rawVisualUserMedia1;
19300
- this.logEvent(e.type, {
19301
- readyState: null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) ? void 0 : _this_rawVisualUserMedia.readyState
19302
- });
19303
- null == (_this_rawVisualUserMedia1 = this.rawVisualUserMedia) || _this_rawVisualUserMedia1.removeEventListener(e.type, this.outputEvent.bind(this));
19304
- }
19305
19299
  unloadRemainingEventListeners() {
19300
+ var _this_rawVisualUserMedia;
19306
19301
  this.options.logger.debug("UserMedia: unloadRemainingEventListeners()");
19307
19302
  mediaEvents.forEach((eventName)=>{
19308
19303
  var _this_rawVisualUserMedia;
19309
- null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.removeEventListener(eventName, this.outputEvent.bind(this));
19304
+ null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.removeEventListener(eventName, this.outputEvent);
19310
19305
  });
19306
+ null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.removeEventListener("error", this.handleMediaError);
19311
19307
  }
19312
19308
  audioRecord(audioCallback) {
19313
19309
  var _this_audioRecorder;
@@ -19418,7 +19414,7 @@ var __webpack_exports__ = {};
19418
19414
  }
19419
19415
  };
19420
19416
  try {
19421
- var _this_rawVisualUserMedia, _this_rawVisualUserMedia1, _this_rawVisualUserMedia2;
19417
+ var _this_rawVisualUserMedia, _this_rawVisualUserMedia1, _this_rawVisualUserMedia2, _this_rawVisualUserMedia3;
19422
19418
  const videoTrack = media_getFirstVideoTrack(localMediaStream);
19423
19419
  this.videoTrackLabel = null == videoTrack ? void 0 : videoTrack.label;
19424
19420
  if (videoTrack) if (videoTrack.enabled) if (util_isVirtualCamera(videoTrack)) throw error_createError({
@@ -19440,9 +19436,8 @@ var __webpack_exports__ = {};
19440
19436
  else this.options.logger.debug("UserMedia: detected (but no video tracks exist");
19441
19437
  null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.addEventListener("loadedmetadata", onLoadedMetaData);
19442
19438
  null == (_this_rawVisualUserMedia1 = this.rawVisualUserMedia) || _this_rawVisualUserMedia1.addEventListener("play", onPlay);
19443
- null == (_this_rawVisualUserMedia2 = this.rawVisualUserMedia) || _this_rawVisualUserMedia2.addEventListener("error", (err)=>{
19444
- this.options.logger.warn(`Caught video element error event: ${util_pretty(err)}`);
19445
- });
19439
+ null == (_this_rawVisualUserMedia2 = this.rawVisualUserMedia) || _this_rawVisualUserMedia2.removeEventListener("error", this.handleMediaError);
19440
+ null == (_this_rawVisualUserMedia3 = this.rawVisualUserMedia) || _this_rawVisualUserMedia3.addEventListener("error", this.handleMediaError);
19446
19441
  this.setVisualStream(localMediaStream);
19447
19442
  play();
19448
19443
  } catch (exc) {
@@ -19455,8 +19450,8 @@ var __webpack_exports__ = {};
19455
19450
  return this.videoTrackLabel;
19456
19451
  }
19457
19452
  isReady() {
19458
- var _this_rawVisualUserMedia;
19459
- return Boolean(null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) ? void 0 : _this_rawVisualUserMedia.src);
19453
+ var _this_rawVisualUserMedia, _this_rawVisualUserMedia1;
19454
+ return Boolean((null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) ? void 0 : _this_rawVisualUserMedia.srcObject) || (null == (_this_rawVisualUserMedia1 = this.rawVisualUserMedia) ? void 0 : _this_rawVisualUserMedia1.currentSrc));
19460
19455
  }
19461
19456
  stop(visualStream, params) {
19462
19457
  try {
@@ -19560,12 +19555,20 @@ var __webpack_exports__ = {};
19560
19555
  };
19561
19556
  }
19562
19557
  constructor(recorder, options){
19563
- 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);
19558
+ 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)=>{
19559
+ var _this_rawVisualUserMedia, _this_rawVisualUserMedia1;
19560
+ this.logEvent(e.type, {
19561
+ readyState: null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) ? void 0 : _this_rawVisualUserMedia.readyState
19562
+ });
19563
+ null == (_this_rawVisualUserMedia1 = this.rawVisualUserMedia) || _this_rawVisualUserMedia1.removeEventListener(e.type, this.outputEvent);
19564
+ }), userMedia_define_property(this, "handleMediaError", (event)=>{
19565
+ this.options.logger.warn(`Caught video element error event: ${util_pretty(event)}`);
19566
+ });
19564
19567
  this.recorder = recorder;
19565
19568
  this.rawVisualUserMedia = recorder.getRawVisualUserMedia();
19566
19569
  mediaEvents.forEach((eventName)=>{
19567
19570
  var _this_rawVisualUserMedia;
19568
- null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.addEventListener(eventName, this.outputEvent.bind(this), false);
19571
+ null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.addEventListener(eventName, this.outputEvent, false);
19569
19572
  });
19570
19573
  }
19571
19574
  }
@@ -19627,13 +19630,16 @@ var __webpack_exports__ = {};
19627
19630
  }
19628
19631
  }
19629
19632
  sendPings() {
19633
+ this.stopPings();
19630
19634
  this.pingInterval = window.setInterval(()=>{
19631
19635
  this.options.logger.debug("Recorder: pinging...");
19632
19636
  this.writeStream(Buffer.from(""));
19633
19637
  }, this.options.timeouts.pingInterval);
19634
19638
  }
19635
19639
  stopPings() {
19636
- clearInterval(this.pingInterval);
19640
+ if (void 0 === this.pingInterval) return;
19641
+ window.clearInterval(this.pingInterval);
19642
+ this.pingInterval = void 0;
19637
19643
  }
19638
19644
  onAudioSample(audioSample) {
19639
19645
  this.samplesCount++;
@@ -19664,13 +19670,13 @@ var __webpack_exports__ = {};
19664
19670
  }
19665
19671
  }
19666
19672
  clearRetryTimeout() {
19667
- if (!this.retryTimeout) return;
19673
+ if (void 0 === this.retryTimeout) return;
19668
19674
  this.options.logger.debug("Recorder: clearRetryTimeout()");
19669
19675
  window.clearTimeout(this.retryTimeout);
19670
19676
  this.retryTimeout = void 0;
19671
19677
  }
19672
19678
  clearConnectionTimeout() {
19673
- if (!this.connectionTimeout) return;
19679
+ if (void 0 === this.connectionTimeout) return;
19674
19680
  this.options.logger.debug("Recorder: clearConnectionTimeout()");
19675
19681
  window.clearTimeout(this.connectionTimeout);
19676
19682
  this.connectionTimeout = void 0;
@@ -19999,19 +20005,23 @@ var __webpack_exports__ = {};
19999
20005
  const characteristics = null == (_this_userMedia = this.userMedia) ? void 0 : _this_userMedia.getCharacteristics();
20000
20006
  this.options.logger.debug(`Recorder: userMediaErrorCallback(), name: ${err.name}, message: ${err.message} and Webcam characteristics: ${characteristics ? util_pretty(characteristics) : "none"}`);
20001
20007
  const errorListeners = this.getListeners("ERROR");
20002
- if (null == errorListeners ? void 0 : errorListeners.length) {
20003
- if (err.name !== error_VideomailError.MEDIA_DEVICE_NOT_SUPPORTED) {
20004
- const videomailError = error_createError({
20005
- err,
20006
- options: this.options,
20007
- usedConstraints
20008
- });
20009
- this.emit("ERROR", {
20010
- err: videomailError
20011
- });
20012
- } else this.options.logger.debug(`Recorder: ignore user media error ${util_pretty(err)}`);
20013
- this.retryTimeout = window.setTimeout(this.initSocket.bind(this), this.options.timeouts.userMedia);
20014
- } else if (this.unloaded) this.options.logger.debug(`Recorder: already unloaded. Not going to throw error ${util_pretty(err)}`);
20008
+ if (null == errorListeners ? void 0 : errorListeners.length) if (err.name !== error_VideomailError.MEDIA_DEVICE_NOT_SUPPORTED) {
20009
+ const videomailError = error_createError({
20010
+ err,
20011
+ options: this.options,
20012
+ usedConstraints
20013
+ });
20014
+ this.emit("ERROR", {
20015
+ err: videomailError
20016
+ });
20017
+ } else {
20018
+ this.options.logger.debug(`Recorder: ignore user media error ${util_pretty(err)}`);
20019
+ this.retryTimeout = window.setTimeout(()=>{
20020
+ this.retryTimeout = void 0;
20021
+ this.loadUserMedia();
20022
+ }, this.options.timeouts.userMedia);
20023
+ }
20024
+ else if (this.unloaded) this.options.logger.debug(`Recorder: already unloaded. Not going to throw error ${util_pretty(err)}`);
20015
20025
  else {
20016
20026
  this.options.logger.debug(`Recorder: no error listeners attached but throwing error ${util_pretty(err)}`);
20017
20027
  throw error_createError({
@@ -20235,7 +20245,8 @@ var __webpack_exports__ = {};
20235
20245
  limitReached
20236
20246
  });
20237
20247
  null == (_this_loop = this.loop) || _this_loop.complete();
20238
- setTimeout(()=>{
20248
+ this.stopTimeout = window.setTimeout(()=>{
20249
+ this.stopTimeout = void 0;
20239
20250
  this.stopTime = Date.now();
20240
20251
  const videoType = this.replay.getVideoType();
20241
20252
  if (!videoType) throw new Error("Unable to video record when no video type is defined.");
@@ -20285,6 +20296,9 @@ var __webpack_exports__ = {};
20285
20296
  this.reset();
20286
20297
  this.clearUserMediaTimeout();
20287
20298
  this.clearConnectionTimeout();
20299
+ this.clearRetryTimeout();
20300
+ this.clearStopTimeout();
20301
+ this.stopPings();
20288
20302
  this.connecting = false;
20289
20303
  if (this.userMedia) this.userMedia.unloadRemainingEventListeners();
20290
20304
  if (this.submitting) ;
@@ -20308,12 +20322,17 @@ var __webpack_exports__ = {};
20308
20322
  }
20309
20323
  }
20310
20324
  clearUserMediaTimeout() {
20311
- if (this.userMediaTimeout) {
20325
+ if (void 0 !== this.userMediaTimeout) {
20312
20326
  this.options.logger.debug("Recorder: clearUserMediaTimeout()");
20313
20327
  window.clearTimeout(this.userMediaTimeout);
20314
20328
  this.userMediaTimeout = void 0;
20315
20329
  }
20316
20330
  }
20331
+ clearStopTimeout() {
20332
+ if (void 0 === this.stopTimeout) return;
20333
+ window.clearTimeout(this.stopTimeout);
20334
+ this.stopTimeout = void 0;
20335
+ }
20317
20336
  validate() {
20318
20337
  return this.connected && void 0 === this.canvas;
20319
20338
  }
@@ -20697,7 +20716,7 @@ var __webpack_exports__ = {};
20697
20716
  return this.userMediaLoaded;
20698
20717
  }
20699
20718
  constructor(visuals, replay, options){
20700
- super("Recorder", options), recorder_define_property(this, "visuals", void 0), recorder_define_property(this, "replay", void 0), 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, "connectionTimeout", 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, "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, "connecting", false), recorder_define_property(this, "connected", false), recorder_define_property(this, "connectionFailed", false), 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);
20719
+ super("Recorder", options), recorder_define_property(this, "visuals", void 0), recorder_define_property(this, "replay", void 0), 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, "connectionTimeout", 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, "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, "connecting", false), recorder_define_property(this, "connected", false), recorder_define_property(this, "connectionFailed", false), 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);
20701
20720
  this.visuals = visuals;
20702
20721
  this.replay = replay;
20703
20722
  this.facingMode = options.video.facingMode;
@@ -20794,14 +20813,13 @@ var __webpack_exports__ = {};
20794
20813
  if (hasAudio) this.replayElement.volume = 1;
20795
20814
  else if (!isAudioEnabled(this.options)) this.replayElement.setAttribute("muted", "true");
20796
20815
  this.replayElement.load();
20797
- if (this.videomail) this.replayElement.addEventListener("canplaythrough", ()=>{
20798
- this.emit("REPLAY_SHOWN");
20799
- }, {
20800
- once: true
20801
- });
20802
- else this.replayElement.addEventListener("canplaythrough", ()=>{
20803
- this.emit("PREVIEW_SHOWN");
20804
- }, {
20816
+ if (this.canPlayThroughHandler) this.replayElement.removeEventListener("canplaythrough", this.canPlayThroughHandler);
20817
+ const eventName = this.videomail ? "REPLAY_SHOWN" : "PREVIEW_SHOWN";
20818
+ this.canPlayThroughHandler = ()=>{
20819
+ this.canPlayThroughHandler = void 0;
20820
+ this.emit(eventName);
20821
+ };
20822
+ this.replayElement.addEventListener("canplaythrough", this.canPlayThroughHandler, {
20805
20823
  once: true
20806
20824
  });
20807
20825
  }
@@ -20824,49 +20842,27 @@ var __webpack_exports__ = {};
20824
20842
  null == (_this_replayElement = this.replayElement) || _this_replayElement.setAttribute("controls", "controls");
20825
20843
  this.show(null == params ? void 0 : params.width, null == params ? void 0 : params.height, null == params ? void 0 : params.hasAudio);
20826
20844
  });
20827
- this.replayElement.addEventListener("touchstart", (e)=>{
20828
- var _this_replayElement;
20829
- e.preventDefault();
20830
- if (null == (_this_replayElement = this.replayElement) ? void 0 : _this_replayElement.paused) this.replayElement.play().catch((exc)=>{
20831
- throw error_createError({
20832
- message: "Failed to play replay video while paused upon touchstart event.",
20833
- exc,
20834
- options: this.options
20835
- });
20836
- });
20837
- else {
20838
- var _this_replayElement1;
20839
- null == (_this_replayElement1 = this.replayElement) || _this_replayElement1.pause();
20840
- }
20841
- }, {
20842
- passive: true
20843
- });
20844
- this.replayElement.addEventListener("click", (e)=>{
20845
- var _this_replayElement;
20846
- e.preventDefault();
20847
- if (null == (_this_replayElement = this.replayElement) ? void 0 : _this_replayElement.paused) this.replayElement.play().catch((exc)=>{
20848
- throw error_createError({
20849
- message: "Failed to play replay video while paused upon click event.",
20850
- exc,
20851
- options: this.options
20852
- });
20853
- });
20854
- else {
20855
- var _this_replayElement1;
20856
- null == (_this_replayElement1 = this.replayElement) || _this_replayElement1.pause();
20857
- }
20858
- });
20845
+ this.replayElement.addEventListener("touchstart", this.togglePlayback);
20846
+ this.replayElement.addEventListener("click", this.togglePlayback);
20859
20847
  }
20860
20848
  this.built = true;
20861
20849
  this.options.logger.debug("Replay: built.");
20862
20850
  }
20863
20851
  unload(params) {
20852
+ var _this_replayElement, _this_replayElement1;
20864
20853
  this.options.logger.debug("Replay: unload()");
20854
+ if (this.canPlayThroughHandler) {
20855
+ var _this_replayElement2;
20856
+ null == (_this_replayElement2 = this.replayElement) || _this_replayElement2.removeEventListener("canplaythrough", this.canPlayThroughHandler);
20857
+ this.canPlayThroughHandler = void 0;
20858
+ }
20859
+ null == (_this_replayElement = this.replayElement) || _this_replayElement.removeEventListener("touchstart", this.togglePlayback);
20860
+ null == (_this_replayElement1 = this.replayElement) || _this_replayElement1.removeEventListener("click", this.togglePlayback);
20865
20861
  this.removeAllListeners();
20866
20862
  if (null == params ? void 0 : params.startingOver) this.hide();
20867
20863
  else {
20868
- var _this_replayElement;
20869
- null == (_this_replayElement = this.replayElement) || _this_replayElement.remove();
20864
+ var _this_replayElement3;
20865
+ null == (_this_replayElement3 = this.replayElement) || _this_replayElement3.remove();
20870
20866
  this.replayElement = void 0;
20871
20867
  }
20872
20868
  this.videomail = void 0;
@@ -20908,7 +20904,7 @@ var __webpack_exports__ = {};
20908
20904
  let source = this.getVideoSource(type);
20909
20905
  let url = src;
20910
20906
  if (url && bustCache) url += `?${Date.now()}`;
20911
- if (source) if (src) source.setAttribute("src", src);
20907
+ if (source) if (url) source.setAttribute("src", url);
20912
20908
  else source.remove();
20913
20909
  else if (src) {
20914
20910
  const { fps } = this.options.video;
@@ -20972,7 +20968,24 @@ var __webpack_exports__ = {};
20972
20968
  return this.replayElement;
20973
20969
  }
20974
20970
  constructor(visuals, options){
20975
- super("Replay", options), replay_define_property(this, "visuals", void 0), replay_define_property(this, "built", false), replay_define_property(this, "replayElement", void 0), replay_define_property(this, "videomail", void 0);
20971
+ super("Replay", options), replay_define_property(this, "visuals", void 0), replay_define_property(this, "built", false), replay_define_property(this, "replayElement", void 0), replay_define_property(this, "videomail", void 0), replay_define_property(this, "canPlayThroughHandler", void 0), replay_define_property(this, "togglePlayback", (e)=>{
20972
+ var _this_replayElement;
20973
+ e.preventDefault();
20974
+ if (null == (_this_replayElement = this.replayElement) ? void 0 : _this_replayElement.paused) this.replayElement.play().catch((exc)=>{
20975
+ const err = error_createError({
20976
+ message: `Failed to play replay video upon ${e.type} event.`,
20977
+ exc,
20978
+ options: this.options
20979
+ });
20980
+ this.emit("ERROR", {
20981
+ err
20982
+ });
20983
+ });
20984
+ else {
20985
+ var _this_replayElement1;
20986
+ null == (_this_replayElement1 = this.replayElement) || _this_replayElement1.pause();
20987
+ }
20988
+ });
20976
20989
  this.visuals = visuals;
20977
20990
  }
20978
20991
  }
@@ -21395,18 +21408,11 @@ var __webpack_exports__ = {};
21395
21408
  }
21396
21409
  initEvents(playerOnly = false) {
21397
21410
  this.options.logger.debug(`Container: initEvents (playerOnly = ${playerOnly})`);
21398
- if (this.options.recalculateDimensionsOnWindowResize) window.addEventListener("resize", ()=>{
21399
- if (!this.built) return;
21400
- this.emit("WINDOW_RESIZE", "container");
21401
- });
21402
- if (this.options.enableAutoUnload) window.addEventListener("beforeunload", (e)=>{
21403
- this.unload({
21404
- e
21405
- });
21406
- }, {
21411
+ if (this.options.recalculateDimensionsOnWindowResize) window.addEventListener("resize", this.handleWindowResize);
21412
+ if (this.options.enableAutoUnload) window.addEventListener("beforeunload", this.handleBeforeUnload, {
21407
21413
  once: true
21408
21414
  });
21409
- if (!playerOnly) this.visibility.onChange((visible)=>{
21415
+ if (!playerOnly) this.stopListeningToVisibility = this.visibility.onChange((visible)=>{
21410
21416
  if (this.built) if (visible) {
21411
21417
  if (isAutoPauseEnabled(this.options) && this.isCountingDown()) this.resume();
21412
21418
  this.emit("VISIBLE");
@@ -21416,19 +21422,7 @@ var __webpack_exports__ = {};
21416
21422
  }
21417
21423
  });
21418
21424
  if (this.options.enableSpace) {
21419
- if (!playerOnly) window.addEventListener("keydown", (e)=>{
21420
- const element = e.target;
21421
- const tagName = element.tagName;
21422
- const isEditable = element.isContentEditable || "true" === element.contentEditable;
21423
- if (!isEditable && tagName && "INPUT" !== tagName.toUpperCase() && "TEXTAREA" !== tagName.toUpperCase()) {
21424
- const code = e.code;
21425
- if ("Space" === code) {
21426
- e.preventDefault();
21427
- if (this.options.enablePause) this.visuals.pauseOrResume();
21428
- else this.visuals.recordOrStop();
21429
- }
21430
- }
21431
- });
21425
+ if (!playerOnly) window.addEventListener("keydown", this.handleKeyDown);
21432
21426
  }
21433
21427
  this.on("ERROR", (params)=>{
21434
21428
  this.processError(params);
@@ -21465,6 +21459,14 @@ var __webpack_exports__ = {};
21465
21459
  }
21466
21460
  this.endWaiting();
21467
21461
  }
21462
+ removeBrowserEventListeners() {
21463
+ var _this_stopListeningToVisibility, _this;
21464
+ window.removeEventListener("resize", this.handleWindowResize);
21465
+ window.removeEventListener("beforeunload", this.handleBeforeUnload);
21466
+ window.removeEventListener("keydown", this.handleKeyDown);
21467
+ null == (_this_stopListeningToVisibility = (_this = this).stopListeningToVisibility) || _this_stopListeningToVisibility.call(_this);
21468
+ this.stopListeningToVisibility = void 0;
21469
+ }
21468
21470
  hideMySelf() {
21469
21471
  html_hideElement(this.containerElement);
21470
21472
  }
@@ -21536,6 +21538,7 @@ var __webpack_exports__ = {};
21536
21538
  exc
21537
21539
  });
21538
21540
  } finally{
21541
+ this.removeBrowserEventListeners();
21539
21542
  this.removeAllListeners();
21540
21543
  this.built = this.submitted = false;
21541
21544
  }
@@ -21817,7 +21820,22 @@ var __webpack_exports__ = {};
21817
21820
  this.visuals.setLimitSeconds(limitSeconds);
21818
21821
  }
21819
21822
  constructor(options){
21820
- super("Container", options), container_define_property(this, "visibility", document_visibility_default()()), container_define_property(this, "htmlElement", document.querySelector("html")), container_define_property(this, "visuals", void 0), container_define_property(this, "buttons", void 0), container_define_property(this, "resource", void 0), container_define_property(this, "form", void 0), container_define_property(this, "hasError", false), container_define_property(this, "submitted", false), container_define_property(this, "lastValidation", false), container_define_property(this, "containerElement", void 0), container_define_property(this, "built", false);
21823
+ super("Container", options), container_define_property(this, "visibility", document_visibility_default()()), container_define_property(this, "htmlElement", document.querySelector("html")), container_define_property(this, "visuals", void 0), container_define_property(this, "buttons", void 0), container_define_property(this, "resource", void 0), container_define_property(this, "form", void 0), container_define_property(this, "hasError", false), container_define_property(this, "submitted", false), container_define_property(this, "lastValidation", false), container_define_property(this, "containerElement", void 0), container_define_property(this, "built", false), container_define_property(this, "stopListeningToVisibility", void 0), container_define_property(this, "handleWindowResize", ()=>{
21824
+ if (this.built) this.emit("WINDOW_RESIZE", "container");
21825
+ }), container_define_property(this, "handleBeforeUnload", (e)=>{
21826
+ this.unload({
21827
+ e
21828
+ });
21829
+ }), container_define_property(this, "handleKeyDown", (e)=>{
21830
+ const element = e.target;
21831
+ const tagName = element.tagName;
21832
+ const isEditable = element.isContentEditable || "true" === element.contentEditable;
21833
+ if (!isEditable && tagName && "INPUT" !== tagName.toUpperCase() && "TEXTAREA" !== tagName.toUpperCase() && "Space" === e.code) {
21834
+ e.preventDefault();
21835
+ if (this.options.enablePause) this.visuals.pauseOrResume();
21836
+ else this.visuals.recordOrStop();
21837
+ }
21838
+ });
21821
21839
  this.visuals = new wrappers_visuals(this, options);
21822
21840
  this.buttons = new buttons(this, options);
21823
21841
  this.resource = new src_resource(options);