@besovideo/webrtc-player 0.8.40 → 0.8.42

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.
@@ -77,7 +77,7 @@ var bvPlayerCore = (() => {
77
77
  };
78
78
 
79
79
  // <define:process.env>
80
- var define_process_env_default = { NODE_ENV: "production", SH_LIB_NAME: "@besovideo/webrtc-player", SH_LIB_VERSION: "0.8.39", PROJECT_NAMESPACE: "bvplayer" };
80
+ var define_process_env_default = { NODE_ENV: "production", SH_LIB_NAME: "@besovideo/webrtc-player", SH_LIB_VERSION: "0.8.41", PROJECT_NAMESPACE: "bvplayer" };
81
81
 
82
82
  // node_modules/@shirtiny/logger/dist/main.es.js
83
83
  var _ = Object.defineProperty;
@@ -4431,10 +4431,12 @@ var bvPlayerCore = (() => {
4431
4431
  this._notifier.unSubscribe(name, callBack);
4432
4432
  }
4433
4433
  clearEventListener(name) {
4434
- this._notifier.clear(name);
4434
+ var _a;
4435
+ (_a = this._notifier) == null ? void 0 : _a.clear(name);
4435
4436
  }
4436
4437
  dispatch(name, event) {
4437
- this._notifier.publish(name, event);
4438
+ var _a;
4439
+ (_a = this._notifier) == null ? void 0 : _a.publish(name, event);
4438
4440
  }
4439
4441
  dispatchSync(name, event) {
4440
4442
  return __async(this, null, function* () {
@@ -4723,9 +4725,10 @@ var bvPlayerCore = (() => {
4723
4725
  yield screenshotByCanvas(canvas, fileName);
4724
4726
  });
4725
4727
  var record = (element, stream, fileName = `record_${Date.now()}`) => {
4726
- const options = { mimeType: "video/webm; codecs=vp9" };
4727
4728
  try {
4728
4729
  const mediaStream = stream || element.captureStream(25);
4730
+ const hasVideo = mediaStream.getVideoTracks().length > 0;
4731
+ const options = hasVideo ? { mimeType: "video/webm; codecs=vp9,opus" } : { mimeType: "audio/webm; codecs=opus" };
4729
4732
  logger_default.info("\u6355\u83B7\u7684\u6D41\u548C\u5F55\u5236\u914D\u7F6E\u9879\uFF1A", mediaStream, options);
4730
4733
  let recordedChunks = [];
4731
4734
  const mediaRecorder = new MediaRecorder(mediaStream, options);
@@ -4977,6 +4980,9 @@ var bvPlayerCore = (() => {
4977
4980
  this._canvasEl = newEl;
4978
4981
  this._mediaStream = null;
4979
4982
  }
4983
+ setCaptureProvider(capture) {
4984
+ this._captureStream = capture;
4985
+ }
4980
4986
  play() {
4981
4987
  return __async(this, null, function* () {
4982
4988
  const el = this._videoEl;
@@ -5014,7 +5020,12 @@ var bvPlayerCore = (() => {
5014
5020
  if (this._recorder) {
5015
5021
  this.recordStop();
5016
5022
  }
5017
- const streamEl = this.canvasEnabled ? this._canvasEl : this._videoEl;
5023
+ const captureStream = () => {
5024
+ if (this._captureStream) {
5025
+ return this._captureStream();
5026
+ }
5027
+ };
5028
+ const streamEl = this.canvasEnabled ? { captureStream } : this._videoEl;
5018
5029
  if (!streamEl)
5019
5030
  return;
5020
5031
  const fileName = this._genFileName("record");
@@ -9563,6 +9574,7 @@ ${event.candidate ? event.candidate.candidate : "(null)"}`
9563
9574
  constructor(options) {
9564
9575
  super(PLUGIN_NAME_PLAYER, "div");
9565
9576
  this._lastTotalReceivedBytes = 0;
9577
+ this._isInClose = false;
9566
9578
  this._video = new video_default({
9567
9579
  puOptions: options == null ? void 0 : options.puOptions
9568
9580
  });
@@ -9685,6 +9697,7 @@ ${event.candidate ? event.candidate.candidate : "(null)"}`
9685
9697
  prepareWebrtc() {
9686
9698
  return __async(this, null, function* () {
9687
9699
  var _a;
9700
+ this._isInClose = false;
9688
9701
  if (this._mode !== "plugin" /* PLUGIN */)
9689
9702
  return;
9690
9703
  logger_default.debug("PuPlayer Plugin prepareWebrtc");
@@ -9714,12 +9727,17 @@ ${event.candidate ? event.candidate.candidate : "(null)"}`
9714
9727
  }
9715
9728
  close() {
9716
9729
  return __async(this, null, function* () {
9717
- yield this.dispatchSync("close");
9718
- this.closeWebrtc();
9730
+ if (!this._isInClose) {
9731
+ this._isInClose = true;
9732
+ yield this.dispatchSync("close");
9733
+ this.closeWebrtc();
9734
+ }
9719
9735
  });
9720
9736
  }
9721
9737
  beforeDestroy() {
9722
- this.close();
9738
+ if (!this._isInClose) {
9739
+ this.close();
9740
+ }
9723
9741
  }
9724
9742
  // 应用和加载播放器设置
9725
9743
  loadPlayerConfig() {
@@ -9833,6 +9851,16 @@ ${event.candidate ? event.candidate.candidate : "(null)"}`
9833
9851
  }
9834
9852
  };
9835
9853
  updateVolumeButton(true);
9854
+ function DisplayVolumn(volume) {
9855
+ const button = panel == null ? void 0 : panel.controller.VolumeButton;
9856
+ if (panel && button) {
9857
+ const volumeSlider2 = panel.controller.VolumeSlider;
9858
+ if (volumeSlider2) {
9859
+ volumeSlider2.percent = volume;
9860
+ }
9861
+ volume == 0 ? button.Children = /* @__PURE__ */ jsx_default.h(icons_default.Volume, { off: true }) : button.Children = /* @__PURE__ */ jsx_default.h(icons_default.Volume, null);
9862
+ }
9863
+ }
9836
9864
  panel.controller.addEventListener("volume", () => updateVolumeButton());
9837
9865
  const volumeSlider = panel.controller.VolumeSlider;
9838
9866
  if (volumeSlider) {
@@ -9841,6 +9869,7 @@ ${event.candidate ? event.candidate.candidate : "(null)"}`
9841
9869
  panel.controller.activeVolume();
9842
9870
  this.video.volume = Number(e == null ? void 0 : e.percent);
9843
9871
  volumeSlider.percent = this.video.volume;
9872
+ DisplayVolumn(Number(e == null ? void 0 : e.percent));
9844
9873
  });
9845
9874
  }
9846
9875
  }
@@ -9886,7 +9915,9 @@ ${event.candidate ? event.candidate.candidate : "(null)"}`
9886
9915
  peerConnection: (_a = this._webrtcConnect) == null ? void 0 : _a.pc
9887
9916
  });
9888
9917
  this._webrtcConnect = null;
9889
- this._video.srcObject = null;
9918
+ if (this._video) {
9919
+ this._video.srcObject = null;
9920
+ }
9890
9921
  }
9891
9922
  refreshInfoModal() {
9892
9923
  return __async(this, null, function* () {
@@ -9964,8 +9995,9 @@ ${event.candidate ? event.candidate.candidate : "(null)"}`
9964
9995
  }
9965
9996
  });
9966
9997
  }
9967
- enableCanvas(enable) {
9998
+ enableCanvas(enable, captureStream) {
9968
9999
  this._video.canvasEnabled = !!enable;
10000
+ this._video.setCaptureProvider(captureStream);
9969
10001
  }
9970
10002
  replaceCanvas(canvas) {
9971
10003
  this._video.setCanvasEl(canvas);
@@ -10200,6 +10232,38 @@ ${event.candidate ? event.candidate.candidate : "(null)"}`
10200
10232
  this.init_callback();
10201
10233
  }
10202
10234
  }
10235
+ captureStream() {
10236
+ const audioTracks = [];
10237
+ const videoTracks = [];
10238
+ if (this.audioPlayer) {
10239
+ const audioStream = this.audioPlayer.getAudioStream();
10240
+ audioStream == null ? void 0 : audioStream.getAudioTracks().forEach((track) => {
10241
+ audioTracks.push(track);
10242
+ });
10243
+ }
10244
+ let hasVideo = (this.mediaDir & 2) == 2;
10245
+ if (hasVideo) {
10246
+ if (this.videoInfo.webcodecs) {
10247
+ if (this.videoPlayer && this.videoPlayer.mContainer.srcObject) {
10248
+ const mediaStram = this.videoPlayer.mContainer.srcObject;
10249
+ if (mediaStram) {
10250
+ mediaStram == null ? void 0 : mediaStram.getAudioTracks().forEach((track) => {
10251
+ audioTracks.push(track);
10252
+ });
10253
+ mediaStram == null ? void 0 : mediaStram.getVideoTracks().forEach((track) => {
10254
+ videoTracks.push(track);
10255
+ });
10256
+ }
10257
+ }
10258
+ } else if (this.canvas) {
10259
+ const canvasStream = this.canvas.captureStream(24);
10260
+ canvasStream == null ? void 0 : canvasStream.getVideoTracks().forEach((track) => {
10261
+ videoTracks.push(track);
10262
+ });
10263
+ }
10264
+ }
10265
+ return new MediaStream([...audioTracks, ...videoTracks]);
10266
+ }
10203
10267
  _OnOpen({ hplayer }) {
10204
10268
  this.hplayer = hplayer;
10205
10269
  console.log("open player ok! " + hplayer);
@@ -10338,6 +10402,7 @@ ${event.candidate ? event.candidate.candidate : "(null)"}`
10338
10402
  this.interval = setInterval(this.flush, this.option.flushingTime);
10339
10403
  this.maxValue = this.getMaxValue();
10340
10404
  this.typedArray = this.getTypedArray();
10405
+ this.audioStream = null;
10341
10406
  this.createContext();
10342
10407
  };
10343
10408
  BVPCMPlayer.prototype.getMaxValue = function() {
@@ -10358,12 +10423,19 @@ ${event.candidate ? event.candidate.candidate : "(null)"}`
10358
10423
  };
10359
10424
  return typedArrays[this.option.encoding] ? typedArrays[this.option.encoding] : typedArrays["s16"];
10360
10425
  };
10426
+ BVPCMPlayer.prototype.getAudioStream = function() {
10427
+ return this.audioStream;
10428
+ };
10361
10429
  BVPCMPlayer.prototype.createContext = function() {
10362
10430
  this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
10363
10431
  this.audioCtx.resume();
10364
10432
  this.gainNode = this.audioCtx.createGain();
10365
10433
  this.gainNode.gain.value = 1;
10366
- this.gainNode.connect(this.audioCtx.destination);
10434
+ const dest = this.audioCtx.createMediaStreamDestination();
10435
+ this.gainNode.connect(dest);
10436
+ const videoEle = document.createElement("video");
10437
+ videoEle.srcObject = this.audioStream = dest.stream;
10438
+ videoEle.play();
10367
10439
  this.startTime = this.audioCtx.currentTime;
10368
10440
  };
10369
10441
  BVPCMPlayer.prototype.isTypedArray = function(data) {
@@ -10392,6 +10464,10 @@ ${event.candidate ? event.candidate.candidate : "(null)"}`
10392
10464
  if (this.interval) {
10393
10465
  clearInterval(this.interval);
10394
10466
  }
10467
+ if (this.audioStream) {
10468
+ this.audioStream.getAudioTracks().forEach((item) => item.stop());
10469
+ this.audioStream = null;
10470
+ }
10395
10471
  this.samples = null;
10396
10472
  this.audioCtx.close();
10397
10473
  this.audioCtx = null;
@@ -11973,7 +12049,7 @@ ${event.candidate ? event.candidate.candidate : "(null)"}`
11973
12049
  case "f32-planar":
11974
12050
  tempArray = new Float32Array(dataArray.buffer);
11975
12051
  byteCount = 4;
11976
- iConstMaxData = 2147483647;
12052
+ iConstMaxData = 1;
11977
12053
  break;
11978
12054
  }
11979
12055
  const iPastMs = 1e3 / sampleRate * dataArray.length / byteCount;
@@ -12316,10 +12392,23 @@ ${event.candidate ? event.candidate.candidate : "(null)"}`
12316
12392
  player.mikeBtn.intercom = intercom == null ? void 0 : intercom.instance;
12317
12393
  } catch (e) {
12318
12394
  try {
12395
+ let DisplayVolumn2 = function(volume) {
12396
+ var _a3;
12397
+ const button = (_a3 = player.panel) == null ? void 0 : _a3.controller.VolumeButton;
12398
+ if (player.panel && button && hplayer) {
12399
+ const volumeSlider2 = player.panel.controller.VolumeSlider;
12400
+ if (volumeSlider2) {
12401
+ volumeSlider2.percent = hplayer.getVolume();
12402
+ }
12403
+ volume == 0 ? button.Children = /* @__PURE__ */ jsx_default.h(icons_default.Volume, { off: true }) : button.Children = /* @__PURE__ */ jsx_default.h(icons_default.Volume, null);
12404
+ }
12405
+ };
12406
+ var DisplayVolumn = DisplayVolumn2;
12319
12407
  logger_default.debug("error\u7684\u7C7B\u578B", e.name, e instanceof OpenDialogError);
12320
12408
  if (e instanceof OpenDialogError || protocol === "webrtc")
12321
12409
  throw e;
12322
- player.enableCanvas(true);
12410
+ const captureStream = () => hplayer == null ? void 0 : hplayer.captureStream();
12411
+ player.enableCanvas(true, captureStream);
12323
12412
  this.protocol = "ws-bvrtc";
12324
12413
  hplayer = new BVMedia();
12325
12414
  if (noVideoRendeAudioWaveform && !defaultMediaOption.video) {
@@ -12416,7 +12505,7 @@ ${event.candidate ? event.candidate.candidate : "(null)"}`
12416
12505
  const audioList = [
12417
12506
  {
12418
12507
  label: t("codec"),
12419
- value: hplayer.getAudioInfo().codec
12508
+ value: hplayer.getAudioInfo().codec + (hplayer.getAudioInfo().webcodecs ? "(webcodecs)" : "")
12420
12509
  },
12421
12510
  {
12422
12511
  label: t("sample-accuracy"),
@@ -12495,6 +12584,7 @@ ${event.candidate ? event.candidate.candidate : "(null)"}`
12495
12584
  (_a3 = player.panel) == null ? void 0 : _a3.controller.activeVolume();
12496
12585
  hplayer.setVolume(Number(e2 == null ? void 0 : e2.percent));
12497
12586
  volumeSlider.percent = hplayer.getVolume();
12587
+ DisplayVolumn2(Number(e2 == null ? void 0 : e2.percent));
12498
12588
  });
12499
12589
  }
12500
12590
  if (player.mikeBtn)
package/dist/main.es.js CHANGED
@@ -71,7 +71,7 @@ var __async = (__this, __arguments, generator) => {
71
71
  };
72
72
 
73
73
  // <define:process.env>
74
- var define_process_env_default = { NODE_ENV: "production", SH_LIB_NAME: "@besovideo/webrtc-player", SH_LIB_VERSION: "0.8.39", PROJECT_NAMESPACE: "bvplayer" };
74
+ var define_process_env_default = { NODE_ENV: "production", SH_LIB_NAME: "@besovideo/webrtc-player", SH_LIB_VERSION: "0.8.41", PROJECT_NAMESPACE: "bvplayer" };
75
75
 
76
76
  // node_modules/@shirtiny/logger/dist/main.es.js
77
77
  var _ = Object.defineProperty;
@@ -4415,10 +4415,12 @@ var Events = class {
4415
4415
  this._notifier.unSubscribe(name, callBack);
4416
4416
  }
4417
4417
  clearEventListener(name) {
4418
- this._notifier.clear(name);
4418
+ var _a;
4419
+ (_a = this._notifier) == null ? void 0 : _a.clear(name);
4419
4420
  }
4420
4421
  dispatch(name, event) {
4421
- this._notifier.publish(name, event);
4422
+ var _a;
4423
+ (_a = this._notifier) == null ? void 0 : _a.publish(name, event);
4422
4424
  }
4423
4425
  dispatchSync(name, event) {
4424
4426
  return __async(this, null, function* () {
@@ -4707,9 +4709,10 @@ var screenshot = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (videoEl,
4707
4709
  yield screenshotByCanvas(canvas, fileName);
4708
4710
  });
4709
4711
  var record = (element, stream, fileName = `record_${Date.now()}`) => {
4710
- const options = { mimeType: "video/webm; codecs=vp9" };
4711
4712
  try {
4712
4713
  const mediaStream = stream || element.captureStream(25);
4714
+ const hasVideo = mediaStream.getVideoTracks().length > 0;
4715
+ const options = hasVideo ? { mimeType: "video/webm; codecs=vp9,opus" } : { mimeType: "audio/webm; codecs=opus" };
4713
4716
  logger_default.info("\u6355\u83B7\u7684\u6D41\u548C\u5F55\u5236\u914D\u7F6E\u9879\uFF1A", mediaStream, options);
4714
4717
  let recordedChunks = [];
4715
4718
  const mediaRecorder = new MediaRecorder(mediaStream, options);
@@ -4961,6 +4964,9 @@ var VideoPlugin = class extends Plugin {
4961
4964
  this._canvasEl = newEl;
4962
4965
  this._mediaStream = null;
4963
4966
  }
4967
+ setCaptureProvider(capture) {
4968
+ this._captureStream = capture;
4969
+ }
4964
4970
  play() {
4965
4971
  return __async(this, null, function* () {
4966
4972
  const el = this._videoEl;
@@ -4998,7 +5004,12 @@ var VideoPlugin = class extends Plugin {
4998
5004
  if (this._recorder) {
4999
5005
  this.recordStop();
5000
5006
  }
5001
- const streamEl = this.canvasEnabled ? this._canvasEl : this._videoEl;
5007
+ const captureStream = () => {
5008
+ if (this._captureStream) {
5009
+ return this._captureStream();
5010
+ }
5011
+ };
5012
+ const streamEl = this.canvasEnabled ? { captureStream } : this._videoEl;
5002
5013
  if (!streamEl)
5003
5014
  return;
5004
5015
  const fileName = this._genFileName("record");
@@ -9547,6 +9558,7 @@ var PlayerPlugin = class extends Plugin {
9547
9558
  constructor(options) {
9548
9559
  super(PLUGIN_NAME_PLAYER, "div");
9549
9560
  this._lastTotalReceivedBytes = 0;
9561
+ this._isInClose = false;
9550
9562
  this._video = new video_default({
9551
9563
  puOptions: options == null ? void 0 : options.puOptions
9552
9564
  });
@@ -9669,6 +9681,7 @@ var PlayerPlugin = class extends Plugin {
9669
9681
  prepareWebrtc() {
9670
9682
  return __async(this, null, function* () {
9671
9683
  var _a;
9684
+ this._isInClose = false;
9672
9685
  if (this._mode !== "plugin" /* PLUGIN */)
9673
9686
  return;
9674
9687
  logger_default.debug("PuPlayer Plugin prepareWebrtc");
@@ -9698,12 +9711,17 @@ var PlayerPlugin = class extends Plugin {
9698
9711
  }
9699
9712
  close() {
9700
9713
  return __async(this, null, function* () {
9701
- yield this.dispatchSync("close");
9702
- this.closeWebrtc();
9714
+ if (!this._isInClose) {
9715
+ this._isInClose = true;
9716
+ yield this.dispatchSync("close");
9717
+ this.closeWebrtc();
9718
+ }
9703
9719
  });
9704
9720
  }
9705
9721
  beforeDestroy() {
9706
- this.close();
9722
+ if (!this._isInClose) {
9723
+ this.close();
9724
+ }
9707
9725
  }
9708
9726
  // 应用和加载播放器设置
9709
9727
  loadPlayerConfig() {
@@ -9817,6 +9835,16 @@ var PlayerPlugin = class extends Plugin {
9817
9835
  }
9818
9836
  };
9819
9837
  updateVolumeButton(true);
9838
+ function DisplayVolumn(volume) {
9839
+ const button = panel == null ? void 0 : panel.controller.VolumeButton;
9840
+ if (panel && button) {
9841
+ const volumeSlider2 = panel.controller.VolumeSlider;
9842
+ if (volumeSlider2) {
9843
+ volumeSlider2.percent = volume;
9844
+ }
9845
+ volume == 0 ? button.Children = /* @__PURE__ */ jsx_default.h(icons_default.Volume, { off: true }) : button.Children = /* @__PURE__ */ jsx_default.h(icons_default.Volume, null);
9846
+ }
9847
+ }
9820
9848
  panel.controller.addEventListener("volume", () => updateVolumeButton());
9821
9849
  const volumeSlider = panel.controller.VolumeSlider;
9822
9850
  if (volumeSlider) {
@@ -9825,6 +9853,7 @@ var PlayerPlugin = class extends Plugin {
9825
9853
  panel.controller.activeVolume();
9826
9854
  this.video.volume = Number(e == null ? void 0 : e.percent);
9827
9855
  volumeSlider.percent = this.video.volume;
9856
+ DisplayVolumn(Number(e == null ? void 0 : e.percent));
9828
9857
  });
9829
9858
  }
9830
9859
  }
@@ -9870,7 +9899,9 @@ var PlayerPlugin = class extends Plugin {
9870
9899
  peerConnection: (_a = this._webrtcConnect) == null ? void 0 : _a.pc
9871
9900
  });
9872
9901
  this._webrtcConnect = null;
9873
- this._video.srcObject = null;
9902
+ if (this._video) {
9903
+ this._video.srcObject = null;
9904
+ }
9874
9905
  }
9875
9906
  refreshInfoModal() {
9876
9907
  return __async(this, null, function* () {
@@ -9948,8 +9979,9 @@ var PlayerPlugin = class extends Plugin {
9948
9979
  }
9949
9980
  });
9950
9981
  }
9951
- enableCanvas(enable) {
9982
+ enableCanvas(enable, captureStream) {
9952
9983
  this._video.canvasEnabled = !!enable;
9984
+ this._video.setCaptureProvider(captureStream);
9953
9985
  }
9954
9986
  replaceCanvas(canvas) {
9955
9987
  this._video.setCanvasEl(canvas);
@@ -10184,6 +10216,38 @@ var BVMedia = class {
10184
10216
  this.init_callback();
10185
10217
  }
10186
10218
  }
10219
+ captureStream() {
10220
+ const audioTracks = [];
10221
+ const videoTracks = [];
10222
+ if (this.audioPlayer) {
10223
+ const audioStream = this.audioPlayer.getAudioStream();
10224
+ audioStream == null ? void 0 : audioStream.getAudioTracks().forEach((track) => {
10225
+ audioTracks.push(track);
10226
+ });
10227
+ }
10228
+ let hasVideo = (this.mediaDir & 2) == 2;
10229
+ if (hasVideo) {
10230
+ if (this.videoInfo.webcodecs) {
10231
+ if (this.videoPlayer && this.videoPlayer.mContainer.srcObject) {
10232
+ const mediaStram = this.videoPlayer.mContainer.srcObject;
10233
+ if (mediaStram) {
10234
+ mediaStram == null ? void 0 : mediaStram.getAudioTracks().forEach((track) => {
10235
+ audioTracks.push(track);
10236
+ });
10237
+ mediaStram == null ? void 0 : mediaStram.getVideoTracks().forEach((track) => {
10238
+ videoTracks.push(track);
10239
+ });
10240
+ }
10241
+ }
10242
+ } else if (this.canvas) {
10243
+ const canvasStream = this.canvas.captureStream(24);
10244
+ canvasStream == null ? void 0 : canvasStream.getVideoTracks().forEach((track) => {
10245
+ videoTracks.push(track);
10246
+ });
10247
+ }
10248
+ }
10249
+ return new MediaStream([...audioTracks, ...videoTracks]);
10250
+ }
10187
10251
  _OnOpen({ hplayer }) {
10188
10252
  this.hplayer = hplayer;
10189
10253
  console.log("open player ok! " + hplayer);
@@ -10322,6 +10386,7 @@ BVPCMPlayer.prototype.init = function(option) {
10322
10386
  this.interval = setInterval(this.flush, this.option.flushingTime);
10323
10387
  this.maxValue = this.getMaxValue();
10324
10388
  this.typedArray = this.getTypedArray();
10389
+ this.audioStream = null;
10325
10390
  this.createContext();
10326
10391
  };
10327
10392
  BVPCMPlayer.prototype.getMaxValue = function() {
@@ -10342,12 +10407,19 @@ BVPCMPlayer.prototype.getTypedArray = function() {
10342
10407
  };
10343
10408
  return typedArrays[this.option.encoding] ? typedArrays[this.option.encoding] : typedArrays["s16"];
10344
10409
  };
10410
+ BVPCMPlayer.prototype.getAudioStream = function() {
10411
+ return this.audioStream;
10412
+ };
10345
10413
  BVPCMPlayer.prototype.createContext = function() {
10346
10414
  this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
10347
10415
  this.audioCtx.resume();
10348
10416
  this.gainNode = this.audioCtx.createGain();
10349
10417
  this.gainNode.gain.value = 1;
10350
- this.gainNode.connect(this.audioCtx.destination);
10418
+ const dest = this.audioCtx.createMediaStreamDestination();
10419
+ this.gainNode.connect(dest);
10420
+ const videoEle = document.createElement("video");
10421
+ videoEle.srcObject = this.audioStream = dest.stream;
10422
+ videoEle.play();
10351
10423
  this.startTime = this.audioCtx.currentTime;
10352
10424
  };
10353
10425
  BVPCMPlayer.prototype.isTypedArray = function(data) {
@@ -10376,6 +10448,10 @@ BVPCMPlayer.prototype.destroy = function() {
10376
10448
  if (this.interval) {
10377
10449
  clearInterval(this.interval);
10378
10450
  }
10451
+ if (this.audioStream) {
10452
+ this.audioStream.getAudioTracks().forEach((item) => item.stop());
10453
+ this.audioStream = null;
10454
+ }
10379
10455
  this.samples = null;
10380
10456
  this.audioCtx.close();
10381
10457
  this.audioCtx = null;
@@ -11957,7 +12033,7 @@ var MediaStreamAudioWaveShowBVRtc = class {
11957
12033
  case "f32-planar":
11958
12034
  tempArray = new Float32Array(dataArray.buffer);
11959
12035
  byteCount = 4;
11960
- iConstMaxData = 2147483647;
12036
+ iConstMaxData = 1;
11961
12037
  break;
11962
12038
  }
11963
12039
  const iPastMs = 1e3 / sampleRate * dataArray.length / byteCount;
@@ -12300,10 +12376,23 @@ var PuPlayer = (props) => {
12300
12376
  player.mikeBtn.intercom = intercom == null ? void 0 : intercom.instance;
12301
12377
  } catch (e) {
12302
12378
  try {
12379
+ let DisplayVolumn2 = function(volume) {
12380
+ var _a3;
12381
+ const button = (_a3 = player.panel) == null ? void 0 : _a3.controller.VolumeButton;
12382
+ if (player.panel && button && hplayer) {
12383
+ const volumeSlider2 = player.panel.controller.VolumeSlider;
12384
+ if (volumeSlider2) {
12385
+ volumeSlider2.percent = hplayer.getVolume();
12386
+ }
12387
+ volume == 0 ? button.Children = /* @__PURE__ */ jsx_default.h(icons_default.Volume, { off: true }) : button.Children = /* @__PURE__ */ jsx_default.h(icons_default.Volume, null);
12388
+ }
12389
+ };
12390
+ var DisplayVolumn = DisplayVolumn2;
12303
12391
  logger_default.debug("error\u7684\u7C7B\u578B", e.name, e instanceof OpenDialogError);
12304
12392
  if (e instanceof OpenDialogError || protocol === "webrtc")
12305
12393
  throw e;
12306
- player.enableCanvas(true);
12394
+ const captureStream = () => hplayer == null ? void 0 : hplayer.captureStream();
12395
+ player.enableCanvas(true, captureStream);
12307
12396
  this.protocol = "ws-bvrtc";
12308
12397
  hplayer = new BVMedia();
12309
12398
  if (noVideoRendeAudioWaveform && !defaultMediaOption.video) {
@@ -12400,7 +12489,7 @@ var PuPlayer = (props) => {
12400
12489
  const audioList = [
12401
12490
  {
12402
12491
  label: t("codec"),
12403
- value: hplayer.getAudioInfo().codec
12492
+ value: hplayer.getAudioInfo().codec + (hplayer.getAudioInfo().webcodecs ? "(webcodecs)" : "")
12404
12493
  },
12405
12494
  {
12406
12495
  label: t("sample-accuracy"),
@@ -12479,6 +12568,7 @@ var PuPlayer = (props) => {
12479
12568
  (_a3 = player.panel) == null ? void 0 : _a3.controller.activeVolume();
12480
12569
  hplayer.setVolume(Number(e2 == null ? void 0 : e2.percent));
12481
12570
  volumeSlider.percent = hplayer.getVolume();
12571
+ DisplayVolumn2(Number(e2 == null ? void 0 : e2.percent));
12482
12572
  });
12483
12573
  }
12484
12574
  if (player.mikeBtn)
@@ -83,6 +83,7 @@ declare class PlayerPlugin extends Plugin<HTMLDivElement, IPlayerPluginEventMap>
83
83
  setProductRemoteSdp(productRemoteSdp: (localDescription: RTCSessionDescription) => Promise<string | undefined>): void;
84
84
  prepareWebrtc(): Promise<void>;
85
85
  close(): Promise<void>;
86
+ private _isInClose;
86
87
  protected beforeDestroy(): void;
87
88
  private loadPlayerConfig;
88
89
  private initEvents;
@@ -91,7 +92,7 @@ declare class PlayerPlugin extends Plugin<HTMLDivElement, IPlayerPluginEventMap>
91
92
  private closeWebrtc;
92
93
  private refreshInfoModal;
93
94
  togglePtz(): Promise<void>;
94
- enableCanvas(enable: boolean): void;
95
+ enableCanvas(enable: boolean, captureStream?: () => MediaStream): void;
95
96
  replaceCanvas(canvas: HTMLCanvasElement): void;
96
97
  setVideoFit(fit: keyof IVideoFits): void;
97
98
  fullscreen(): void;
@@ -42,6 +42,8 @@ declare class VideoPlugin extends Plugin<HTMLDivElement, IVideoPluginEventMap> {
42
42
  getVideoEl(): HTMLVideoElement;
43
43
  getCanvasEl(): HTMLCanvasElement;
44
44
  setCanvasEl(newEl: HTMLCanvasElement): void;
45
+ private _captureStream;
46
+ setCaptureProvider(capture?: () => MediaStream): void;
45
47
  play(): Promise<void>;
46
48
  pause(): void;
47
49
  screenshot(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@besovideo/webrtc-player",
3
- "version": "0.8.40",
3
+ "version": "0.8.42",
4
4
  "description": "@besovideo/webrtc-player desc",
5
5
  "type": "module",
6
6
  "types": "./dist/types/main.d.ts",
@@ -70,4 +70,4 @@
70
70
  "> 1%",
71
71
  "not dead"
72
72
  ]
73
- }
73
+ }