videomail-client 15.7.18 → 15.7.19

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.7.19"
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,20 @@ 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
+ return this.rawVisualUserMedia.videoWidth < 3 || this.rawVisualUserMedia.videoHeight < 3;
19294
19294
  }
19295
19295
  logEvent(eventType, params) {
19296
19296
  this.options.logger.debug(`UserMedia: ... ${EVENT_ASCII} event ${eventType}: ${util_pretty(params)}`);
19297
19297
  }
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
19298
  unloadRemainingEventListeners() {
19299
+ var _this_rawVisualUserMedia;
19306
19300
  this.options.logger.debug("UserMedia: unloadRemainingEventListeners()");
19307
19301
  mediaEvents.forEach((eventName)=>{
19308
19302
  var _this_rawVisualUserMedia;
19309
- null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.removeEventListener(eventName, this.outputEvent.bind(this));
19303
+ null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.removeEventListener(eventName, this.outputEvent);
19310
19304
  });
19305
+ null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.removeEventListener("error", this.handleMediaError);
19311
19306
  }
19312
19307
  audioRecord(audioCallback) {
19313
19308
  var _this_audioRecorder;
@@ -19418,7 +19413,7 @@ var __webpack_exports__ = {};
19418
19413
  }
19419
19414
  };
19420
19415
  try {
19421
- var _this_rawVisualUserMedia, _this_rawVisualUserMedia1, _this_rawVisualUserMedia2;
19416
+ var _this_rawVisualUserMedia, _this_rawVisualUserMedia1, _this_rawVisualUserMedia2, _this_rawVisualUserMedia3;
19422
19417
  const videoTrack = media_getFirstVideoTrack(localMediaStream);
19423
19418
  this.videoTrackLabel = null == videoTrack ? void 0 : videoTrack.label;
19424
19419
  if (videoTrack) if (videoTrack.enabled) if (util_isVirtualCamera(videoTrack)) throw error_createError({
@@ -19440,9 +19435,8 @@ var __webpack_exports__ = {};
19440
19435
  else this.options.logger.debug("UserMedia: detected (but no video tracks exist");
19441
19436
  null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.addEventListener("loadedmetadata", onLoadedMetaData);
19442
19437
  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
- });
19438
+ null == (_this_rawVisualUserMedia2 = this.rawVisualUserMedia) || _this_rawVisualUserMedia2.removeEventListener("error", this.handleMediaError);
19439
+ null == (_this_rawVisualUserMedia3 = this.rawVisualUserMedia) || _this_rawVisualUserMedia3.addEventListener("error", this.handleMediaError);
19446
19440
  this.setVisualStream(localMediaStream);
19447
19441
  play();
19448
19442
  } catch (exc) {
@@ -19455,8 +19449,8 @@ var __webpack_exports__ = {};
19455
19449
  return this.videoTrackLabel;
19456
19450
  }
19457
19451
  isReady() {
19458
- var _this_rawVisualUserMedia;
19459
- return Boolean(null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) ? void 0 : _this_rawVisualUserMedia.src);
19452
+ var _this_rawVisualUserMedia, _this_rawVisualUserMedia1;
19453
+ return Boolean((null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) ? void 0 : _this_rawVisualUserMedia.srcObject) || (null == (_this_rawVisualUserMedia1 = this.rawVisualUserMedia) ? void 0 : _this_rawVisualUserMedia1.currentSrc));
19460
19454
  }
19461
19455
  stop(visualStream, params) {
19462
19456
  try {
@@ -19560,12 +19554,20 @@ var __webpack_exports__ = {};
19560
19554
  };
19561
19555
  }
19562
19556
  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);
19557
+ 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)=>{
19558
+ var _this_rawVisualUserMedia, _this_rawVisualUserMedia1;
19559
+ this.logEvent(e.type, {
19560
+ readyState: null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) ? void 0 : _this_rawVisualUserMedia.readyState
19561
+ });
19562
+ null == (_this_rawVisualUserMedia1 = this.rawVisualUserMedia) || _this_rawVisualUserMedia1.removeEventListener(e.type, this.outputEvent);
19563
+ }), userMedia_define_property(this, "handleMediaError", (event)=>{
19564
+ this.options.logger.warn(`Caught video element error event: ${util_pretty(event)}`);
19565
+ });
19564
19566
  this.recorder = recorder;
19565
19567
  this.rawVisualUserMedia = recorder.getRawVisualUserMedia();
