From dea44dcd78418ed3e7f191a73cee2b81a7a0019f Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期五, 13 一月 2023 16:21:17 +0800
Subject: [PATCH] Merge branch 'wvp-28181-2.0'

---
 web_src/src/components/dialog/devicePlayer.vue |   90 +++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 86 insertions(+), 4 deletions(-)

diff --git a/web_src/src/components/dialog/devicePlayer.vue b/web_src/src/components/dialog/devicePlayer.vue
index e83a29c..b49a188 100644
--- a/web_src/src/components/dialog/devicePlayer.vue
+++ b/web_src/src/components/dialog/devicePlayer.vue
@@ -4,9 +4,6 @@
     <el-dialog title="瑙嗛鎾斁" top="0" :close-on-click-modal="false" :visible.sync="showVideoDialog" @close="close()">
       <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">
-<!--          <el-tab-pane label="LivePlayer" name="livePlayer">-->
-<!--            <LivePlayer v-if="showVideoDialog" ref="livePlayer" :visible.sync="showVideoDialog" :videoUrl="videoUrl" :error="videoError" :message="videoError" :hasaudio="hasAudio" fluent autoplay live></LivePlayer>-->
-<!--          </el-tab-pane>-->
           <el-tab-pane label="Jessibuca" name="jessibuca">
             <jessibucaPlayer v-if="activePlayer === 'jessibuca'" ref="jessibuca" :visible.sync="showVideoDialog" :videoUrl="videoUrl" :error="videoError" :message="videoError" height="100px" :hasAudio="hasAudio" fluent autoplay live ></jessibucaPlayer>
           </el-tab-pane>
@@ -232,6 +229,18 @@
                     </div>
 
                 </el-tab-pane>
+              <el-tab-pane label="璇煶瀵硅" name="broadcast" >
+                <div class="trank" style="text-align: center;">
+                  <el-button @click="broadcastStatusClick()" :type="getBroadcastStatus()" :disabled="broadcastStatus === -2" circle icon="el-icon-microphone"  style="font-size: 32px; padding: 24px;margin-top: 24px;"/>
+                  <p>
+                    <span v-if="broadcastStatus === -2">姝e湪閲婃斁璧勬簮</span>
+                    <span v-if="broadcastStatus === -1">鐐瑰嚮寮�濮嬪璁�</span>
+                    <span v-if="broadcastStatus === 0">绛夊緟鎺ラ�氫腑...</span>
+                    <span v-if="broadcastStatus === 1">璇疯璇�</span>
+                  </p>
+
+                </div>
+              </el-tab-pane>
 
             </el-tabs>
         </div>
@@ -242,6 +251,7 @@
 <script>
 import rtcPlayer from '../dialog/rtcPlayer.vue'
 import LivePlayer from '@liveqing/liveplayer'
+import crypto from 'crypto'
 import jessibucaPlayer from '../common/jessibuca.vue'
 export default {
     name: 'devicePlayer',
@@ -259,7 +269,9 @@
         }
     },
     created() {
+      console.log("created")
       console.log(this.player)
+      this.broadcastStatus = -1;
       if (Object.keys(this.player).length === 1) {
         this.activePlayer = Object.keys(this.player)[0]
       }
@@ -272,7 +284,6 @@
             // 濡備綍浣犲彧鏄敤涓�绉嶆挱鏀惧櫒锛岀洿鎺ユ敞閲婃帀涓嶇敤鐨勯儴鍒嗗嵆鍙�
             player: {
               jessibuca : ["ws_flv", "wss_flv"],
-              livePlayer : ["ws_flv", "wss_flv"],
               webRTC: ["rtc", "rtcs"],
             },
             showVideoDialog: false,
@@ -308,6 +319,8 @@
             recordStartTime: 0,
             showTimeText: "00:00:00",
             streamInfo: null,
+            broadcastRtc: null,
+            broadcastStatus: -1, // -2 姝e湪閲婃斁璧勬簮 -1 榛樿鐘舵�� 0 绛夊緟鎺ラ�� 1 鎺ラ�氭垚鍔�
         };
     },
     methods: {
@@ -465,6 +478,7 @@
               this.convertStop();
             }
             this.convertKey = ''
+            this.stopBroadcast()
         },
 
         copySharedInfo: function (data) {
@@ -537,7 +551,75 @@
         },
 
 
+              this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_ICE_CANDIDATE_ERROR,(e)=>{// ICE 鍗忓晢鍑洪敊
+                console.error('ICE 鍗忓晢鍑洪敊')
+                this.$message({
+                  showClose: true,
+                  message: 'ICE 鍗忓晢鍑洪敊',
+                  type: 'error'
+                });
+                this.broadcastStatus = -1;
+              });
 
+              this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED,(e)=>{// offer anwser 浜ゆ崲澶辫触
+                console.error('offer anwser 浜ゆ崲澶辫触',e)
+                this.$message({
+                  showClose: true,
+                  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)
+                if (e === "connecting") {
+                  this.broadcastStatus = 0;
+                }else if (e === "connected") {
+                  this.broadcastStatus = 1;
+                }else if (e === "disconnected") {
+                  this.broadcastStatus = -1;
+                }
+              });
+              this.broadcastRtc.on(ZLMRTCClient.Events.CAPTURE_STREAM_FAILED,(e)=>{// offer anwser 浜ゆ崲澶辫触
+                console.log('鎹曡幏娴佸け璐�',e)
+                this.$message({
+                  showClose: true,
+                  message: '鎹曡幏娴佸け璐�' + e,
+                  type: 'error'
+                });
+                this.broadcastStatus = -1;
+              });
+            }
+          }).catch((e) => {
+            this.$message({
+              showClose: true,
+              message: e,
+              type: 'error'
+            });
+            this.broadcastStatus = -1;
+          });
+
+
+        },
+        stopBroadcast(){
+          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",
+              });
+            }
+          });
+        }
     }
 };
 </script>

--
Gitblit v1.8.0