From 06bbe3fe01e5af9486c309693a975077df813f7c Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 29 九月 2022 16:27:59 +0800
Subject: [PATCH] 添加第二种语音对讲实现

---
 web_src/src/components/dialog/devicePlayer.vue |   61 ++++++++++++++++++------------
 1 files changed, 36 insertions(+), 25 deletions(-)

diff --git a/web_src/src/components/dialog/devicePlayer.vue b/web_src/src/components/dialog/devicePlayer.vue
index ee5fd7b..4c8f264 100644
--- a/web_src/src/components/dialog/devicePlayer.vue
+++ b/web_src/src/components/dialog/devicePlayer.vue
@@ -1,7 +1,7 @@
 <template>
 <div id="devicePlayer" v-loading="isLoging">
 
-    <el-dialog title="瑙嗛鎾斁" top="0" :close-on-click-modal="false" :visible.sync="showVideoDialog" :destroy-on-close="true" @close="close()">
+    <el-dialog title="瑙嗛鎾斁" top="0" :close-on-click-modal="false" :visible.sync="showVideoDialog" @close="close()">
         <!-- <LivePlayer v-if="showVideoDialog" ref="videoPlayer" :videoUrl="videoUrl" :error="videoError" :message="videoError" :hasaudio="hasaudio" fluent autoplay live></LivePlayer> -->
       <div style="width: 100%; height: 100%">
         <el-tabs type="card" :stretch="true" v-model="activePlayer" @tab-click="changePlayer" v-if="Object.keys(this.player).length > 1">
@@ -118,6 +118,10 @@
                                 <el-dropdown-item :command="streamInfo.rtc">
                                   <el-tag >RTC:</el-tag>
                                   <span>{{ streamInfo.rtc }}</span>
+                                </el-dropdown-item>
+                                <el-dropdown-item :command="streamInfo.rtcs">
+                                  <el-tag >RTCS:</el-tag>
+                                  <span>{{ streamInfo.rtcs }}</span>
                                 </el-dropdown-item>
                                 <el-dropdown-item :command="streamInfo.rtmp">
                                   <el-tag >RTMP:</el-tag>
@@ -875,7 +879,8 @@
                 }
               });
             }else if (this.broadcastStatus === 1) {
-              this.stopBroadcast()
+                this.broadcastStatus = -1;
+                this.broadcastRtc.close()
             }
         },
         startBroadcast(url){
@@ -890,6 +895,7 @@
                 message: "鑾峰彇鎺ㄦ祦閴存潈Key澶辫触",
                 type: "error",
               });
+              this.broadcastStatus = -1;
             }else {
               let pushKey = res.data.data.pushKey;
               // 鑾峰彇鎺ㄦ祦閴存潈KEY
@@ -923,6 +929,7 @@
                   message: '涓嶆敮鎸亀ebrtc, 鏃犳硶杩涜璇煶瀵硅',
                   type: 'error'
                 });
+                this.broadcastStatus = -1;
               });
 
               this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_ICE_CANDIDATE_ERROR,(e)=>{// ICE 鍗忓晢鍑洪敊
@@ -932,6 +939,7 @@
                   message: 'ICE 鍗忓晢鍑洪敊',
                   type: 'error'
                 });
+                this.broadcastStatus = -1;
               });
 
               this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED,(e)=>{// offer anwser 浜ゆ崲澶辫触
@@ -941,6 +949,7 @@
                   message: 'offer anwser 浜ゆ崲澶辫触' + e,
                   type: 'error'
                 });
+                this.broadcastStatus = -1;
               });
               this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_ON_CONNECTION_STATE_CHANGE,(e)=>{// offer anwser 浜ゆ崲澶辫触
                 console.log('鐘舵�佹敼鍙�',e)
@@ -959,36 +968,38 @@
                   message: '鎹曡幏娴佸け璐�' + e,
                   type: 'error'
                 });
+                this.broadcastStatus = -1;
               });
             }
+          }).catch((e) => {
+            this.$message({
+              showClose: true,
+              message: e,
+              type: 'error'
+            });
+            this.broadcastStatus = -1;
           });
 
 
         },
         stopBroadcast(){
-          if (this.broadcastStatus === -1) {
-            this.broadcastStatus = 1;
-          }else {
-            this.broadcastStatus = -2;
-            this.broadcastRtc = null;
-            this.$axios({
-              method: 'get',
-              url: '/api/play/broadcast/stop/' + this.deviceId + '/' + this.channelId
-            }).then( (res)=> {
-              if (res.data.code == 0) {
-                // this.broadcastStatus = -1;
-                // this.broadcastRtc.close()
-              }else {
-                this.$message({
-                  showClose: true,
-                  message: res.data.msg,
-                  type: "error",
-                });
-              }
-            });
-          }
-
-
+          this.broadcastRtc.close();
+          this.broadcastStatus = -1;
+          this.$axios({
+            method: 'get',
+            url: '/api/play/broadcast/stop/' + this.deviceId + '/' + this.channelId
+          }).then( (res)=> {
+            if (res.data.code == 0) {
+              // this.broadcastStatus = -1;
+              // this.broadcastRtc.close()
+            }else {
+              this.$message({
+                showClose: true,
+                message: res.data.msg,
+                type: "error",
+              });
+            }
+          });
         }
     }
 };

--
Gitblit v1.8.0