|
@@ -115,18 +115,15 @@ export const useWebRTCStore = defineStore("webrtc", {
|
|
event.streams[0].getTracks().forEach((track) => {
|
|
event.streams[0].getTracks().forEach((track) => {
|
|
this.remoteStream.addTrack(track);
|
|
this.remoteStream.addTrack(track);
|
|
});
|
|
});
|
|
- // 绑定音频
|
|
|
|
- // this.bindRemoteAudio();
|
|
|
|
|
|
+
|
|
};
|
|
};
|
|
|
|
|
|
// 监听 ICE 连接状态(关键修复!)
|
|
// 监听 ICE 连接状态(关键修复!)
|
|
this.peerConnection.oniceconnectionstatechange = () => {
|
|
this.peerConnection.oniceconnectionstatechange = () => {
|
|
const state = this.peerConnection.iceConnectionState;
|
|
const state = this.peerConnection.iceConnectionState;
|
|
- console.log("ICE 连接状态:", state);
|
|
|
|
-
|
|
|
|
if (state === "connected") {
|
|
if (state === "connected") {
|
|
console.log("✅ P2P 连接成功,可以开始语音通话!");
|
|
console.log("✅ P2P 连接成功,可以开始语音通话!");
|
|
- this.bindRemoteAudio();
|
|
|
|
|
|
+ if(this.streamType == "audio") this.bindRemoteAudio();
|
|
} else if (state === "failed") {
|
|
} else if (state === "failed") {
|
|
console.error("❌ ICE 连接失败,尝试重启...");
|
|
console.error("❌ ICE 连接失败,尝试重启...");
|
|
this.restartICE();
|
|
this.restartICE();
|