From 1ef360a14efab8a1defa1dfdc13bb5af64a9d621 Mon Sep 17 00:00:00 2001
From: husq <931347610@qq.com>
Date: Mon, 18 Sep 2023 17:02:51 +0800
Subject: [PATCH] 飞行指令打开

---
 src/components/GMap.vue |   30 +++++++++++++++++++++++-------
 1 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/src/components/GMap.vue b/src/components/GMap.vue
index f112bd0..ece0f70 100644
--- a/src/components/GMap.vue
+++ b/src/components/GMap.vue
@@ -372,7 +372,7 @@
       </div>
       <a-row class="p5" v-if="showMonitor">
         <!-- <a-spin :spinning="spinning"> -->
-          <Jessibuca v-if="airPortUrl" :videoUrl="airPortUrl" width="100%" height="200px" />
+          <Jessibuca v-if="airPortUrl" :videoUrl="airPortUrl" width="100%" height="300px" />
         <!-- </a-spin> -->
       </a-row>
       <!--  飞机-->
@@ -613,9 +613,9 @@
             '' }}{{ deviceInfo.device.battery.remain_flight_time % 60 }}
         </div>
       </div>
-      <!-- 飞行指令
+      <!-- 飞行指令 -->
       <DroneControlPanel :sn="osdVisible.gateway_sn" :deviceInfo="deviceInfo" :payloads="osdVisible.payloads">
-      </DroneControlPanel> -->
+      </DroneControlPanel>
     </div>
   </div>
 </template>
@@ -642,7 +642,7 @@
 import { deviceTsaUpdate } from '/@/hooks/use-g-map-tsa'
 import Jessibuca from '/@/components/Jessibuca/Jessibuca.vue'
 import { CURRENT_CONFIG as config } from '/@/api/http/config'
-import { getLiveCapacity, startLivestream } from '/@/api/manage'
+import { getLiveCapacity, startLivestream, stopLivestream } from '/@/api/manage'
 import {
   DeviceOsd, DeviceStatus, DockOsd, EGear, EModeCode, GatewayOsd, EDockModeCode, EDockModeText, EModeText,
   NetworkStateQualityEnum, NetworkStateTypeEnum, RainfallEnum, DroneInDockEnum
@@ -781,7 +781,11 @@
     // 打开监控权限
     const openMonitor = () => {
       showMonitor.value = !showMonitor.value
-      loadVideo()
+      if (showMonitor.value) {
+        loadVideo()
+      } else {
+        onClose()
+      }
     }
     // 加载该设备的视频信息
     const loadVideo = async () => {
@@ -827,11 +831,10 @@
           console.error(error)
         })
     }
-    // 开始播放
+    // 设备开始播放
     const onStart = async () => {
       const videoId = droneList.value[droneIndex.value].value + '/' + cameraList.value[cameraIndex.value].value + '/' + videoList.value[videoIndex.value].value
       const streamId = droneList.value[droneIndex.value].value + '-' + cameraList.value[cameraIndex.value].value + '-' + videoList.value[videoIndex.value].value
-      console.log(videoId, 'videoId')
       const liveURL = config.rtmpURL + streamId
       await startLivestream({
         url: liveURL,
@@ -846,6 +849,19 @@
           console.log(airPortUrl.value, 'airPortUrl')
         })
     }
+    // 关闭设备直播
+    const onClose = async () => {
+      const videoId = droneList.value[droneIndex.value].value + '/' + cameraList.value[cameraIndex.value].value + '/' + videoList.value[videoIndex.value].value
+
+      stopLivestream({
+        video_id: videoId
+      }).then(res => {
+        if (res.code === 0) {
+          console.log('stop play livestream')
+          airPortUrl.value = ''
+        }
+      })
+    }
     watch(() => store.state.deviceStatusEvent,
       data => {
         if (Object.keys(data.deviceOnline).length !== 0) {

--
Gitblit v1.9.3