Browse Source

comunicate api md

zhangjie 4 years ago
parent
commit
f30582cb78

+ 1 - 0
src/features/Login/Login.vue

@@ -123,6 +123,7 @@ export default {
             this.$message({
               message: "登录成功",
               type: "success",
+              duration: 1500,
             });
             this.$router.push("/home");
           } catch (error) {

+ 16 - 10
src/features/invigilation/VideoCommunication/VideoCommunication.vue

@@ -72,7 +72,7 @@ export default {
       students: [
         {
           id: 1,
-          roomId: "1",
+          roomId: "8888",
           stdAvatar: "/img/avatars/1.jpg",
           stdName: "邹朵朵",
         },
@@ -103,7 +103,7 @@ export default {
     };
   },
   mounted() {
-    // this.initRong();
+    this.initRong();
   },
   methods: {
     async initRong() {
@@ -114,7 +114,12 @@ export default {
         this.$message.error("初始化错误!");
         return;
       }
-      this.rongRTC = initRongRTC({ debug: true });
+      const { Mode, ROLE } = window.RongRTC;
+      this.rongRTC = initRongRTC({
+        debug: false,
+        mode: Mode.LIVE,
+        liveRole: ROLE.ANCHOR,
+      });
     },
     async answer(student, isVideo) {
       this.dialogVisible = true;
@@ -139,7 +144,6 @@ export default {
       if (!joinRoomSuccess) return;
 
       // 初始化stream
-      // TODO:后加入房间的人,是否会执行先加入房间的人的published回调
       this.stream = new Stream({
         published: (user) => {
           console.log(user);
@@ -147,9 +151,9 @@ export default {
             let {
               stream: { mediaStream },
             } = user;
-            this.$refs.VideoGuest.srcObject = mediaStream;
-            this.$refs.VideoGuest.autoplay = true;
-            this.videoGuestReady = true;
+            this.$refs.VideoHost.srcObject = mediaStream;
+            this.$refs.VideoHost.autoplay = true;
+            this.videoHostReady = true;
           });
         },
         unpublished: (user) => {
@@ -180,10 +184,12 @@ export default {
         .catch((error) => {
           console.log(error);
         });
+      console.log(streamPublishResult);
+      // {configUrl, liveUrl}
       if (isVideo && streamPublishResult) {
-        this.$refs.VideoHost.autoplay = true;
-        this.$refs.VideoHost.srcObject = localStream.mediaStream;
-        this.videoHostReady = true;
+        this.$refs.VideoGuest.autoplay = true;
+        this.$refs.VideoGuest.srcObject = localStream.mediaStream;
+        this.videoGuestReady = true;
       }
     },
     async hangup() {

+ 15 - 8
src/features/invigilation/WainingManage/WainingDetail.vue

@@ -185,7 +185,12 @@ export default {
         this.$message.error("初始化错误!");
         return;
       }
-      this.rongRTC = initRongRTC({ debug: true });
+      const { Mode, ROLE } = window.RongRTC;
+      this.rongRTC = initRongRTC({
+        debug: true,
+        mode: Mode.LIVE,
+        liveRole: ROLE.ANCHOR,
+      });
     },
     initVideo() {
       const { Stream } = this.rongRTC;
@@ -220,6 +225,7 @@ export default {
     closeVideo() {
       this.stream.unsubscribe({ liveUrl: this.liveUrlFirst });
       this.stream.unsubscribe({ liveUrl: this.liveUrlThree });
+      this.stream = null;
       this.firstViewVideoReady = false;
       this.threeViewVideoReady = false;
     },
@@ -247,7 +253,6 @@ export default {
       if (!joinRoomSuccess) return;
 
       // 初始化stream
-      // TODO:后加入房间的人,是否会执行先加入房间的人的published回调
       this.stream = new Stream({
         published: (user) => {
           console.log(user);
@@ -255,9 +260,9 @@ export default {
             let {
               stream: { mediaStream },
             } = user;
-            this.$refs.VideoGuest.srcObject = mediaStream;
-            this.$refs.VideoGuest.autoplay = true;
-            this.videoGuestReady = true;
+            this.$refs.VideoHost.srcObject = mediaStream;
+            this.$refs.VideoHost.autoplay = true;
+            this.videoHostReady = true;
           });
         },
         unpublished: (user) => {
@@ -288,10 +293,12 @@ export default {
         .catch((error) => {
           console.log(error);
         });
+      console.log(streamPublishResult);
+      // {configUrl, liveUrl}
       if (isVideo && streamPublishResult) {
-        this.$refs.VideoHost.autoplay = true;
-        this.$refs.VideoHost.srcObject = localStream.mediaStream;
-        this.videoHostReady = true;
+        this.$refs.VideoGuest.autoplay = true;
+        this.$refs.VideoGuest.srcObject = localStream.mediaStream;
+        this.videoGuestReady = true;
       }
     },
     async hangup() {

+ 6 - 0
src/styles/base.scss

@@ -72,6 +72,11 @@
     margin: 0 auto;
     position: relative;
     border-radius: 6px;
+    video {
+      display: block;
+      width: 100%;
+      height: 100%;
+    }
 
     .communication-host {
       position: relative;
@@ -85,6 +90,7 @@
       top: 10px;
       right: 10px;
       z-index: 99;
+      background: #000;
     }
     .communication-action {
       position: absolute;