liuyu vor 4 Jahren
Ursprung
Commit
b3be45a96a
1 geänderte Dateien mit 43 neuen und 15 gelöschten Zeilen
  1. 43 15
      src/views/live/roomDetail.vue

+ 43 - 15
src/views/live/roomDetail.vue

@@ -183,6 +183,9 @@ export default {
       shmaiindex: 0,
       stremlist: [],
       stremMeetlist: [],
+      stremOtherlist: [],
+      swichzjrid: '',
+      swichzjrstatus: false,
     };
   },
   created() {
@@ -331,9 +334,9 @@ export default {
       this.$stomp({
         [`/exchange/quest_publish_` + this.id]: this.onQueMessage,
       });
-      // this.$stomp({
-      //   [`/exchange/othe_publish_` + this.id]: this.onOtheMessage,
-      // });
+      this.$stomp({
+        [`/exchange/switch_zjr_` + this.id]: this.onZjrMessage,
+      });
     },
     onMessage(message) {
       // console.log('receive a message: ', message.body);
@@ -398,6 +401,19 @@ export default {
         this.swichposition(body.shmaiid);
       }
     },
+    onZjrMessage(message) {
+      let body = _.get(message, 'body');
+      if (body) {
+        body = JSON.parse(body);
+        if (body.switchzjr) {
+          this.swichzjrstatus = true;
+          this.swichzjrid = body.switchzjr;
+          this.swichzjrVideo(body.switchzjr);
+        } else {
+          this.swichzjrstatus = false;
+        }
+      }
+    },
     onOtheMessage(message) {
       let body = _.get(message, 'body');
       if (body) {
@@ -410,6 +426,17 @@ export default {
         }
       }
     },
+    async swichzjrVideo(switchzjr) {
+      //
+      const swichstrem = _.find(this.stremOtherlist, { switchzjrid: switchzjr, type: 'other' });
+      if (swichstrem) {
+        const oldstrem_ = _.find(this.stremlist, { type: 'mainr' });
+        if (oldstrem_) {
+          this.stermStop(oldstrem_.strem);
+        }
+        this.stermPlay(swichstrem.strem, 'look-video-right');
+      }
+    },
     async userswichrole() {
       // 根据房间id查询房间详细信息
       let result = await this.lookuserswichrole({ roomid: this.id, userid: this.user.uid });
@@ -493,6 +520,11 @@ export default {
       if (this.$checkRes(result)) {
         console.log(result.data);
         this.$set(this, `roomInfos`, result.data);
+        if (result.data.switchzjr) {
+          this.swichzjrid = result.data.switchzjr;
+          this.swichzjrstatus = true;
+          this.swichzjrVideo(result.data.switchzjr);
+        }
         // 根据房间信息判断是否回答问卷
         if (result.data.isque === '1') {
           const info = { roomid: this.id, userid: this.user.uid, questionnaireid: result.data.queid };
@@ -580,6 +612,12 @@ export default {
             // this.zbfullbtn();
             const newdata_ = { strem: remoteStream, type: 'mainr' };
             this.stremlist.push(newdata_);
+            if (this.swichzjrid) {
+              const swichstrem = _.find(this.stremOtherlist, { switchzjrid: this.swichzjrid, type: 'other' });
+              if (swichstrem) {
+                this.stermStop(swichstrem.strem);
+              }
+            }
             remoteStream
               .play('look-video-right')
               .then(() => {
@@ -595,18 +633,8 @@ export default {
           } else if (useridsplit_ === 'other') {
             console.log('333');
             this.rvideoid_ = 'video_' + remoteStream.getId();
-            remoteStream
-              .play('look-video-right')
-              .then(() => {
-                // autoplay success
-              })
-              .catch(e => {
-                const errorCode = e.getCode();
-                if (errorCode === 0x4043) {
-                  // PLAY_NOT_ALLOWED,引导用户手势操作恢复音视频播放
-                  remoteStream.resume();
-                }
-              });
+            const newdata_ = { strem: remoteStream, type: 'other', switchzjrid: userid_zs };
+            this.stremOtherlist.push(newdata_);
           } else if (useridsplit_ === 'meetu') {
             console.log('333');
             console.log('公众号进入画面' + this.index_);