quickvo-sdk-js 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -732,7 +732,6 @@ class AudioMediaContext {
|
|
|
732
732
|
// 音量
|
|
733
733
|
Z(this, "enhanceGain", 0);
|
|
734
734
|
// 音量增强
|
|
735
|
-
Z(this, "audio", new Audio());
|
|
736
735
|
// @ts-ignore 音频上下文
|
|
737
736
|
Z(this, "audioContext", new (window.AudioContext || window.webkitAudioContext)());
|
|
738
737
|
// 媒体流音频源节点
|
|
@@ -749,6 +748,12 @@ class AudioMediaContext {
|
|
|
749
748
|
Z(this, "analyserNode");
|
|
750
749
|
// 缓冲区 存储分析节点的时域数据
|
|
751
750
|
Z(this, "analyserArrayData");
|
|
751
|
+
// 初始化节点
|
|
752
|
+
Z(this, "initNode", () => {
|
|
753
|
+
this.mediaStreamAudioSourceNode = this.audioContext.createMediaStreamSource(this.stream), this.autoGainNode = this.audioContext.createGain(), this.autoGainNode.gain.setValueAtTime(0.8, this.audioContext.currentTime), this.biquadFilterNode = this.audioContext.createBiquadFilter(), this.biquadFilterNode.type = "lowpass", this.biquadFilterNode.frequency.value = 1e3, this.delayNode = this.audioContext.createDelay(), this.delayNode.delayTime.value = 0.5, this.gainNode = this.audioContext.createGain(), this.gainNode.gain.setValueAtTime(this.gain, this.audioContext.currentTime), this.analyserNode = this.audioContext.createAnalyser(), this.analyserNode.fftSize = 512, this.analyserArrayData = new Uint8Array(this.analyserNode.frequencyBinCount);
|
|
754
|
+
const { gainNode: I, analyserNode: a } = this;
|
|
755
|
+
I.connect(a), this.audioContext.state === "suspended" && (this.audioContext.resume(), document.addEventListener("click", () => this.audioContext.resume(), { once: !0 })), this.setFilter();
|
|
756
|
+
});
|
|
752
757
|
/**
|
|
753
758
|
* 停止
|
|
754
759
|
*/
|
|
@@ -763,11 +768,11 @@ class AudioMediaContext {
|
|
|
763
768
|
* 替换媒体
|
|
764
769
|
*/
|
|
765
770
|
Z(this, "replaceStream", (I) => {
|
|
766
|
-
const a = this.stream.getTracks();
|
|
767
|
-
for (const
|
|
768
|
-
|
|
769
|
-
const [
|
|
770
|
-
|
|
771
|
+
const a = this.stream, E = a.getTracks();
|
|
772
|
+
for (const k of E)
|
|
773
|
+
a.removeTrack(k);
|
|
774
|
+
const [_] = I.getAudioTracks();
|
|
775
|
+
_ && a.addTrack(_), this.initNode();
|
|
771
776
|
});
|
|
772
777
|
/**
|
|
773
778
|
* 获取数据流
|
|
@@ -819,9 +824,7 @@ class AudioMediaContext {
|
|
|
819
824
|
let N = k;
|
|
820
825
|
return a && N.connect(e), E && N.connect(n), _ && N.connect(O), N.connect($), I;
|
|
821
826
|
});
|
|
822
|
-
this.stream.addTrack(I), this.
|
|
823
|
-
const { gainNode: a, analyserNode: E } = this;
|
|
824
|
-
a.connect(E), this.audioContext.state === "suspended" && (this.audioContext.resume(), document.addEventListener("click", () => this.audioContext.resume(), { once: !0 })), this.setFilter();
|
|
827
|
+
this.stream.addTrack(I), this.audioContext = new (window.AudioContext || window.webkitAudioContext)(), this.initNode();
|
|
825
828
|
}
|
|
826
829
|
}
|
|
827
830
|
class VideoMediaContext {
|
|
@@ -840,11 +843,11 @@ class VideoMediaContext {
|
|
|
840
843
|
* 替换媒体
|
|
841
844
|
*/
|
|
842
845
|
Z(this, "replaceStream", (I) => {
|
|
843
|
-
const a = this.stream.getTracks();
|
|
844
|
-
for (const
|
|
845
|
-
|
|
846
|
-
const [
|
|
847
|
-
|
|
846
|
+
const a = this.stream, E = a.getTracks();
|
|
847
|
+
for (const k of E)
|
|
848
|
+
a.removeTrack(k);
|
|
849
|
+
const [_] = I.getVideoTracks();
|
|
850
|
+
_ && a.addTrack(_);
|
|
848
851
|
});
|
|
849
852
|
/**
|
|
850
853
|
* 获取数据流
|
|
@@ -8319,15 +8322,16 @@ class RoomPeer extends RoomUsers {
|
|
|
8319
8322
|
* 替换发射器媒体流
|
|
8320
8323
|
*/
|
|
8321
8324
|
Z(this, "replaceSenderStream", async (a = [], E) => {
|
|
8325
|
+
const { userId: _ } = this.options;
|
|
8322
8326
|
a.length === 0 && (a = mediaType_keys);
|
|
8323
|
-
for (const
|
|
8324
|
-
const
|
|
8325
|
-
let
|
|
8326
|
-
if (
|
|
8327
|
-
const { sender:
|
|
8328
|
-
E ?
|
|
8329
|
-
const [
|
|
8330
|
-
|
|
8327
|
+
for (const k of a) {
|
|
8328
|
+
const e = this.transceiverMap.get(k);
|
|
8329
|
+
let n;
|
|
8330
|
+
if (e) {
|
|
8331
|
+
const { sender: O } = e;
|
|
8332
|
+
E ? n = this.getUserStream(_, k) : n = this.getPhoneyStreams(k);
|
|
8333
|
+
const [$] = n.getTracks();
|
|
8334
|
+
$ && await O.replaceTrack($);
|
|
8331
8335
|
}
|
|
8332
8336
|
}
|
|
8333
8337
|
});
|