From 5ffc36a1db18d3112a9b50a9cf3953d7fcf21bae Mon Sep 17 00:00:00 2001
From: huanghongfeng <huanghongfeng@hnkhzn.com>
Date: 星期二, 19 八月 2025 16:37:24 +0800
Subject: [PATCH] 更新

---
 项目代码/DP/src/views/indexs/center-map.vue |  231 ++++++++++++++++++++-------------------------------------
 1 files changed, 81 insertions(+), 150 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/DP/src/views/indexs/center-map.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/DP/src/views/indexs/center-map.vue"
index f04a88e..6fec754 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/DP/src/views/indexs/center-map.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/DP/src/views/indexs/center-map.vue"
@@ -1,167 +1,98 @@
 <template>
   <div class="centermap">
     <div class="mapwrap">
-      <dv-border-box-13>
-        <video 
-          ref="videoPlayer" 
-          class="screen-video" 
-          src="../../assets/img/2.mp4" 
-          loop 
-          autoplay 
-          preload="auto"
-          muted
-          @click="handleVideoClick"
-        >
-          鎮ㄧ殑娴忚鍣ㄤ笉鏀寔瑙嗛鎾斁銆�
-        </video>
-        <div v-if="showUnmuteButton" class="unmute-button" @click="unmuteVideo">
-          <span>馃攪 鐐瑰嚮鍙栨秷闈欓煶</span>
-        </div>
-      </dv-border-box-13>
+      <ItemWrap title="瑙嗛鐩戞帶">
+        <video id="video_left" autoplay muted controls playsinline width="100%" height="100%"></video>
+      </ItemWrap>
+    </div>
+    <div class="mapwrap">
+      <ItemWrap title="瑙嗛鐩戞帶">
+        <video id="video_right" autoplay muted controls playsinline width="100%" height="100%"></video>
+      </ItemWrap>
     </div>
   </div>
 </template>
 