19566
19568
  mediaEvents.forEach((eventName)=>{
19567
19569
  var _this_rawVisualUserMedia;
19568
- null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.addEventListener(eventName, this.outputEvent.bind(this), false);
19570
+ null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.addEventListener(eventName, this.outputEvent, false);
19569
19571
  });
19570
19572
  }
19571
19573
  }
@@ -20794,14 +20796,13 @@ var __webpack_exports__ = {};
20794
20796
  if (hasAudio) this.replayElement.volume = 1;
20795
20797
  else if (!isAudioEnabled(this.options)) this.replayElement.setAttribute("muted", "true");
20796
20798
  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
- }, {
20799
+ if (this.canPlayThroughHandler) this.replayElement.removeEventListener("canplaythrough", this.canPlayThroughHandler);
20800
+ const eventName = this.videomail ? "REPLAY_SHOWN" : "PREVIEW_SHOWN";
20801
+ this.canPlayThroughHandler = ()=>{
20802
+ this.canPlayThroughHandler = void 0;
20803
+ this.emit(eventName);
20804
+ };
20805
+ this.replayElement.addEventListener("canplaythrough", this.canPlayThroughHandler, {
20805
20806
  once: true
20806
20807
  });
20807
20808
  }
@@ -20824,49 +20825,27 @@ var __webpack_exports__ = {};
20824
20825
  null == (_this_replayElement = this.replayElement) || _this_replayElement.setAttribute("controls", "controls");
20825
20826
  this.show(null == params ? void 0 : params.width, null == params ? void 0 : params.height, null == params ? void 0 : params.hasAudio);
20826
20827
  });
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
- });
20828
+ this.replayElement.addEventListener("touchstart", this.togglePlayback);
20829
+ this.replayElement.addEventListener("click", this.togglePlayback);
20859
20830
  }
20860
20831
  this.built = true;
20861
20832
  this.options.logger.debug("Replay: built.");
20862
20833
  }
20863
20834
  unload(params) {
20835
+ var _this_replayElement, _this_replayElement1;
20864
20836
  this.options.logger.debug("Replay: unload()");
20837
+ if (this.canPlayThroughHandler) {
20838
+ var _this_replayElement2;
20839
+ null == (_this_replayElement2 = this.replayElement) || _this_replayElement2.removeEventListener("canplaythrough", this.canPlayThroughHandler);
20840
+ this.canPlayThroughHandler = void 0;
20841
+ }
20842
+ null == (_this_replayElement = this.replayElement) || _this_replayElement.removeEventListener("touchstart", this.togglePlayback);
20843
+ null == (_this_replayElement1 = this.replayElement) || _this_replayElement1.removeEventListener("click", this.togglePlayback);
20865
20844
  this.removeAllListeners();
20866
20845
  if (null == params ? void 0 : params.startingOver) this.hide();
20867
20846
  else {
20868
- var _this_replayElement;
20869
- null == (_this_replayElement = this.replayElement) || _this_replayElement.remove();
20847
+ var _this_replayElement3;
20848
+ null == (_this_replayElement3 = this.replayElement) || _this_replayElement3.remove();
20870
20849
  this.replayElement = void 0;
20871
20850
  }
20872
20851
  this.videomail = void 0;
@@ -20908,7 +20887,7 @@ var __webpack_exports__ = {};
20908
20887
  let source = this.getVideoSource(type);
20909
20888
  let url = src;
20910
20889
  if (url && bustCache) url += `?${Date.now()}`;
20911
- if (source) if (src) source.setAttribute("src", src);
20890
+ if (source) if (url) source.setAttribute("src", url);
20912
20891
  else source.remove();
20913
20892
  else if (src) {
20914
20893
  const { fps } = this.options.video;
@@ -20972,7 +20951,24 @@ var __webpack_exports__ = {};
20972
20951
  return this.replayElement;
20973
20952
  }
20974
20953
  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);
20954
+ 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)=>{
20955
+ var _this_replayElement;
20956
+ e.preventDefault();
20957
+ if (null == (_this_replayElement = this.replayElement) ? void 0 : _this_replayElement.paused) this.replayElement.play().catch((exc)=>{
20958
+ const err = error_createError({
20959
+ message: `Failed to play replay video upon ${e.type} event.`,
20960
+ exc,
20961
+ options: this.options
20962
+ });
20963
+ this.emit("ERROR", {
20964
+ err
20965
+ });
20966
+ });
20967
+ else {
20968
+ var _this_replayElement1;
20969
+ null == (_this_replayElement1 = this.replayElement) || _this_replayElement1.pause();
20970
+ }
20971
+ });
20976
20972
  this.visuals = visuals;
