liuyu 4 years ago
parent
commit
867a845aed
2 changed files with 1098 additions and 26 deletions
  1. 1052 0
      src/views/live/roomDetail copy.vue
  2. 46 26
      src/views/live/roomDetail.vue

File diff suppressed because it is too large
+ 1052 - 0
src/views/live/roomDetail copy.vue


+ 46 - 26
src/views/live/roomDetail.vue

@@ -11,18 +11,16 @@
               <van-col id="look-video-left" :span="stremlist.length == 2 ? 16 : 0" :style="{ height: oheight }"> </van-col>
               <van-col id="look-video-left" :span="stremlist.length == 2 ? 16 : 0" :style="{ height: oheight }"> </van-col>
               <van-col id="look-video-right" :style="{ height: oheight }" :span="stremlist.length == 1 ? 24 : 8"> </van-col>
               <van-col id="look-video-right" :style="{ height: oheight }" :span="stremlist.length == 1 ? 24 : 8"> </van-col>
             </div>
             </div>
-            <div
-              id="othediv"
-              v-show="othedivshow"
-              :style="{ transform: transform, height: otheheight, width: vwidth, padding: othepadding, position: 'absolute' }"
-            >
-              <div id="otheplaydiv" :style="{ height: otheheight, width: vwidth, background: background_ }">
-                <div id="othe-video-1" :style="{ height: otheheight, width: othewidth }" class="video-box col-div othe-video-left"></div>
-                <div id="othe-video-2" :style="{ height: otheheight, width: othewidth }" class="video-box col-div othe-video-left"></div>
-                <div id="othe-video-3" :style="{ height: otheheight, width: othewidth }" class="video-box col-div othe-video-left"></div>
-                <div id="othe-video-4" :style="{ height: otheheight, width: othewidth }" class="video-box col-div othe-video-left"></div>
-                <div id="othe-video-5" :style="{ height: otheheight, width: othewidth }" class="video-box col-div othe-video-left"></div>
-              </div>
+            <div id="othediv" v-show="othedivshow" :style="{ transform: transform, width: vwidth, padding: othepadding, position: 'absolute' }">
+              <el-col
+                :span="24"
+                id="otheplaydiv"
+                :style="{ height: otheheight, width: vwidth, background: background_ }"
+                v-for="(item, index) in stremMeetlist"
+                :key="index"
+              >
+                <div :id="item.id" :style="{ height: otheheight, width: othewidth }" class="video-box col-div othe-video-left"></div>
+              </el-col>
             </div>
             </div>
           </van-overlay>
           </van-overlay>
         </el-col>
         </el-col>
