@besovideo/webrtc-player 0.9.84 → 0.9.86

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.
@@ -117,7 +117,7 @@ var bvPlayerCore = (() => {
117
117
  var define_processenv_default;
118
118
  var init_define_processenv = __esm({
119
119
  "<define:processenv>"() {
120
- define_processenv_default = { NODE_ENV: "production", SH_LIB_NAME: "@besovideo/webrtc-player", SH_LIB_VERSION: "0.9.84", PROJECT_NAMESPACE: "bvplayer" };
120
+ define_processenv_default = { NODE_ENV: "production", SH_LIB_NAME: "@besovideo/webrtc-player", SH_LIB_VERSION: "0.9.86", PROJECT_NAMESPACE: "bvplayer" };
121
121
  }
122
122
  });
123
123
 
@@ -13416,6 +13416,7 @@ If you want to allow non-zero first timestamps, set firstTimestampBehavior: 'per
13416
13416
  };
13417
13417
  var Events = class {
13418
13418
  constructor() {
13419
+ this.isDisable = false;
13419
13420
  this._notifier = new Notifier();
13420
13421
  }
13421
13422
  addEventListener(name, callBack) {
@@ -13433,11 +13434,22 @@ If you want to allow non-zero first timestamps, set firstTimestampBehavior: 'per
13433
13434
  }
13434
13435
  dispatch(name, event) {
13435
13436
  var _a;
13436
- (_a = this._notifier) == null ? void 0 : _a.publish(name, event);
13437
+ if (!this.isDisable) {
13438
+ (_a = this._notifier) == null ? void 0 : _a.publish(name, event);
13439
+ }
13437
13440
  }
13438
13441
  dispatchSync(name, event) {
13439
13442
  return __async(this, null, function* () {
13440
- yield this._notifier.publishSync(name, event);
13443
+ if (!this.isDisable) {
13444
+ yield this._notifier.publishSync(name, event);
13445
+ }
13446
+ });
13447
+ }
13448
+ noDispathHandle(handle2) {
13449
+ return __async(this, null, function* () {
13450
+ this.isDisable = true;
13451
+ yield handle2();
13452
+ this.isDisable = false;
13441
13453
  });
13442
13454
  }
13443
13455
  };
@@ -21618,6 +21630,10 @@ registerProcessor('bv-audio-processor', BVAudioProcessor);
21618
21630
  sampleRate: this.config.sampleRate
21619
21631
  }).then((stream) => {
21620
21632
  this.audioInput = this.context.createMediaStreamSource(stream);
21633
+ this.audioInput.releaseStream = () => {
21634
+ delete this.audioInput.releaseStream;
21635
+ stream.getTracks().forEach((item) => item.stop());
21636
+ };
21621
21637
  }, (error2) => {
21622
21638
  console.error(error2);
21623
21639
  }).then(() => {
@@ -21634,6 +21650,9 @@ registerProcessor('bv-audio-processor', BVAudioProcessor);
21634
21650
  this.recorder.disconnect();
21635
21651
  if (this.context)
21636
21652
  this.context.close();
21653
+ if (this.audioInput) {
21654
+ this.audioInput.releaseStream && this.audioInput.releaseStream();
21655
+ }
21637
21656
  };
21638
21657
  BVPcmRecorder.prototype.init = function() {
21639
21658
  return __async(this, null, function* () {
@@ -22300,7 +22319,9 @@ registerProcessor('bv-audio-processor', BVAudioProcessor);
22300
22319
  open(muted = false) {
22301
22320
  return __async(this, null, function* () {
22302
22321
  logger_default.debug("BvWebrtc open");
22303
- yield this.close();
22322
+ yield this.noDispathHandle(() => __async(this, null, function* () {
22323
+ yield this.close();
22324
+ }));
22304
22325
  this.player.mask.visible = false;
22305
22326
  this.player.mask.text = t("connecting");
22306
22327
  this.player.mute(!!muted);
@@ -22435,12 +22456,16 @@ registerProcessor('bv-audio-processor', BVAudioProcessor);
22435
22456
  sdpFetcher,
22436
22457
  container
22437
22458
  );
22438
- bvInstance.addEventListener("close", () => {
22439
- onClose && onClose();
22440
- });
22441
- bvInstance.addEventListener("destroy", () => {
22459
+ const handleDestory = () => {
22460
+ bvInstance.removeEventListener("destroy", handleDestory);
22442
22461
  onDestroy2 && onDestroy2();
22443
- });
22462
+ };
22463
+ bvInstance.addEventListener("destroy", handleDestory);
22464
+ const handleClose = () => {
22465
+ bvInstance.removeEventListener("close", handleClose);
22466
+ onClose && onClose();
22467
+ };
22468
+ bvInstance.addEventListener("close", handleClose);
22444
22469
  const instance2 = {
22445
22470
  open: () => __async(void 0, null, function* () {
22446
22471
  logger_default.debug("BvWebrtc open");
package/dist/main.es.js CHANGED
@@ -111,7 +111,7 @@ var __async = (__this, __arguments, generator) => {
111
111
  var define_processenv_default;
112
112
  var init_define_processenv = __esm({
113
113
  "<define:processenv>"() {
114
- define_processenv_default = { NODE_ENV: "production", SH_LIB_NAME: "@besovideo/webrtc-player", SH_LIB_VERSION: "0.9.84", PROJECT_NAMESPACE: "bvplayer" };
114
+ define_processenv_default = { NODE_ENV: "production", SH_LIB_NAME: "@besovideo/webrtc-player", SH_LIB_VERSION: "0.9.86", PROJECT_NAMESPACE: "bvplayer" };
115
115
  }
116
116
  });
117
117
 
@@ -13400,6 +13400,7 @@ var IDataHandle = class {
13400
13400
  };
13401
13401
  var Events = class {
13402
13402
  constructor() {
13403
+ this.isDisable = false;
13403
13404
  this._notifier = new Notifier();
13404
13405
  }
13405
13406
  addEventListener(name, callBack) {
@@ -13417,11 +13418,22 @@ var Events = class {
13417
13418
  }
13418
13419
  dispatch(name, event) {
13419
13420
  var _a;
13420
- (_a = this._notifier) == null ? void 0 : _a.publish(name, event);
13421
+ if (!this.isDisable) {
13422
+ (_a = this._notifier) == null ? void 0 : _a.publish(name, event);
13423
+ }
13421
13424
  }
13422
13425
  dispatchSync(name, event) {
13423
13426
  return __async(this, null, function* () {
13424
- yield this._notifier.publishSync(name, event);
13427
+ if (!this.isDisable) {
13428
+ yield this._notifier.publishSync(name, event);
13429
+ }
13430
+ });
13431
+ }
13432
+ noDispathHandle(handle2) {
13433
+ return __async(this, null, function* () {
13434
+ this.isDisable = true;
13435
+ yield handle2();
13436
+ this.isDisable = false;
13425
13437
  });
13426
13438
  }
13427
13439
  };
@@ -21602,6 +21614,10 @@ BVPcmRecorder.prototype.start = function() {
21602
21614
  sampleRate: this.config.sampleRate
21603
21615
  }).then((stream) => {
21604
21616
  this.audioInput = this.context.createMediaStreamSource(stream);
21617
+ this.audioInput.releaseStream = () => {
21618
+ delete this.audioInput.releaseStream;
21619
+ stream.getTracks().forEach((item) => item.stop());
21620
+ };
21605
21621
  }, (error2) => {
21606
21622
  console.error(error2);
21607
21623
  }).then(() => {
@@ -21618,6 +21634,9 @@ BVPcmRecorder.prototype.stop = function() {
21618
21634
  this.recorder.disconnect();
21619
21635
  if (this.context)
21620
21636
  this.context.close();
21637
+ if (this.audioInput) {
21638
+ this.audioInput.releaseStream && this.audioInput.releaseStream();
21639
+ }
21621
21640
  };
21622
21641
  BVPcmRecorder.prototype.init = function() {
21623
21642
  return __async(this, null, function* () {
@@ -22284,7 +22303,9 @@ var BvWebrtcInstance = class extends CommonInstance {
22284
22303
  open(muted = false) {
22285
22304
  return __async(this, null, function* () {
22286
22305
  logger_default.debug("BvWebrtc open");
22287
- yield this.close();
22306
+ yield this.noDispathHandle(() => __async(this, null, function* () {
22307
+ yield this.close();
22308
+ }));
22288
22309
  this.player.mask.visible = false;
22289
22310
  this.player.mask.text = t("connecting");
22290
22311
  this.player.mute(!!muted);
@@ -22419,12 +22440,16 @@ var BvWebrtc = (props) => {
22419
22440
  sdpFetcher,
22420
22441
  container
22421
22442
  );
22422
- bvInstance.addEventListener("close", () => {
22423
- onClose && onClose();
22424
- });
22425
- bvInstance.addEventListener("destroy", () => {
22443
+ const handleDestory = () => {
22444
+ bvInstance.removeEventListener("destroy", handleDestory);
22426
22445
  onDestroy2 && onDestroy2();
22427
- });
22446
+ };
22447
+ bvInstance.addEventListener("destroy", handleDestory);
22448
+ const handleClose = () => {
22449
+ bvInstance.removeEventListener("close", handleClose);
22450
+ onClose && onClose();
22451
+ };
22452
+ bvInstance.addEventListener("close", handleClose);
22428
22453
  const instance2 = {
22429
22454
  open: () => __async(void 0, null, function* () {
22430
22455
  logger_default.debug("BvWebrtc open");
@@ -53,6 +53,8 @@ export declare class Events<M extends IEventMap> {
53
53
  clearEventListener<K extends keyof M>(name?: K): void;
54
54
  dispatch<K extends keyof M>(name: K, event?: M[K]): void;
55
55
  dispatchSync<K extends keyof M>(name: K, event?: M[K]): Promise<void>;
56
+ private isDisable;
57
+ noDispathHandle(handle: () => (Promise<void> | void)): Promise<void>;
56
58
  }
57
59
  export declare class DomEventStore {
58
60
  private _store;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@besovideo/webrtc-player",
3
- "version": "0.9.84",
3
+ "version": "0.9.86",
4
4
  "description": "@besovideo/webrtc-player desc",
5
5
  "type": "module",
6
6
  "types": "./dist/types/main.d.ts",