20977
20973
  }
20978
20974
  }
package/dist/esm/index.js CHANGED
@@ -3620,7 +3620,7 @@ const constants = {
3620
3620
  }
3621
3621
  };
3622
3622
  var package_namespaceObject = {
3623
- rE: "15.7.18"
3623
+ rE: "15.7.19"
3624
3624
  };
3625
3625
  function isAudioEnabled(options) {
3626
3626
  return Boolean(options.audio.enabled);
@@ -6320,8 +6320,10 @@ class UserMedia extends util_Despot {
6320
6320
  setVisualStream(localMediaStream) {
6321
6321
  if (localMediaStream) this.attachMediaStream(localMediaStream);
6322
6322
  else {
6323
- this.rawVisualUserMedia?.removeAttribute("srcObject");
6324
- this.rawVisualUserMedia?.removeAttribute("src");
6323
+ if (this.rawVisualUserMedia) {
6324
+ this.rawVisualUserMedia.srcObject = null;
6325
+ this.rawVisualUserMedia.removeAttribute("src");
6326
+ }
6325
6327
  this.currentVisualStream = void 0;
6326
6328
  }
6327
6329
  }
@@ -6330,23 +6332,18 @@ class UserMedia extends util_Despot {
6330
6332
  return !this.currentVisualStream?.active;
6331
6333
  }
6332
6334
  hasInvalidDimensions() {
6333
- if (this.rawVisualUserMedia?.videoWidth && this.rawVisualUserMedia.videoWidth < 3 || this.rawVisualUserMedia?.height && this.rawVisualUserMedia.height < 3) return true;
6334
- return false;
6335
+ if (!this.rawVisualUserMedia) return false;
6336
+ return this.rawVisualUserMedia.videoWidth < 3 || this.rawVisualUserMedia.videoHeight < 3;
6335
6337
  }
6336
6338
  logEvent(eventType, params) {
6337
6339
  this.options.logger.debug(`UserMedia: ... ${EVENT_ASCII} event ${eventType}: ${util_pretty(params)}`);
6338
6340
  }
6339
- outputEvent(e) {
6340
- this.logEvent(e.type, {
6341
- readyState: this.rawVisualUserMedia?.readyState
6342
- });
6343
- this.rawVisualUserMedia?.removeEventListener(e.type, this.outputEvent.bind(this));
6344
- }
6345
6341
  unloadRemainingEventListeners() {
6346
6342
  this.options.logger.debug("UserMedia: unloadRemainingEventListeners()");
6347
6343
  mediaEvents.forEach((eventName)=>{
6348
- this.rawVisualUserMedia?.removeEventListener(eventName, this.outputEvent.bind(this));
6344
+ this.rawVisualUserMedia?.removeEventListener(eventName, this.outputEvent);
6349
6345
  });
6346
+ this.rawVisualUserMedia?.removeEventListener("error", this.handleMediaError);
6350
6347
  }
6351
6348
  audioRecord(audioCallback) {
6352
6349
  this.removeListener("SENDING_FIRST_FRAME");
@@ -6472,9 +6469,8 @@ class UserMedia extends util_Despot {
6472
6469
  else this.options.logger.debug("UserMedia: detected (but no video tracks exist");
6473
6470
  this.rawVisualUserMedia?.addEventListener("loadedmetadata", onLoadedMetaData);
6474
6471
  this.rawVisualUserMedia?.addEventListener("play", onPlay);
6475
- this.rawVisualUserMedia?.addEventListener("error", (err)=>{
6476
- this.options.logger.warn(`Caught video element error event: ${util_pretty(err)}`);
6477
- });
6472
+ this.rawVisualUserMedia?.removeEventListener("error", this.handleMediaError);
6473
+ this.rawVisualUserMedia?.addEventListener("error", this.handleMediaError);
6478
6474
  this.setVisualStream(localMediaStream);
6479
6475
  play();
6480
6476
  } catch (exc) {
@@ -6487,7 +6483,7 @@ class UserMedia extends util_Despot {
6487
6483
  return this.videoTrackLabel;
6488
6484
  }
6489
6485
  isReady() {
6490
- return Boolean(this.rawVisualUserMedia?.src);
6486
+ return Boolean(this.rawVisualUserMedia?.srcObject || this.rawVisualUserMedia?.currentSrc);
6491
6487
  }
6492
6488
  stop(visualStream, params) {
6493
6489
  try {
@@ -6589,11 +6585,18 @@ class UserMedia extends util_Despot {
6589
6585
  };
6590
6586
  }
6591
6587
  constructor(recorder, options){
6592
- 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);
6588
+ 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)=>{
6589
+ this.logEvent(e.type, {
6590
+ readyState: this.rawVisualUserMedia?.readyState
6591
+ });
6592
+ this.rawVisualUserMedia?.removeEventListener(e.type, this.outputEvent);
6593
+ }), userMedia_define_property(this, "handleMediaError", (event)=>{
6594
+ this.options.logger.warn(`Caught video element error event: ${util_pretty(event)}`);
6595
+ });
6593
6596
  this.recorder = recorder;
6594
6597
  this.rawVisualUserMedia = recorder.getRawVisualUserMedia();
6595
6598
  mediaEvents.forEach((eventName)=>{
6596
- this.rawVisualUserMedia?.addEventListener(eventName, this.outputEvent.bind(this), false);
6599
+ this.rawVisualUserMedia?.addEventListener(eventName, this.outputEvent, false);
6597
6600
  });
6598
6601
  }
6599
6602
  }
@@ -7798,14 +7801,13 @@ class Replay extends util_Despot {
7798
7801
  if (hasAudio) this.replayElement.volume = 1;
7799
7802
  else if (!isAudioEnabled(this.options)) this.replayElement.setAttribute("muted", "true");
7800
7803
  this.replayElement.load();
7801
- if (this.videomail) this.replayElement.addEventListener("canplaythrough", ()=>{
7802
- this.emit("REPLAY_SHOWN");
7803
- }, {
7804
- once: true
7805
- });
7806
- else this.replayElement.addEventListener("canplaythrough", ()=>{
7807
- this.emit("PREVIEW_SHOWN");
7808
- }, {
7804
+ if (this.canPlayThroughHandler) this.replayElement.removeEventListener("canplaythrough", this.canPlayThroughHandler);
7805
+ const eventName = this.videomail ? "REPLAY_SHOWN" : "PREVIEW_SHOWN";
7806
+ this.canPlayThroughHandler = ()=>{
7807
+ this.canPlayThroughHandler = void 0;
7808
+ this.emit(eventName);
7809
+ };
7810
+ this.replayElement.addEventListener("canplaythrough", this.canPlayThroughHandler, {
7809
7811
  once: true
7810
7812
  });
7811
7813
  }
@@ -7826,36 +7828,20 @@ class Replay extends util_Despot {
7826
7828
  this.replayElement?.setAttribute("controls", "controls");
7827
7829
  this.show(params?.width, params?.height, params?.hasAudio);
7828
7830
  });
7829
- this.replayElement.addEventListener("touchstart", (e)=>{
7830
- e.preventDefault();
7831
- if (this.replayElement?.paused) this.replayElement.play().catch((exc)=>{
7832
- throw error_createError({
7833
- message: "Failed to play replay video while paused upon touchstart event.",
7834
- exc,
7835
- options: this.options
7836
- });
7837
- });
7838
- else this.replayElement?.pause();
7839
- }, {
7840
- passive: true
7841
- });
7842
- this.replayElement.addEventListener("click", (e)=>{
7843
- e.preventDefault();
7844
- if (this.replayElement?.paused) this.replayElement.play().catch((exc)=>{
7845
- throw error_createError({
7846
- message: "Failed to play replay video while paused upon click event.",
7847
- exc,
7848
- options: this.options
7849
- });
7850
- });
7851
- else this.replayElement?.pause();
7852
- });
7831
+ this.replayElement.addEventListener("touchstart", this.togglePlayback);
7832
+ this.replayElement.addEventListener("click", this.togglePlayback);
7853
7833
  }
7854
7834
  this.built = true;
7855
7835
  this.options.logger.debug("Replay: built.");
7856
7836
  }
