liuyu %!s(int64=4) %!d(string=hai) anos
pai
achega
9640bd66c7
Modificáronse 1 ficheiros con 15 adicións e 1 borrados
  1. 15 1
      src/layout/live/detailInfo.vue

+ 15 - 1
src/layout/live/detailInfo.vue

@@ -41,8 +41,9 @@
           <el-col :span="24" class="rightTop">
             <span @click="liveon"><i class="iconfont iconshexiangtou"></i>直播</span>
             <span v-show="zjrshow" @click="livezhuchi"><i class="iconfont iconshexiangtou"></i>主持</span>
-            <span @click="liveclose"><i class="el-icon-switch-button"></i>关闭</span>
+            <span @click="liveclose"><i class="el-icon-switch-button"></i>关闭直播</span>
             <span @click="shareon"><i class="iconfont iconfenxiang"></i>屏幕</span>
+            <span @click="shareclose"><i class="iconfont iconfenxiang"></i>关闭分享</span>
             <span><el-switch @change="recordclick" v-model="isrecord" active-text="录制" inactive-text="停录"> </el-switch></span>
           </el-col>
           <el-col :span="2" class="noVideo"> </el-col>
@@ -171,6 +172,8 @@ export default {
       microphones: [],
       client_: '',
       localStream_: '',
+      shareClient_: '',
+      shareStream_: '',
       sdkAppId_: '1400380125',
       userId_: '',
       userMainId_: '',
@@ -484,11 +487,13 @@ export default {
           userId: shareId,
           userSig: res.data,
         });
+        this.shareClient_ = shareClient;
         shareClient.setDefaultMuteRemoteStreams(true);
         await shareClient.join({ roomId: this.name });
         const localStream = TRTC.createStream({ audio: false, screen: true });
         //localStream.setScreenProfile({ width: 200, height: 200, float: 'left', frameRate: 5, bitrate: 1600 /* kbps */ });
         await localStream.initialize();
+        this.shareStream_ = localStream;
         console.log('initialize share stream success');
         await shareClient.publish(localStream);
         this.client_.on('stream-added', event => {
@@ -521,6 +526,15 @@ export default {
         }
       }
     },
+    async shareclose() {
+      this.shareClient_;
+      if (this.shareClient_) {
+        this.shareClient_.unpublish(this.shareStream_).then(() => {
+          // 关闭屏幕分享流
+          this.shareStream_.close();
+        });
+      }
+    },
     async cameraChange() {
       //await this.localStream_.switchDevice('video', this.cameraId);
     },