tremble 3 年之前
父节点
当前提交
97ba5f5846
共有 3 个文件被更改,包括 34 次插入5 次删除
  1. 27 4
      src/components/RTC/Trtccom.vue
  2. 0 1
      src/components/RTC/dialog/createdRoom.vue
  3. 7 0
      src/components/RTC/index.vue

+ 27 - 4
src/components/RTC/Trtccom.vue

@@ -150,6 +150,7 @@ async function handleJoin() {
       userId: store.getters["rtc/userId"],
       userSig: res.data.sign,
       useStringRoomId: true,
+      enableAutoPlayDialog: false,
     });
     installEventHandlers();
 
@@ -167,7 +168,29 @@ async function handleJoin() {
     .then(() => {
       // addLocalControlView();
     })
-    .catch((e) => {});
+    .catch((e) => {
+      console.log(stream);
+    });
+
+  localStream.on("error", (error) => {
+    if (error.getCode() === 0x4043) {
+      // 自动播放受限导致播放失败,此时引导用户点击页面。
+      // 在点击事件的回调函数中,执行 stream.resume();
+      Dialog.confirm({
+        showCloseIcon: false,
+        okText: "确定",
+        content:
+          "<span style='font-size: 16px; line-height: 1.5;'>開發者已遵守收集、使用最終用戶個人信息有關的所有可適用法律、政策和法規,保護用戶個人信息安全。<span/>",
+        title: "隱私條款:",
+        single: true,
+        func: (state) => {
+          if (state == "ok") {
+            localStream.resume();
+          }
+        },
+      });
+    }
+  });
 }
 
 async function handlePublish() {
@@ -222,9 +245,9 @@ async function handleLeave() {
   try {
     uninstallEventHandlers();
     await localClient.leave();
-    invitedRemoteStreams.value = []
-    store.commit("rtc/setVideoDeviceId", '');
-    store.commit("rtc/setAudioDeviceId", '');
+    invitedRemoteStreams.value = [];
+    store.commit("rtc/setVideoDeviceId", "");
+    store.commit("rtc/setAudioDeviceId", "");
 
     if (localStream) {
       localStream.stop();

+ 0 - 1
src/components/RTC/dialog/createdRoom.vue

@@ -76,7 +76,6 @@ export default {
     },
     closeCreated() {
       this.$emit("closeCreated");
-      !browser.hasURLParam("pose");
     },
     createdConfirm() {
       if (this.userName == "") {

+ 7 - 0
src/components/RTC/index.vue

@@ -72,6 +72,13 @@ const closeCreated = (str, link) => {
   store.commit("showShoppingguide", false);
   showCreated.value = false;
   showguide();
+  if (browser.getURLParam("role")) {
+    let tempUrl = window.location.href;
+    ["mode", "name", "role", "roomId", "vruserId"].forEach((item) => {
+      tempUrl = browser.replaceQueryString(tempUrl, item, "");
+    });
+    history.replaceState(null, null, tempUrl);
+  }
 };
 
 const createdConfirm = (str, link) => {