7857
7837
  unload(params) {
7858
7838
  this.options.logger.debug("Replay: unload()");
7839
+ if (this.canPlayThroughHandler) {
7840
+ this.replayElement?.removeEventListener("canplaythrough", this.canPlayThroughHandler);
7841
+ this.canPlayThroughHandler = void 0;
7842
+ }
7843
+ this.replayElement?.removeEventListener("touchstart", this.togglePlayback);
7844
+ this.replayElement?.removeEventListener("click", this.togglePlayback);
7859
7845
  this.removeAllListeners();
7860
7846
  if (params?.startingOver) this.hide();
7861
7847
  else {
@@ -7898,7 +7884,7 @@ class Replay extends util_Despot {
7898
7884
  let source = this.getVideoSource(type);
7899
7885
  let url = src;
7900
7886
  if (url && bustCache) url += `?${Date.now()}`;
7901
- if (source) if (src) source.setAttribute("src", src);
7887
+ if (source) if (url) source.setAttribute("src", url);
7902
7888
  else source.remove();
7903
7889
  else if (src) {
7904
7890
  const { fps } = this.options.video;
@@ -7962,7 +7948,20 @@ class Replay extends util_Despot {
7962
7948
  return this.replayElement;
7963
7949
  }
7964
7950
  constructor(visuals, options){
7965
- 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);
7951
+ 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)=>{
7952
+ e.preventDefault();
7953
+ if (this.replayElement?.paused) this.replayElement.play().catch((exc)=>{
7954
+ const err = error_createError({
7955
+ message: `Failed to play replay video upon ${e.type} event.`,
7956
+ exc,
7957
+ options: this.options
7958
+ });
7959
+ this.emit("ERROR", {
7960
+ err
7961
+ });
7962
+ });
7963
+ else this.replayElement?.pause();
7964
+ });
7966
7965
  this.visuals = visuals;
7967
7966
  }
7968
7967
  }