-<script>
-export default {
-  data() {
-    return {
-      showUnmuteButton: true, // 鏄剧ず鍙栨秷闈欓煶鎸夐挳
-      hasUserInteracted: false, // 璁板綍鐢ㄦ埛鏄惁宸蹭氦浜�
-      wasPlaying: false // 璁板綍瑙i櫎闈欓煶鍓嶇殑鎾斁鐘舵��
-    };
-  },
-  mounted() {
-    this.initVideo();
-    this.adjustVideoSize();
-    window.addEventListener('resize', this.adjustVideoSize);
-  },
-  beforeDestroy() {
-    window.removeEventListener('resize', this.adjustVideoSize);
-    const video = this.$refs.videoPlayer;
-    if (video) {
-      video.removeEventListener('error', this.handleVideoError);
-    }
-  },
-  methods: {
-    async initVideo() {
-      const video = this.$refs.videoPlayer;
-      if (video) {
-        // 纭繚瑙嗛浠ラ潤闊崇姸鎬佸紑濮�
-        video.muted = true;
-        
-        // 娣诲姞閿欒鐩戝惉
-        video.addEventListener('error', this.handleVideoError);
-        
-        // 灏濊瘯鑷姩鎾斁锛堥潤闊崇姸鎬佷笅閫氬父鍏佽锛�
-        try {
-          await video.play();
-          this.wasPlaying = true;
-        } catch (error) {
-          console.log('鑷姩鎾斁琚樆姝�:', error);
-        }
-      }
-    },
-    
-    handleVideoClick() {
-      if (!this.hasUserInteracted) {
-        this.hasUserInteracted = true;
-        // 鐢ㄦ埛绗竴娆$偣鍑昏棰戞椂灏濊瘯瑙i櫎闈欓煶
-        this.unmuteVideo();
-      }
-    },
-    
-    async unmuteVideo() {
-      const video = this.$refs.videoPlayer;
-      if (!video) return;
-      
-      // 璁板綍褰撳墠鎾斁鐘舵��
-      this.wasPlaying = !video.paused;
-      
-      try {
-        // 鍏堢‘淇濊棰戝湪鎾斁
-        if (this.wasPlaying) {
-          await video.play();
-        }
-        
-        // 瑙i櫎闈欓煶
-        video.muted = false;
-        
-        // 闅愯棌鍙栨秷闈欓煶鎸夐挳
-        this.showUnmuteButton = false;
-      } catch (error) {
-        console.error('瑙i櫎闈欓煶澶辫触:', error);
-        // 鏄剧ず鎻愮ず锛屽憡鐭ョ敤鎴烽渶瑕佷氦浜掓墠鑳芥挱鏀惧0闊�
-        this.showUnmuteButton = true;
-      }
-    },
-    
-    handleVideoError(e) {
-      const video = e.target;
-      console.error('瑙嗛閿欒:', video.error);
-    },
-    
-    adjustVideoSize() {
-      const video = this.$refs.videoPlayer;
-      if (video) {
-        video.style.width = '100%';
-        video.style.height = '100%';
-        video.style.objectFit = 'cover';
-      }
-    }
+<script setup>
+import { ref, onMounted, onUnmounted, onActivated, onDeactivated } from 'vue'
+
+// WebRTC 鎾斁鍣ㄥ疄渚�
+const webRtcServer_left = ref(null)
+const webRtcServer_right = ref(null)
+
+// RTSP 鍦板潃锛屾敞鎰� URL 缂栫爜鐗规畩瀛楃
+const rtspLeft = 'rtsp://admin:Mx202513@172.21.7.244:554/Streaming/Channels/102?rtsp_transport=tcp'
+const rtspRight = 'rtsp://admin:Mx202513@172.21.7.244:554/Streaming/Channels/202?rtsp_transport=tcp'
+
+// WebRtcStreamer 鏈嶅姟鍦板潃
+const serverUrl = 'http://172.21.1.139:8000' // 鈫� 鏀逛负浣犺繍琛� webrtcstreamer 鐨勭數鑴� IP
+
+// 鍒濆鍖栬棰戞挱鏀�
+const initVideo = () => {
+  try {
+    // 宸︽憚鍍忓ご
+    webRtcServer_left.value = new WebRtcStreamer('video_left', serverUrl)
+    webRtcServer_left.value.connect(rtspLeft)
+
+    // 鍙虫憚鍍忓ご
+    webRtcServer_right.value = new WebRtcStreamer('video_right', serverUrl)
+    webRtcServer_right.value.connect(rtspRight)
+
+    console.log('瑙嗛鍒濆鍖栧畬鎴�')
+  } catch (err) {
+    console.error('瑙嗛鍒濆鍖栧け璐�: ' + err.message)
   }
-};
+}
+
+// 閿�姣佽棰戞挱鏀�
+const destroyVideo = () => {
+  if (webRtcServer_left.value) {
+    webRtcServer_left.value.disconnect()
+    webRtcServer_left.value = null
+  }
+  if (webRtcServer_right.value) {
+    webRtcServer_right.value.disconnect()
+    webRtcServer_right.value = null
+  }
+}
+
+// 椤甸潰婵�娲绘椂鎾斁
+onActivated(() => {
+  ['video_left', 'video_right'].forEach(id => {
+    const video = document.getElementById(id)
+    if (video && video.paused) video.play()
+  })
+})
+
+// 椤甸潰鍋滅敤鏃舵殏鍋�
+onDeactivated(() => {
+  ['video_left', 'video_right'].forEach(id => {
+    const video = document.getElementById(id)
+    if (video && !video.paused) video.pause()
+  })
+})
+
+// 椤甸潰鎸傝浇鍒濆鍖�
+onMounted(() => {
+  initVideo()
+})
+
+// 椤甸潰鍗歌浇閿�姣�
+onUnmounted(() => {
+  destroyVideo()
+})
 </script>
 
 <style scoped>
 .centermap {
   width: 100%;
   height: 100%;
-  
-  .mapwrap {
-    height: 960px;
-    width: 100%;
-    box-sizing: border-box;
-    position: relative;
-    margin-top: 10px;
-    
-    & > dv-border-box-13 {
-      width: 100%;
-      height: 100%;
-      position: relative;
-      overflow: hidden;
-    }
-  }
 }
-
-.screen-video {
-  position: absolute;
-  top: 0;
-  left: 0;
+.mapwrap {
+  height: 470px;
   width: 100%;
-  height: 100%;
-  object-fit: cover;
-  cursor: pointer;
+  box-sizing: border-box;
+  position: relative;
+  margin-top: 10px;
 }
-
-.unmute-button {
-  position: absolute;
-  bottom: 20px;
-  right: 20px;
-  background: rgba(0, 0, 0, 0.7);
-  color: white;
-  padding: 8px 16px;
-  border-radius: 20px;
-  cursor: pointer;
-  z-index: 10;
-  font-size: 14px;
-  display: flex;
-  align-items: center;
-  gap: 8px;
-  transition: all 0.3s ease;
-  
-  &:hover {
-    background: rgba(0, 0, 0, 0.9);
-  }
-}
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.9.3