|
@@ -2,10 +2,32 @@
|
|
|
<div v-if="rtcStore.imSate.videoCallModal" class="weixin-call-modal">
|
|
|
<div class="caller-info">
|
|
|
<img
|
|
|
+ v-if="rtcStore.streamType == 'audio'"
|
|
|
class="avatar"
|
|
|
:src="rtcStore.imSate.callAvatar || defaultAvatar"
|
|
|
alt="头像"
|
|
|
/>
|
|
|
+ <div v-if="rtcStore.streamType == 'video'">
|
|
|
+ <!-- 本地视频 -->
|
|
|
+ <video
|
|
|
+ ref="localVideo"
|
|
|
+ autoplay
|
|
|
+ playsinline
|
|
|
+ muted
|
|
|
+ class="local-video"
|
|
|
+ ></video>
|
|
|
+
|
|
|
+ <!-- 远程视频 -->
|
|
|
+ <video
|
|
|
+ ref="remoteVideo"
|
|
|
+ autoplay
|
|
|
+ playsinline
|
|
|
+ class="remote-video"
|
|
|
+ ></video>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- video id="localPreviewSender" width="700px" height="auto" autoPlay muted controls />
|
|
|
+ <video id="remoteVideoSender" width="700px" height="auto" autoPlay muted controls /> -->
|
|
|
<div class="name">{{ rtcStore.imSate.callName || "未知用户" }}</div>
|
|
|
<div class="status">{{ statusText }}</div>
|
|
|
</div>
|
|
@@ -38,12 +60,15 @@ import * as Constant from "@/common/constant/Constant";
|
|
|
const wsStore = useWebSocketStore();
|
|
|
const rtcStore = useWebRTCStore();
|
|
|
|
|
|
+const localVideo = ref(null);
|
|
|
+const remoteVideo = ref(null);
|
|
|
+
|
|
|
const inCall = ref(false);
|
|
|
const defaultAvatar = "https://example.com/default-avatar.png";
|
|
|
|
|
|
const statusText = computed(() => {
|
|
|
- if(inCall.value && rtcStore.remoteStream){
|
|
|
- return "通话中..."
|
|
|
+ if (inCall.value && rtcStore.remoteStream) {
|
|
|
+ return "通话中...";
|
|
|
}
|
|
|
return inCall.value ? "链接中..." : "正在语音通话请求...";
|
|
|
});
|
|
@@ -111,12 +136,22 @@ function hangupCall() {
|
|
|
watch(
|
|
|
() => rtcStore.remoteStream,
|
|
|
(val) => {
|
|
|
- if (val && rtcStore.streamType == "video") {
|
|
|
- console.log("remoteStream===", rtcStore.streamType)
|
|
|
+ if (val && rtcStore.streamType == "video" && remoteVideo.value) {
|
|
|
+ remoteVideo.value.srcObject = val;
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
-
|
|
|
+
|
|
|
+watch(
|
|
|
+ () => rtcStore.localStream,
|
|
|
+ (val) => {
|
|
|
+ if (val && rtcStore.streamType == "video" && localVideo.value) {
|
|
|
+ localVideo.value.srcObject = val;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ { immediate: true }
|
|
|
+);
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
wsStore.onMessageCallbacks.push(onMessage);
|
|
|
});
|