@@ -8,6 +8,8 @@ declare class Replay extends Despot {
8
8
  private built;
9
9
  private replayElement?;
10
10
  private videomail?;
11
+ private canPlayThroughHandler?;
12
+ private readonly togglePlayback;
11
13
  constructor(visuals: Visuals, options: VideomailClientOptions);
12
14
  private buildElement;
13
15
  private copyAttributes;
@@ -18,13 +18,14 @@ declare class UserMedia extends Despot {
18
18
  private onLoadedMetaDataReached;
19
19
  private playingPromiseReached;
20
20
  private videoTrackLabel?;
21
+ private readonly outputEvent;
22
+ private readonly handleMediaError;
21
23
  constructor(recorder: Recorder, options: VideomailClientOptions);
22
24
  private attachMediaStream;
23
25
  private setVisualStream;
24
26
  private hasEnded;
25
27
  private hasInvalidDimensions;
26
28
  private logEvent;
27
- private outputEvent;
28
29
  unloadRemainingEventListeners(): void;
29
30
  private audioRecord;
30
31
  init(localMediaStream: MediaStream, videoCallback: () => void, audioCallback: AudioProcessCB, endedEarlyCallback: (err: any) => void, switchingFacingMode?: ConstrainDOMString): void;
package/dist/umd/index.js CHANGED
@@ -10978,7 +10978,7 @@
10978
10978
  var client = __webpack_require__("Q");
10979
10979
  var client_default = /*#__PURE__*/ __webpack_require__.n(client);
10980
10980
  var package_namespaceObject = {
10981
- rE: "15.7.18"
10981
+ rE: "15.7.19"
10982
10982
  };
10983
10983
  function isAudioEnabled(options) {
10984
10984
  return Boolean(options.audio.enabled);
@@ -19020,12 +19020,21 @@
19020
19020
  onLoadedMetaDataReached = false;
19021
19021
  playingPromiseReached = false;
19022
19022
  videoTrackLabel;
19023
+ outputEvent = (e)=>{
19024
+ this.logEvent(e.type, {
19025
+ readyState: this.rawVisualUserMedia?.readyState
19026
+ });
19027
+ this.rawVisualUserMedia?.removeEventListener(e.type, this.outputEvent);
19028
+ };
19029
+ handleMediaError = (event)=>{
19030
+ this.options.logger.warn(`Caught video element error event: ${util_pretty(event)}`);
19031
+ };
19023
19032
  constructor(recorder, options){
19024
19033
  super("UserMedia", options);
19025
19034
  this.recorder = recorder;
19026
19035
  this.rawVisualUserMedia = recorder.getRawVisualUserMedia();
19027
19036
  mediaEvents.forEach((eventName)=>{
19028
- this.rawVisualUserMedia?.addEventListener(eventName, this.outputEvent.bind(this), false);
19037
+ this.rawVisualUserMedia?.addEventListener(eventName, this.outputEvent, false);
19029
19038
  });
19030
19039
  }
19031
19040
  attachMediaStream(stream) {
@@ -19040,8 +19049,10 @@
19040
19049
  setVisualStream(localMediaStream) {
19041
19050
  if (localMediaStream) this.attachMediaStream(localMediaStream);
19042
19051
  else {
19043
- this.rawVisualUserMedia?.removeAttribute("srcObject");
19044
- this.rawVisualUserMedia?.removeAttribute("src");
19052
+ if (this.rawVisualUserMedia) {
19053
+ this.rawVisualUserMedia.srcObject = null;
19054
+ this.rawVisualUserMedia.removeAttribute("src");
19055
+ }
19045
19056
  this.currentVisualStream = void 0;
19046
19057
  }
19047
19058
  }
@@ -19050,23 +19061,18 @@
19050
19061
  return !this.currentVisualStream?.active;
19051
19062
  }
19052
19063
  hasInvalidDimensions() {
19053
- if (this.rawVisualUserMedia?.videoWidth && this.rawVisualUserMedia.videoWidth < 3 || this.rawVisualUserMedia?.height && this.rawVisualUserMedia.height < 3) return true;
19054
- return false;
19064
+ if (!this.rawVisualUserMedia) return false;
19065
+ return this.rawVisualUserMedia.videoWidth < 3 || this.rawVisualUserMedia.videoHeight < 3;
19055
19066
  }
19056
19067
  logEvent(eventType, params) {
19057
19068
  this.options.logger.debug(`UserMedia: ... ${EVENT_ASCII} event ${eventType}: ${util_pretty(params)}`);
19058
19069
  }
19059
- outputEvent(e) {
19060
- this.logEvent(e.type, {
19061
- readyState: this.rawVisualUserMedia?.readyState
19062
- });
19063
- this.rawVisualUserMedia?.removeEventListener(e.type, this.outputEvent.bind(this));
19064
- }
19065
19070
  unloadRemainingEventListeners() {
19066
19071
  this.options.logger.debug("UserMedia: unloadRemainingEventListeners()");
19067
19072
  mediaEvents.forEach((eventName)=>{
19068
- this.rawVisualUserMedia?.removeEventListener(eventName, this.outputEvent.bind(this));
19073
+ this.rawVisualUserMedia?.removeEventListener(eventName, this.outputEvent);
19069
19074
  });
19075
+ this.rawVisualUserMedia?.removeEventListener("error", this.handleMediaError);
19070
19076
  }
19071
19077
  audioRecord(audioCallback) {
19072
19078
  this.removeListener("SENDING_FIRST_FRAME");
@@ -19192,9 +19198,8 @@
19192
19198
  else this.options.logger.debug("UserMedia: detected (but no video tracks exist");
19193
19199
  this.rawVisualUserMedia?.addEventListener("loadedmetadata", onLoadedMetaData);
19194
19200
  this.rawVisualUserMedia?.addEventListener("play", onPlay);
19195
- this.rawVisualUserMedia?.addEventListener("error", (err)=>{
19196
- this.options.logger.warn(`Caught video element error event: ${util_pretty(err)}`);
19197
- });
19201
+ this.rawVisualUserMedia?.removeEventListener("error", this.handleMediaError);
19202
+ this.rawVisualUserMedia?.addEventListener("error", this.handleMediaError);
19198
19203
  this.setVisualStream(localMediaStream);
19199
19204
  play();
19200
19205
  } catch (exc) {
@@ -19207,7 +19212,7 @@
19207
19212
  return this.videoTrackLabel;
19208
19213
  }
19209
19214
  isReady() {
19210
- return Boolean(this.rawVisualUserMedia?.src);
19215
+ return Boolean(this.rawVisualUserMedia?.srcObject || this.rawVisualUserMedia?.currentSrc);
19211
19216
  }
19212
19217
  stop(visualStream, params) {
19213
19218
  try {
@@ -20459,6 +20464,21 @@
20459
20464
  built = false;
20460
20465
  replayElement;
20461
20466
  videomail;
20467
+ canPlayThroughHandler;
20468
+ togglePlayback = (e)=>{
20469
+ e.preventDefault();
20470
+ if (this.replayElement?.paused) this.replayElement.play().catch((exc)=>{
20471
+ const err = error_createError({
20472
+ message: `Failed to play replay video upon ${e.type} event.`,
20473
+ exc,
20474
+ options: this.options
20475
+ });
20476
+ this.emit("ERROR", {
20477
+ err
20478
+ });
20479
+ });
20480
+ else this.replayElement?.pause();
20481
+ };
20462
20482
  constructor(visuals, options){
20463
20483
  super("Replay", options);
20464
20484
  this.visuals = visuals;
@@ -20536,14 +20556,13 @@
20536
20556
  if (hasAudio) this.replayElement.volume = 1;
20537
20557
  else if (!isAudioEnabled(this.options)) this.replayElement.setAttribute("muted", "true");
20538
20558
  this.replayElement.load();
20539
- if (this.videomail) this.replayElement.addEventListener("canplaythrough", ()=>{
20540
- this.emit("REPLAY_SHOWN");
20541
- }, {
20542
- once: true
20543
- });
20544
- else this.replayElement.addEventListener("canplaythrough", ()=>{
20545
- this.emit("PREVIEW_SHOWN");
20546
- }, {
20559
+ if (this.canPlayThroughHandler) this.replayElement.removeEventListener("canplaythrough", this.canPlayThroughHandler);
20560
+ const eventName = this.videomail ? "REPLAY_SHOWN" : "PREVIEW_SHOWN";
20561
+ this.canPlayThroughHandler = ()=>{
20562
+ this.canPlayThroughHandler = void 0;
20563
+ this.emit(eventName);
20564
+ };
20565
+ this.replayElement.addEventListener("canplaythrough", this.canPlayThroughHandler, {
20547
20566
  once: true
20548
20567
  });
20549
20568
  }
@@ -20564,36 +20583,20 @@
20564
20583
  this.replayElement?.setAttribute("controls", "controls");
20565
20584
  this.show(params?.width, params?.height, params?.hasAudio);
20566
20585
  });
20567
- this.replayElement.addEventListener("touchstart", (e)=>{
20568
- e.preventDefault();
20569
- if (this.replayElement?.paused) this.replayElement.play().catch((exc)=>{
20570
- throw error_createError({
20571
- message: "Failed to play replay video while paused upon touchstart event.",
20572
- exc,
20573
- options: this.options
20574
- });
20575
- });
20576
- else this.replayElement?.pause();
20577
- }, {
20578
- passive: true
20579
- });
20580
- this.replayElement.addEventListener("click", (e)=>{
20581
- e.preventDefault();
20582
- if (this.replayElement?.paused) this.replayElement.play().catch((exc)=>{
20583
- throw error_createError({
20584
- message: "Failed to play replay video while paused upon click event.",
20585
- exc,
20586
- options: this.options
20587
- });
20588
- });
20589
- else this.replayElement?.pause();
20590
- });
20586
+ this.replayElement.addEventListener("touchstart", this.togglePlayback);
20587
+ this.replayElement.addEventListener("click", this.togglePlayback);
20591
20588
  }
20592
20589
  this.built = true;
20593
20590
  this.options.logger.debug("Replay: built.");
20594
20591
  }
20595
20592
  unload(params) {
20596
20593
  this.options.logger.debug("Replay: unload()");
20594
+ if (this.canPlayThroughHandler) {
20595
+ this.replayElement?.removeEventListener("canplaythrough", this.canPlayThroughHandler);
20596
+ this.canPlayThroughHandler = void 0;
20597
+ }
20598
+ this.replayElement?.removeEventListener("touchstart", this.togglePlayback);
20599
+ this.replayElement?.removeEventListener("click", this.togglePlayback);
20597
20600
  this.removeAllListeners();
20598
20601
  if (params?.startingOver) this.hide();
20599
20602
  else {
@@ -20636,7 +20639,7 @@
20636
20639
  let source = this.getVideoSource(type);
20637
20640
  let url = src;
20638
20641
  if (url && bustCache) url += `?${Date.now()}`;
20639
- if (source) if (src) source.setAttribute("src", src);
20642
+ if (source) if (url) source.setAttribute("src", url);
20640
20643
  else source.remove();
20641
20644
  else if (src) {
20642
20645
  const { fps } = this.options.video;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "videomail-client",
3
- "version": "15.7.18",
3
+ "version": "15.7.19",
4
4
  "description": "A wicked npm package to record videos directly in the browser, for Deaf and Sign Language!",
5
5
  "keywords": [
6
6
  "webcam",