From 72c1b36d6d2ece497e032c8434641d6576590f9d Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期日, 03 七月 2022 00:44:36 +0800
Subject: [PATCH] 优化对讲逻辑

---
 web_src/src/components/dialog/devicePlayer.vue |   50 ++++++++++++++++++++++++++++----------------------
 1 files changed, 28 insertions(+), 22 deletions(-)

diff --git a/web_src/src/components/dialog/devicePlayer.vue b/web_src/src/components/dialog/devicePlayer.vue
index 25101ea..a33e8a4 100644
--- a/web_src/src/components/dialog/devicePlayer.vue
+++ b/web_src/src/components/dialog/devicePlayer.vue
@@ -537,6 +537,9 @@
               this.stopPlayRecord();
             }
             this.recordPlay = ''
+            if (this.broadcastStatus === 1) {
+              this.stopBroadcast()
+            }
         },
 
         copySharedInfo: function (data) {
@@ -849,24 +852,7 @@
                 }
               });
             }else if (this.broadcastStatus === 1) {
-              this.broadcastRtc.close()
-              this.broadcastRtc = null;
-              this.$axios({
-                method: 'get',
-                url: '/api/play/broadcast/stop/' + this.deviceId + '/' + this.channelId
-              }).then( (res)=> {
-                if (res.data.code == 0) {
-                  let streamInfo = res.data.data.streamInfo;
-                  this.startBroadcast(streamInfo.rtc)
-                }else {
-                  this.$message({
-                    showClose: true,
-                    message: res.data.msg,
-                    type: "error",
-                  });
-                }
-              });
-              this.broadcastStatus = -1;
+              this.stopBroadcast()
             }
         },
         startBroadcast(url){
@@ -920,12 +906,12 @@
           });
           this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_ON_CONNECTION_STATE_CHANGE,(e)=>{// offer anwser 浜ゆ崲澶辫触
             console.log('鐘舵�佹敼鍙�',e)
-            if (e === "failed") {
-              this.broadcastStatus = -1;
-            }else if (e === "connecting") {
+            if (e === "connecting") {
               this.broadcastStatus = 0;
-            }else{
+            }else if (e === "connected") {
               this.broadcastStatus = 1;
+            }else {
+              this.broadcastStatus = -1;
             }
           });
           this.broadcastRtc.on(ZLMRTCClient.Events.CAPTURE_STREAM_FAILED,(e)=>{// offer anwser 浜ゆ崲澶辫触
@@ -936,6 +922,26 @@
               type: 'error'
             });
           });
+        },
+        stopBroadcast(){
+          this.broadcastRtc.close()
+          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;
+
+            }else {
+              this.$message({
+                showClose: true,
+                message: res.data.msg,
+                type: "error",
+              });
+            }
+          });
+
         }
     }
 };

--
Gitblit v1.8.0