@@ -395,9 +393,14 @@ export default {
         }
         }
         if (body.switchrole === 'audience') {
         if (body.switchrole === 'audience') {
           const oldstrem_ = _.find(this.stremlist, { type: 'mainr' });
           const oldstrem_ = _.find(this.stremlist, { type: 'mainr' });
-          this.stermStop(oldstrem_.strem);
-          this.stermPlay(oldstrem_.strem, 'look-video-right');
+          if (oldstrem_) {
+            this.stermStop(oldstrem_.strem);
+            this.stermPlay(oldstrem_.strem, 'look-video-right');
+          }
+          console.log('移除body.userid--' + body.userid);
+          console.log('移除this.user.uid--' + this.user.uid);
           if (body.userid === this.user.uid) {
           if (body.userid === this.user.uid) {
+            console.log(this.localStream_);
             this.stermStop(this.localStream_);
             this.stermStop(this.localStream_);
             this.localStream_.muteAudio();
             this.localStream_.muteAudio();
             this.localStream_.muteVideo();
             this.localStream_.muteVideo();
@@ -516,7 +519,7 @@ export default {
       await this.client_.publish(this.localStream_);
       await this.client_.publish(this.localStream_);
       this.index_ = this.index_ + 1;
       this.index_ = this.index_ + 1;
 
 
-      if (this.index_ < 6) {
+      if (this.index_ < 11) {
         // const otheplaydiv = document.getElementById('otheplaydiv');
         // const otheplaydiv = document.getElementById('otheplaydiv');
         const id_ = 'othe-video-' + this.index_;
         const id_ = 'othe-video-' + this.index_;
         const newdata_ = { strem: this.localStream_, index: this.index_, id: id_, swichuserid: this.userId_ };
         const newdata_ = { strem: this.localStream_, index: this.index_, id: id_, swichuserid: this.userId_ };
@@ -526,7 +529,10 @@ export default {
         const newdata = { swichuserid: this.userId_, swichindex: this.index_ };
         const newdata = { swichuserid: this.userId_, swichindex: this.index_ };
         this.swichusers.push(newdata);
         this.swichusers.push(newdata);
         console.log('将用户push到列表里' + this.swichusers);
         console.log('将用户push到列表里' + this.swichusers);
-        this.localStream_.play(id_);
+
+        this.$nextTick(() => {
+          this.localStream_.play(id_);
+        });
       }
       }
     },
     },
     async questSearch() {
     async questSearch() {
@@ -730,7 +736,7 @@ export default {
             this.otheheight = '70px';
             this.otheheight = '70px';
             this.iscamera = true;
             this.iscamera = true;
             this.index_ = this.index_ + 1;
             this.index_ = this.index_ + 1;
-            if (this.index_ < 6) {
+            if (this.index_ < 11) {
               const id_ = 'othe-video-' + this.index_;
               const id_ = 'othe-video-' + this.index_;
               const newdata_ = { strem: remoteStream, index: this.index_, id: id_, swichuserid: userid_zs };
               const newdata_ = { strem: remoteStream, index: this.index_, id: id_, swichuserid: userid_zs };
               this.stremMeetlist.push(newdata_);
               this.stremMeetlist.push(newdata_);
@@ -739,12 +745,14 @@ export default {
               this.swichusers.push(newdata);
               this.swichusers.push(newdata);
               console.log('将用户push到列表里' + newdata);
               console.log('将用户push到列表里' + newdata);
               this.stermStop(remoteStream);
               this.stermStop(remoteStream);
-              remoteStream.play(id_);
+              this.$nextTick(() => {
+                remoteStream.play(id_);
+              });
             }
             }
           } else if (useridsplit_ === 'wxxcx') {
           } else if (useridsplit_ === 'wxxcx') {
             console.log('小程序进入画面' + this.index_);
             console.log('小程序进入画面' + this.index_);
             this.index_ = this.index_ + 1;
             this.index_ = this.index_ + 1;
-            if (this.index_ < 6) {
+            if (this.index_ < 11) {
               const id_ = 'othe-video-' + this.index_;
               const id_ = 'othe-video-' + this.index_;
               console.log(id_);
               console.log(id_);
               remoteStream.play(id_);
               remoteStream.play(id_);
@@ -808,14 +816,15 @@ export default {
         this.client_.on('mute-video', event => {
         this.client_.on('mute-video', event => {
           const userid_ = event.userId;
           const userid_ = event.userId;
           const useridsplit_ = userid_.substring(0, 5);
           const useridsplit_ = userid_.substring(0, 5);
+          const useridzs_ = userid_.substring(6);
           if (useridsplit_ === 'wxxcx' || useridsplit_ === 'meetu') {
           if (useridsplit_ === 'wxxcx' || useridsplit_ === 'meetu') {
-            console.log('退出userid_' + useridsplit_);
-            const swichstrem = _.find(this.stremMeetlist, { swichuserid: userid_ });
-            this.stermStop(swichstrem.strem);
-            // 订阅远端音频和视频流
-            if (this.index_ > 0) {
-              this.index_ = this.index_ - 1;
-            }
+            console.log('退出userid_' + useridzs_);
+            const swichstrem = _.find(this.stremMeetlist, { swichuserid: useridzs_ });
+            // this.stermStop(swichstrem.strem);
+            // // 订阅远端音频和视频流
+            // if (this.index_ > 0) {
+            //   this.index_ = this.index_ - 1;
+            // }
           }
           }
           console.log('退出');
           console.log('退出');
           console.log(event);
           console.log(event);
@@ -827,6 +836,10 @@ export default {
     imgclick(url) {
     imgclick(url) {
       location.href = url;
       location.href = url;
     },
     },
+    forOtherId(_index) {
+      const index_ = _index + 1;
+      return 'othe-video-' + index_;
+    },
     full() {
     full() {
       this.show = true;
       this.show = true;
       const width = document.documentElement.clientWidth;
       const width = document.documentElement.clientWidth;
@@ -969,6 +982,13 @@ export default {
   grid-area: 1/1/3/4;
   grid-area: 1/1/3/4;
   justify-content: flex-end;
   justify-content: flex-end;
 }
 }
+#othediv {
+  width: 100%;
+  min-height: 0px;
+  word-wrap: break-word;
+  word-break: break-all;
+  overflow: hidden;
+}
 .othe-video-left {
 .othe-video-left {
   float: left;
   float: left;
   background: #000;
   background: #000;