devicePlayer.vue 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987
  1. <template>
  2. <div id="devicePlayer" v-loading="isLoging">
  3. <el-dialog title="视频播放" top="0" :close-on-click-modal="false" :visible.sync="showVideoDialog" @close="close()">
  4. <div style="width: 100%; height: 100%">
  5. <el-tabs type="card" :stretch="true" v-model="activePlayer" @tab-click="changePlayer"
  6. v-if="Object.keys(this.player).length > 1">
  7. <el-tab-pane label="Jessibuca" name="jessibuca">
  8. <jessibucaPlayer v-if="activePlayer === 'jessibuca'" ref="jessibuca" :visible.sync="showVideoDialog"
  9. :videoUrl="videoUrl" :error="videoError" :message="videoError" height="100px"
  10. :hasAudio="hasAudio" fluent autoplay live></jessibucaPlayer>
  11. </el-tab-pane>
  12. <el-tab-pane label="WebRTC" name="webRTC">
  13. <rtc-player v-if="activePlayer === 'webRTC'" ref="webRTC" :visible.sync="showVideoDialog"
  14. :videoUrl="videoUrl" :error="videoError" :message="videoError" height="100px"
  15. :hasAudio="hasAudio" fluent autoplay live></rtc-player>
  16. </el-tab-pane>
  17. <el-tab-pane label="h265web">h265web敬请期待</el-tab-pane>
  18. <el-tab-pane label="wsPlayer">wsPlayer 敬请期待</el-tab-pane>
  19. </el-tabs>
  20. <jessibucaPlayer v-if="Object.keys(this.player).length == 1 && this.player.jessibuca" ref="jessibuca"
  21. :visible.sync="showVideoDialog" :videoUrl="videoUrl" :error="videoError" :message="videoError"
  22. height="100px" :hasAudio="hasAudio" fluent autoplay live></jessibucaPlayer>
  23. <rtc-player v-if="Object.keys(this.player).length == 1 && this.player.webRTC" ref="jessibuca"
  24. :visible.sync="showVideoDialog" :videoUrl="videoUrl" :error="videoError" :message="videoError"
  25. height="100px" :hasAudio="hasAudio" fluent autoplay live></rtc-player>
  26. </div>
  27. <div id="shared" style="text-align: right; margin-top: 1rem;">
  28. <el-tabs v-model="tabActiveName" @tab-click="tabHandleClick">
  29. <el-tab-pane label="实时视频" name="media">
  30. <div style="display: flex; margin-bottom: 0.5rem; height: 2.5rem;">
  31. <span style="width: 5rem; line-height: 2.5rem; text-align: right;">播放地址:</span>
  32. <el-input v-model="getPlayerShared.sharedUrl" :disabled="true">
  33. <template slot="append">
  34. <i class="cpoy-btn el-icon-document-copy" title="点击拷贝" v-clipboard="getPlayerShared.sharedUrl"
  35. @success="$message({type:'success', message:'成功拷贝到粘贴板'})"></i>
  36. </template>
  37. </el-input>
  38. </div>
  39. <div style="display: flex; margin-bottom: 0.5rem; height: 2.5rem;">
  40. <span style="width: 5rem; line-height: 2.5rem; text-align: right;">iframe:</span>
  41. <el-input v-model="getPlayerShared.sharedIframe" :disabled="true">
  42. <template slot="append">
  43. <i class="cpoy-btn el-icon-document-copy" title="点击拷贝" v-clipboard="getPlayerShared.sharedIframe"
  44. @success="$message({type:'success', message:'成功拷贝到粘贴板'})"></i>
  45. </template>
  46. </el-input>
  47. </div>
  48. <div style="display: flex; margin-bottom: 0.5rem; height: 2.5rem;">
  49. <span style="width: 5rem; line-height: 2.5rem; text-align: right;">资源地址:</span>
  50. <el-input v-model="getPlayerShared.sharedRtmp" :disabled="true">
  51. <el-button slot="append" icon="el-icon-document-copy" title="点击拷贝"
  52. v-clipboard="getPlayerShared.sharedRtmp"
  53. @success="$message({type:'success', message:'成功拷贝到粘贴板'})"></el-button>
  54. <el-dropdown slot="prepend" v-if="streamInfo" trigger="click" @command="copyUrl">
  55. <el-button>
  56. 更多地址<i class="el-icon-arrow-down el-icon--right"></i>
  57. </el-button>
  58. <el-dropdown-menu slot="dropdown">
  59. <el-dropdown-item v-if="streamInfo.flv" :command="streamInfo.flv">
  60. <el-tag>FLV:</el-tag>
  61. <span>{{ streamInfo.flv }}</span>
  62. </el-dropdown-item>
  63. <el-dropdown-item v-if="streamInfo.https_flv" :command="streamInfo.https_flv">
  64. <el-tag>FLV(https):</el-tag>
  65. <span>{{ streamInfo.https_flv }}</span>
  66. </el-dropdown-item>
  67. <el-dropdown-item v-if="streamInfo.ws_flv" :command="streamInfo.ws_flv">
  68. <el-tag>FLV(ws):</el-tag>
  69. <span>{{ streamInfo.ws_flv }}</span>
  70. </el-dropdown-item>
  71. <el-dropdown-item v-if="streamInfo.wss_flv" :command="streamInfo.wss_flv">
  72. <el-tag>FLV(wss):</el-tag>
  73. <span>{{ streamInfo.wss_flv }}</span>
  74. </el-dropdown-item>
  75. <el-dropdown-item v-if="streamInfo.fmp4" :command="streamInfo.fmp4">
  76. <el-tag>FMP4:</el-tag>
  77. <span>{{ streamInfo.fmp4 }}</span>
  78. </el-dropdown-item>
  79. <el-dropdown-item v-if="streamInfo.https_fmp4" :command="streamInfo.https_fmp4">
  80. <el-tag>FMP4(https):</el-tag>
  81. <span>{{ streamInfo.https_fmp4 }}</span>
  82. </el-dropdown-item>
  83. <el-dropdown-item v-if="streamInfo.ws_fmp4" :command="streamInfo.ws_fmp4">
  84. <el-tag>FMP4(ws):</el-tag>
  85. <span>{{ streamInfo.ws_fmp4 }}</span>
  86. </el-dropdown-item>
  87. <el-dropdown-item v-if="streamInfo.wss_fmp4" :command="streamInfo.wss_fmp4">
  88. <el-tag>FMP4(wss):</el-tag>
  89. <span>{{ streamInfo.wss_fmp4 }}</span>
  90. </el-dropdown-item>
  91. <el-dropdown-item v-if="streamInfo.hls" :command="streamInfo.hls">
  92. <el-tag>HLS:</el-tag>
  93. <span>{{ streamInfo.hls }}</span>
  94. </el-dropdown-item>
  95. <el-dropdown-item v-if="streamInfo.https_hls" :command="streamInfo.https_hls">
  96. <el-tag>HLS(https):</el-tag>
  97. <span>{{ streamInfo.https_hls }}</span>
  98. </el-dropdown-item>
  99. <el-dropdown-item v-if="streamInfo.ws_hls" :command="streamInfo.ws_hls">
  100. <el-tag>HLS(ws):</el-tag>
  101. <span>{{ streamInfo.ws_hls }}</span>
  102. </el-dropdown-item>
  103. <el-dropdown-item v-if="streamInfo.wss_hls" :command="streamInfo.wss_hls">
  104. <el-tag>HLS(wss):</el-tag>
  105. <span>{{ streamInfo.wss_hls }}</span>
  106. </el-dropdown-item>
  107. <el-dropdown-item v-if="streamInfo.ts" :command="streamInfo.ts">
  108. <el-tag>TS:</el-tag>
  109. <span>{{ streamInfo.ts }}</span>
  110. </el-dropdown-item>
  111. <el-dropdown-item v-if="streamInfo.https_ts" :command="streamInfo.https_ts">
  112. <el-tag>TS(https):</el-tag>
  113. <span>{{ streamInfo.https_ts }}</span>
  114. </el-dropdown-item>
  115. <el-dropdown-item v-if="streamInfo.ws_ts" :command="streamInfo.ws_ts">
  116. <el-tag>TS(ws):</el-tag>
  117. <span>{{ streamInfo.ws_ts }}</span>
  118. </el-dropdown-item>
  119. <el-dropdown-item v-if="streamInfo.wss_ts" :command="streamInfo.wss_ts">
  120. <el-tag>TS(wss):</el-tag>
  121. <span>{{ streamInfo.wss_ts }}</span>
  122. </el-dropdown-item>
  123. <el-dropdown-item v-if="streamInfo.rtc" :command="streamInfo.rtc">
  124. <el-tag>RTC:</el-tag>
  125. <span>{{ streamInfo.rtc }}</span>
  126. </el-dropdown-item>
  127. <el-dropdown-item v-if="streamInfo.rtcs" :command="streamInfo.rtcs">
  128. <el-tag>RTCS:</el-tag>
  129. <span>{{ streamInfo.rtcs }}</span>
  130. </el-dropdown-item>
  131. <el-dropdown-item v-if="streamInfo.rtmp" :command="streamInfo.rtmp">
  132. <el-tag>RTMP:</el-tag>
  133. <span>{{ streamInfo.rtmp }}</span>
  134. </el-dropdown-item>
  135. <el-dropdown-item v-if="streamInfo.rtmps" :command="streamInfo.rtmps">
  136. <el-tag>RTMPS:</el-tag>
  137. <span>{{ streamInfo.rtmps }}</span>
  138. </el-dropdown-item>
  139. <el-dropdown-item v-if="streamInfo.rtsp" :command="streamInfo.rtsp">
  140. <el-tag>RTSP:</el-tag>
  141. <span>{{ streamInfo.rtsp }}</span>
  142. </el-dropdown-item>
  143. <el-dropdown-item v-if="streamInfo.rtsps" :command="streamInfo.rtsps">
  144. <el-tag>RTSPS:</el-tag>
  145. <span>{{ streamInfo.rtsps }}</span>
  146. </el-dropdown-item>
  147. </el-dropdown-menu>
  148. </el-dropdown>
  149. </el-input>
  150. </div>
  151. </el-tab-pane>
  152. <!--{"code":0,"data":{"paths":["22-29-30.mp4"],"rootPath":"/home/kkkkk/Documents/ZLMediaKit/release/linux/Debug/www/record/hls/kkkkk/2020-05-11/"}}-->
  153. <!--遥控界面-->
  154. <el-tab-pane label="云台控制" name="control" v-if="showPtz">
  155. <div style="display: flex; justify-content: left;">
  156. <div class="control-wrapper">
  157. <div class="control-btn control-top" @mousedown="ptzCamera('up')" @mouseup="ptzCamera('stop')">
  158. <i class="el-icon-caret-top"></i>
  159. <div class="control-inner-btn control-inner"></div>
  160. </div>
  161. <div class="control-btn control-left" @mousedown="ptzCamera('left')" @mouseup="ptzCamera('stop')">
  162. <i class="el-icon-caret-left"></i>
  163. <div class="control-inner-btn control-inner"></div>
  164. </div>
  165. <div class="control-btn control-bottom" @mousedown="ptzCamera('down')" @mouseup="ptzCamera('stop')">
  166. <i class="el-icon-caret-bottom"></i>
  167. <div class="control-inner-btn control-inner"></div>
  168. </div>
  169. <div class="control-btn control-right" @mousedown="ptzCamera('right')" @mouseup="ptzCamera('stop')">
  170. <i class="el-icon-caret-right"></i>
  171. <div class="control-inner-btn control-inner"></div>
  172. </div>
  173. <div class="control-round">
  174. <div class="control-round-inner"><i class="fa fa-pause-circle"></i></div>
  175. </div>
  176. <div style="position: absolute; left: 7.25rem; top: 1.25rem" @mousedown="ptzCamera('zoomin')"
  177. @mouseup="ptzCamera('stop')"><i class="el-icon-zoom-in control-zoom-btn"
  178. style="font-size: 1.875rem;"></i></div>
  179. <div style="position: absolute; left: 7.25rem; top: 3.25rem; font-size: 1.875rem;"
  180. @mousedown="ptzCamera('zoomout')" @mouseup="ptzCamera('stop')"><i
  181. class="el-icon-zoom-out control-zoom-btn"></i></div>
  182. <div class="contro-speed" style="position: absolute; left: 4px; top: 7rem; width: 9rem;">
  183. <el-slider v-model="controSpeed" :max="255"></el-slider>
  184. </div>
  185. </div>
  186. <div class="control-panel">
  187. <el-button-group>
  188. <el-tag style="position :absolute; left: 0rem; top: 0rem; width: 5rem; text-align: center"
  189. size="medium">预置位编号
  190. </el-tag>
  191. <el-input-number style="position: absolute; left: 5rem; top: 0rem; width: 6rem" size="mini"
  192. v-model="presetPos" controls-position="right" :precision="0" :step="1" :min="1"
  193. :max="255"></el-input-number>
  194. <el-button style="position: absolute; left: 11rem; top: 0rem; width: 5rem" size="mini"
  195. icon="el-icon-add-location" @click="presetPosition(129, presetPos)">设置
  196. </el-button>
  197. <el-button style="position: absolute; left: 27rem; top: 0rem; width: 5rem" size="mini" type="primary"
  198. icon="el-icon-place" @click="presetPosition(130, presetPos)">调用
  199. </el-button>
  200. <el-button style="position: absolute; left: 16rem; top: 0rem; width: 5rem" size="mini"
  201. icon="el-icon-delete-location" @click="presetPosition(131, presetPos)">删除
  202. </el-button>
  203. <el-tag style="position :absolute; left: 0rem; top: 2.5rem; width: 5rem; text-align: center"
  204. size="medium">巡航速度
  205. </el-tag>
  206. <el-input-number style="position: absolute; left: 5rem; top: 2.5rem; width: 6rem" size="mini"
  207. v-model="cruisingSpeed" controls-position="right" :precision="0" :min="1"
  208. :max="4095"></el-input-number>
  209. <el-button style="position: absolute; left: 11rem; top: 2.5rem; width: 5rem" size="mini"
  210. icon="el-icon-loading" @click="setSpeedOrTime(134, cruisingGroup, cruisingSpeed)">设置
  211. </el-button>
  212. <el-tag style="position :absolute; left: 16rem; top: 2.5rem; width: 5rem; text-align: center"
  213. size="medium">停留时间
  214. </el-tag>
  215. <el-input-number style="position: absolute; left: 21rem; top: 2.5rem; width: 6rem" size="mini"
  216. v-model="cruisingTime" controls-position="right" :precision="0" :min="1"
  217. :max="4095"></el-input-number>
  218. <el-button style="position: absolute; left: 27rem; top: 2.5rem; width: 5rem" size="mini"
  219. icon="el-icon-timer" @click="setSpeedOrTime(135, cruisingGroup, cruisingTime)">设置
  220. </el-button>
  221. <el-tag style="position :absolute; left: 0rem; top: 4.5rem; width: 5rem; text-align: center"
  222. size="medium">巡航组编号
  223. </el-tag>
  224. <el-input-number style="position: absolute; left: 5rem; top: 4.5rem; width: 6rem" size="mini"
  225. v-model="cruisingGroup" controls-position="right" :precision="0" :min="0"
  226. :max="255"></el-input-number>
  227. <el-button style="position: absolute; left: 11rem; top: 4.5rem; width: 5rem" size="mini"
  228. icon="el-icon-add-location" @click="setCommand(132, cruisingGroup, presetPos)">添加点
  229. </el-button>
  230. <el-button style="position: absolute; left: 16rem; top: 4.5rem; width: 5rem" size="mini"
  231. icon="el-icon-delete-location" @click="setCommand(133, cruisingGroup, presetPos)">删除点
  232. </el-button>
  233. <el-button style="position: absolute; left: 21rem; top: 4.5rem; width: 5rem" size="mini"
  234. icon="el-icon-delete" @click="setCommand(133, cruisingGroup, 0)">删除组
  235. </el-button>
  236. <el-button style="position: absolute; left: 27rem; top: 5rem; width: 5rem" size="mini" type="primary"
  237. icon="el-icon-video-camera-solid" @click="setCommand(136, cruisingGroup, 0)">巡航
  238. </el-button>
  239. <el-tag style="position :absolute; left: 0rem; top: 7rem; width: 5rem; text-align: center"
  240. size="medium">扫描速度
  241. </el-tag>
  242. <el-input-number style="position: absolute; left: 5rem; top: 7rem; width: 6rem" size="mini"
  243. v-model="scanSpeed" controls-position="right" :precision="0" :min="1"
  244. :max="4095"></el-input-number>
  245. <el-button style="position: absolute; left: 11rem; top: 7rem; width: 5rem" size="mini"
  246. icon="el-icon-loading" @click="setSpeedOrTime(138, scanGroup, scanSpeed)">设置
  247. </el-button>
  248. <el-tag style="position :absolute; left: 0rem; top: 9rem; width: 5rem; text-align: center"
  249. size="medium">扫描组编号
  250. </el-tag>
  251. <el-input-number style="position: absolute; left: 5rem; top: 9rem; width: 6rem" size="mini"
  252. v-model="scanGroup" controls-position="right" :precision="0" :step="1" :min="0"
  253. :max="255"></el-input-number>
  254. <el-button style="position: absolute; left: 11rem; top: 9rem; width: 5rem" size="mini"
  255. icon="el-icon-d-arrow-left" @click="setCommand(137, scanGroup, 1)">左边界
  256. </el-button>
  257. <el-button style="position: absolute; left: 16rem; top: 9rem; width: 5rem" size="mini"
  258. icon="el-icon-d-arrow-right" @click="setCommand(137, scanGroup, 2)">右边界
  259. </el-button>
  260. <el-button style="position: absolute; left: 27rem; top: 7rem; width: 5rem" size="mini" type="primary"
  261. icon="el-icon-video-camera-solid" @click="setCommand(137, scanGroup, 0)">扫描
  262. </el-button>
  263. <el-button style="position: absolute; left: 27rem; top: 9rem; width: 5rem" size="mini" type="danger"
  264. icon="el-icon-switch-button" @click="ptzCamera('stop')">停止
  265. </el-button>
  266. </el-button-group>
  267. </div>
  268. </div>
  269. </el-tab-pane>
  270. <el-tab-pane label="编码信息" name="codec" v-loading="tracksLoading">
  271. <p>
  272. 无法播放或者没有声音?&nbsp&nbsp&nbsp试一试&nbsp
  273. <el-button size="mini" type="primary" v-if="!coverPlaying" @click="coverPlay">转码播放</el-button>
  274. <el-button size="mini" type="danger" v-if="coverPlaying" @click="convertStopClick">停止转码</el-button>
  275. </p>
  276. <div class="trank">
  277. <p v-if="tracksNotLoaded" style="text-align: center;padding-top: 3rem;">暂无数据</p>
  278. <div v-for="(item, index) in tracks" style="width: 50%; float: left" loading>
  279. <span>流 {{ index }}</span>
  280. <div class="trankInfo" v-if="item.codec_type == 0">
  281. <p>格式: {{ item.codec_id_name }}</p>
  282. <p>类型: 视频</p>
  283. <p>分辨率: {{ item.width }} x {{ item.height }}</p>
  284. <p>帧率: {{ item.fps }}</p>
  285. </div>
  286. <div class="trankInfo" v-if="item.codec_type == 1">
  287. <p>格式: {{ item.codec_id_name }}</p>
  288. <p>类型: 音频</p>
  289. <p>采样位数: {{ item.sample_bit }}</p>
  290. <p>采样率: {{ item.sample_rate }}</p>
  291. </div>
  292. </div>
  293. </div>
  294. </el-tab-pane>
  295. <el-tab-pane label="语音对讲" name="broadcast">
  296. <div class="trank" style="text-align: center;">
  297. <el-button @click="broadcastStatusClick()" :type="getBroadcastStatus()" :disabled="broadcastStatus === -2"
  298. circle icon="el-icon-microphone" style="font-size: 32px; padding: 24px;margin-top: 24px;"/>
  299. <p>
  300. <span v-if="broadcastStatus === -2">正在释放资源</span>
  301. <span v-if="broadcastStatus === -1">点击开始对讲</span>
  302. <span v-if="broadcastStatus === 0">等待接通中...</span>
  303. <span v-if="broadcastStatus === 1">请说话</span>
  304. </p>
  305. </div>
  306. </el-tab-pane>
  307. </el-tabs>
  308. </div>
  309. </el-dialog>
  310. </div>
  311. </template>
  312. <script>
  313. import rtcPlayer from '../dialog/rtcPlayer.vue'
  314. import LivePlayer from '@liveqing/liveplayer'
  315. import crypto from 'crypto'
  316. import jessibucaPlayer from '../common/jessibuca.vue'
  317. export default {
  318. name: 'devicePlayer',
  319. props: {},
  320. components: {
  321. LivePlayer, jessibucaPlayer, rtcPlayer,
  322. },
  323. computed: {
  324. getPlayerShared: function () {
  325. return {
  326. sharedUrl: window.location.origin + '/#/play/wasm/' + encodeURIComponent(this.videoUrl),
  327. sharedIframe: '<iframe src="' + window.location.origin + '/#/play/wasm/' + encodeURIComponent(this.videoUrl) + '"></iframe>',
  328. sharedRtmp: this.videoUrl
  329. };
  330. }
  331. },
  332. created() {
  333. console.log("created")
  334. console.log(this.player)
  335. this.broadcastStatus = -1;
  336. if (Object.keys(this.player).length === 1) {
  337. this.activePlayer = Object.keys(this.player)[0]
  338. }
  339. },
  340. data() {
  341. return {
  342. video: 'http://lndxyj.iqilu.com/public/upload/2019/10/14/8c001ea0c09cdc59a57829dabc8010fa.mp4',
  343. videoUrl: '',
  344. activePlayer: "jessibuca",
  345. // 如何你只是用一种播放器,直接注释掉不用的部分即可
  346. player: {
  347. jessibuca: ["ws_flv", "wss_flv"],
  348. webRTC: ["rtc", "rtcs"],
  349. },
  350. showVideoDialog: false,
  351. streamId: '',
  352. app: '',
  353. mediaServerId: '',
  354. convertKey: '',
  355. deviceId: '',
  356. channelId: '',
  357. tabActiveName: 'media',
  358. hasAudio: false,
  359. loadingRecords: false,
  360. recordsLoading: false,
  361. isLoging: false,
  362. controSpeed: 30,
  363. timeVal: 0,
  364. timeMin: 0,
  365. timeMax: 1440,
  366. presetPos: 1,
  367. cruisingSpeed: 100,
  368. cruisingTime: 5,
  369. cruisingGroup: 0,
  370. scanSpeed: 100,
  371. scanGroup: 0,
  372. tracks: [],
  373. coverPlaying: false,
  374. tracksLoading: false,
  375. showPtz: true,
  376. showRrecord: true,
  377. tracksNotLoaded: false,
  378. sliderTime: 0,
  379. seekTime: 0,
  380. recordStartTime: 0,
  381. showTimeText: "00:00:00",
  382. streamInfo: null,
  383. broadcastRtc: null,
  384. broadcastStatus: -1, // -2 正在释放资源 -1 默认状态 0 等待接通 1 接通成功
  385. };
  386. },
  387. methods: {
  388. tabHandleClick: function (tab, event) {
  389. console.log(tab)
  390. var that = this;
  391. that.tracks = [];
  392. that.tracksLoading = true;
  393. that.tracksNotLoaded = false;
  394. if (tab.name === "codec") {
  395. this.$axios({
  396. method: 'get',
  397. url: '/zlm/' + this.mediaServerId + '/index/api/getMediaInfo?vhost=__defaultVhost__&schema=rtsp&app=' + this.app + '&stream=' + this.streamId
  398. }).then(function (res) {
  399. that.tracksLoading = false;
  400. if (res.data.code == 0 && res.data.tracks) {
  401. that.tracks = res.data.tracks;
  402. } else {
  403. that.tracksNotLoaded = true;
  404. that.$message({
  405. showClose: true,
  406. message: '获取编码信息失败,',
  407. type: 'warning'
  408. });
  409. }
  410. }).catch(function (e) {
  411. });
  412. }
  413. },
  414. changePlayer: function (tab) {
  415. console.log(this.player[tab.name][0])
  416. this.activePlayer = tab.name;
  417. this.videoUrl = this.getUrlByStreamInfo()
  418. console.log(this.videoUrl)
  419. },
  420. openDialog: function (tab, deviceId, channelId, param) {
  421. if (this.showVideoDialog) {
  422. return;
  423. }
  424. this.tabActiveName = tab;
  425. this.channelId = channelId;
  426. this.deviceId = deviceId;
  427. this.streamId = "";
  428. this.mediaServerId = "";
  429. this.app = "";
  430. this.videoUrl = ""
  431. if (!!this.$refs[this.activePlayer]) {
  432. this.$refs[this.activePlayer].pause();
  433. }
  434. switch (tab) {
  435. case "media":
  436. this.play(param.streamInfo, param.hasAudio)
  437. break;
  438. case "streamPlay":
  439. this.tabActiveName = "media";
  440. this.showRrecord = false;
  441. this.showPtz = false;
  442. this.play(param.streamInfo, param.hasAudio)
  443. break;
  444. case "control":
  445. break;
  446. }
  447. },
  448. play: function (streamInfo, hasAudio) {
  449. this.streamInfo = streamInfo;
  450. this.hasAudio = hasAudio;
  451. this.isLoging = false;
  452. // this.videoUrl = streamInfo.rtc;
  453. this.videoUrl = this.getUrlByStreamInfo();
  454. this.streamId = streamInfo.stream;
  455. this.app = streamInfo.app;
  456. this.mediaServerId = streamInfo.mediaServerId;
  457. this.playFromStreamInfo(false, streamInfo)
  458. },
  459. getUrlByStreamInfo() {
  460. console.log(this.streamInfo)
  461. if (location.protocol === "https:") {
  462. this.videoUrl = this.streamInfo[this.player[this.activePlayer][1]]
  463. } else {
  464. this.videoUrl = this.streamInfo[this.player[this.activePlayer][0]]
  465. }
  466. return this.videoUrl;
  467. },
  468. coverPlay: function () {
  469. var that = this;
  470. this.coverPlaying = true;
  471. this.$refs[this.activePlayer].pause()
  472. that.$axios({
  473. method: 'post',
  474. url: '/api/play/convert/' + that.streamId
  475. }).then(function (res) {
  476. if (res.data.code === 0) {
  477. that.convertKey = res.data.key;
  478. setTimeout(() => {
  479. that.isLoging = false;
  480. that.playFromStreamInfo(false, res.data.data);
  481. }, 2000)
  482. } else {
  483. that.isLoging = false;
  484. that.coverPlaying = false;
  485. that.$message({
  486. showClose: true,
  487. message: '转码失败',
  488. type: 'error'
  489. });
  490. }
  491. }).catch(function (e) {
  492. console.log(e)
  493. that.coverPlaying = false;
  494. that.$message({
  495. showClose: true,
  496. message: '播放错误',
  497. type: 'error'
  498. });
  499. });
  500. },
  501. convertStopClick: function () {
  502. this.convertStop(() => {
  503. this.$refs[this.activePlayer].play(this.videoUrl)
  504. });
  505. },
  506. convertStop: function (callback) {
  507. var that = this;
  508. that.$refs.videoPlayer.pause()
  509. this.$axios({
  510. method: 'post',
  511. url: '/api/play/convertStop/' + this.convertKey
  512. }).then(function (res) {
  513. if (res.data.code == 0) {
  514. console.log(res.data.msg)
  515. } else {
  516. console.error(res.data.msg)
  517. }
  518. if (callback) callback();
  519. }).catch(function (e) {
  520. });
  521. that.coverPlaying = false;
  522. that.convertKey = "";
  523. // if (callback )callback();
  524. },
  525. playFromStreamInfo: function (realHasAudio, streamInfo) {
  526. this.showVideoDialog = true;
  527. this.hasaudio = realHasAudio && this.hasaudio;
  528. this.$refs[this.activePlayer].play(this.getUrlByStreamInfo(streamInfo))
  529. },
  530. close: function () {
  531. console.log('关闭视频');
  532. if (!!this.$refs[this.activePlayer]) {
  533. this.$refs[this.activePlayer].pause();
  534. }
  535. this.videoUrl = '';
  536. this.coverPlaying = false;
  537. this.showVideoDialog = false;
  538. if (this.convertKey != '') {
  539. this.convertStop();
  540. }
  541. this.convertKey = ''
  542. this.stopBroadcast()
  543. },
  544. copySharedInfo: function (data) {
  545. console.log('复制内容:' + data);
  546. this.coverPlaying = false;
  547. this.tracks = []
  548. let _this = this;
  549. this.$copyText(data).then(
  550. function (e) {
  551. _this.$message({
  552. showClose: true,
  553. message: '复制成功',
  554. type: 'success'
  555. });
  556. },
  557. function (e) {
  558. _this.$message({
  559. showClose: true,
  560. message: '复制失败,请手动复制',
  561. type: 'error'
  562. });
  563. }
  564. );
  565. },
  566. ptzCamera: function (command) {
  567. console.log('云台控制:' + command);
  568. let that = this;
  569. this.$axios({
  570. method: 'post',
  571. url: '/api/ptz/control/' + this.deviceId + '/' + this.channelId + '?command=' + command + '&horizonSpeed=' + this.controSpeed + '&verticalSpeed=' + this.controSpeed + '&zoomSpeed=' + this.controSpeed
  572. }).then(function (res) {
  573. });
  574. },
  575. //////////////////////播放器事件处理//////////////////////////
  576. videoError: function (e) {
  577. console.log("播放器错误:" + JSON.stringify(e));
  578. },
  579. presetPosition: function (cmdCode, presetPos) {
  580. console.log('预置位控制:' + this.presetPos + ' : 0x' + cmdCode.toString(16));
  581. let that = this;
  582. this.$axios({
  583. method: 'post',
  584. url: '/api/ptz/front_end_command/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + cmdCode + '&parameter1=0&parameter2=' + presetPos + '&combindCode2=0'
  585. }).then(function (res) {
  586. });
  587. },
  588. setSpeedOrTime: function (cmdCode, groupNum, parameter) {
  589. let that = this;
  590. let parameter2 = parameter % 256;
  591. let combindCode2 = Math.floor(parameter / 256) * 16;
  592. console.log('前端控制:0x' + cmdCode.toString(16) + ' 0x' + groupNum.toString(16) + ' 0x' + parameter2.toString(16) + ' 0x' + combindCode2.toString(16));
  593. this.$axios({
  594. method: 'post',
  595. url: '/api/ptz/front_end_command/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + cmdCode + '&parameter1=' + groupNum + '&parameter2=' + parameter2 + '&combindCode2=' + combindCode2
  596. }).then(function (res) {
  597. });
  598. },
  599. setCommand: function (cmdCode, groupNum, parameter) {
  600. let that = this;
  601. console.log('前端控制:0x' + cmdCode.toString(16) + ' 0x' + groupNum.toString(16) + ' 0x' + parameter.toString(16) + ' 0x0');
  602. this.$axios({
  603. method: 'post',
  604. url: '/api/ptz/front_end_command/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + cmdCode + '&parameter1=' + groupNum + '&parameter2=' + parameter + '&combindCode2=0'
  605. }).then(function (res) {
  606. });
  607. },
  608. copyUrl: function (dropdownItem) {
  609. console.log(dropdownItem)
  610. this.$copyText(dropdownItem).then((e) => {
  611. this.$message.success("成功拷贝到粘贴板");
  612. }, (e) => {
  613. })
  614. },
  615. getBroadcastStatus() {
  616. if (this.broadcastStatus == -2) {
  617. return "primary"
  618. }
  619. if (this.broadcastStatus == -1) {
  620. return "primary"
  621. }
  622. if (this.broadcastStatus == 0) {
  623. return "warning"
  624. }
  625. if (this.broadcastStatus == 1) {
  626. return "danger"
  627. }
  628. },
  629. broadcastStatusClick() {
  630. if (this.broadcastStatus == -1) {
  631. // 默认状态, 开始
  632. this.broadcastStatus = 0
  633. // 发起语音对讲
  634. this.$axios({
  635. method: 'get',
  636. url: '/api/play/broadcast/' + this.deviceId + '/' + this.channelId + "?timeout=30"
  637. }).then( (res)=> {
  638. if (res.data.code == 0) {
  639. let streamInfo = res.data.data.streamInfo;
  640. if (document.location.protocol.includes("https")) {
  641. this.startBroadcast(streamInfo.rtcs)
  642. }else {
  643. this.startBroadcast(streamInfo.rtc)
  644. }
  645. }else {
  646. this.$message({
  647. showClose: true,
  648. message: res.data.msg,
  649. type: "error",
  650. });
  651. }
  652. });
  653. }else if (this.broadcastStatus === 1) {
  654. this.broadcastStatus = -1;
  655. this.broadcastRtc.close()
  656. }
  657. },
  658. startBroadcast(url) {
  659. // 获取推流鉴权Key
  660. this.$axios({
  661. method: 'post',
  662. url: '/api/user/userInfo',
  663. }).then((res) => {
  664. if (res.data.code !== 0) {
  665. this.$message({
  666. showClose: true,
  667. message: "获取推流鉴权Key失败",
  668. type: "error",
  669. });
  670. this.broadcastStatus = -1;
  671. } else {
  672. let pushKey = res.data.data.pushKey;
  673. // 获取推流鉴权KEY
  674. url += "&sign=" + crypto.createHash('md5').update(pushKey, "utf8").digest('hex')
  675. console.log("开始语音对讲: " + url)
  676. this.broadcastRtc = new ZLMRTCClient.Endpoint({
  677. debug: true, // 是否打印日志
  678. zlmsdpUrl: url, //流地址
  679. simulecast: false,
  680. useCamera: false,
  681. audioEnable: true,
  682. videoEnable: false,
  683. recvOnly: false,
  684. })
  685. // webrtcPlayer.on(ZLMRTCClient.Events.WEBRTC_ON_REMOTE_STREAMS,(e)=>{//获取到了远端流,可以播放
  686. // console.error('播放成功',e.streams)
  687. // this.broadcastStatus = 1;
  688. // });
  689. //
  690. // webrtcPlayer.on(ZLMRTCClient.Events.WEBRTC_ON_LOCAL_STREAM,(s)=>{// 获取到了本地流
  691. // this.broadcastStatus = 1;
  692. // // document.getElementById('selfVideo').srcObject=s;
  693. // // this.eventcallbacK("LOCAL STREAM", "获取到了本地流")
  694. // });
  695. this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_NOT_SUPPORT, (e) => {// 获取到了本地流
  696. console.error('不支持webrtc', e)
  697. this.$message({
  698. showClose: true,
  699. message: '不支持webrtc, 无法进行语音对讲',
  700. type: 'error'
  701. });
  702. this.broadcastStatus = -1;
  703. });
  704. this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_ICE_CANDIDATE_ERROR, (e) => {// ICE 协商出错
  705. console.error('ICE 协商出错')
  706. this.$message({
  707. showClose: true,
  708. message: 'ICE 协商出错',
  709. type: 'error'
  710. });
  711. this.broadcastStatus = -1;
  712. });
  713. this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED, (e) => {// offer anwser 交换失败
  714. console.error('offer anwser 交换失败', e)
  715. this.$message({
  716. showClose: true,
  717. message: 'offer anwser 交换失败' + e,
  718. type: 'error'
  719. });
  720. this.broadcastStatus = -1;
  721. });
  722. this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_ON_CONNECTION_STATE_CHANGE, (e) => {// offer anwser 交换失败
  723. console.log('状态改变', e)
  724. if (e === "connecting") {
  725. this.broadcastStatus = 0;
  726. } else if (e === "connected") {
  727. this.broadcastStatus = 1;
  728. } else if (e === "disconnected") {
  729. this.broadcastStatus = -1;
  730. }
  731. });
  732. this.broadcastRtc.on(ZLMRTCClient.Events.CAPTURE_STREAM_FAILED, (e) => {// offer anwser 交换失败
  733. console.log('捕获流失败', e)
  734. this.$message({
  735. showClose: true,
  736. message: '捕获流失败' + e,
  737. type: 'error'
  738. });
  739. this.broadcastStatus = -1;
  740. });
  741. }
  742. }).catch((e) => {
  743. this.$message({
  744. showClose: true,
  745. message: e,
  746. type: 'error'
  747. });
  748. this.broadcastStatus = -1;
  749. });
  750. },
  751. stopBroadcast() {
  752. this.broadcastRtc.close();
  753. this.broadcastStatus = -1;
  754. this.$axios({
  755. method: 'get',
  756. url: '/api/play/broadcast/stop/' + this.deviceId + '/' + this.channelId
  757. }).then((res) => {
  758. if (res.data.code == 0) {
  759. // this.broadcastStatus = -1;
  760. // this.broadcastRtc.close()
  761. } else {
  762. this.$message({
  763. showClose: true,
  764. message: res.data.msg,
  765. type: "error",
  766. });
  767. }
  768. });
  769. }
  770. }
  771. };
  772. </script>
  773. <style>
  774. .control-wrapper {
  775. position: relative;
  776. width: 6.25rem;
  777. height: 6.25rem;
  778. max-width: 6.25rem;
  779. max-height: 6.25rem;
  780. border-radius: 100%;
  781. margin-top: 1.5rem;
  782. margin-left: 0.5rem;
  783. float: left;
  784. }
  785. .control-panel {
  786. position: relative;
  787. top: 0;
  788. left: 5rem;
  789. height: 11rem;
  790. max-height: 11rem;
  791. }
  792. .control-btn {
  793. display: flex;
  794. justify-content: center;
  795. position: absolute;
  796. width: 44%;
  797. height: 44%;
  798. border-radius: 5px;
  799. border: 1px solid #78aee4;
  800. box-sizing: border-box;
  801. transition: all 0.3s linear;
  802. }
  803. .control-btn:hover {
  804. cursor: pointer
  805. }
  806. .control-btn i {
  807. font-size: 20px;
  808. color: #78aee4;
  809. display: flex;
  810. justify-content: center;
  811. align-items: center;
  812. }
  813. .control-btn i:hover {
  814. cursor: pointer
  815. }
  816. .control-zoom-btn:hover {
  817. cursor: pointer
  818. }
  819. .control-round {
  820. position: absolute;
  821. top: 21%;
  822. left: 21%;
  823. width: 58%;
  824. height: 58%;
  825. background: #fff;
  826. border-radius: 100%;
  827. }
  828. .control-round-inner {
  829. position: absolute;
  830. left: 13%;
  831. top: 13%;
  832. display: flex;
  833. justify-content: center;
  834. align-items: center;
  835. width: 70%;
  836. height: 70%;
  837. font-size: 40px;
  838. color: #78aee4;
  839. border: 1px solid #78aee4;
  840. border-radius: 100%;
  841. transition: all 0.3s linear;
  842. }
  843. .control-inner-btn {
  844. position: absolute;
  845. width: 60%;
  846. height: 60%;
  847. background: #fafafa;
  848. }
  849. .control-top {
  850. top: -8%;
  851. left: 27%;
  852. transform: rotate(-45deg);
  853. border-radius: 5px 100% 5px 0;
  854. }
  855. .control-top i {
  856. transform: rotate(45deg);
  857. border-radius: 5px 100% 5px 0;
  858. }
  859. .control-top .control-inner {
  860. left: -1px;
  861. bottom: 0;
  862. border-top: 1px solid #78aee4;
  863. border-right: 1px solid #78aee4;
  864. border-radius: 0 100% 0 0;
  865. }
  866. .control-top .fa {
  867. transform: rotate(45deg) translateY(-7px);
  868. }
  869. .control-left {
  870. top: 27%;
  871. left: -8%;
  872. transform: rotate(45deg);
  873. border-radius: 5px 0 5px 100%;
  874. }
  875. .control-left i {
  876. transform: rotate(-45deg);
  877. }
  878. .control-left .control-inner {
  879. right: -1px;
  880. top: -1px;
  881. border-bottom: 1px solid #78aee4;
  882. border-left: 1px solid #78aee4;
  883. border-radius: 0 0 0 100%;
  884. }
  885. .control-left .fa {
  886. transform: rotate(-45deg) translateX(-7px);
  887. }
  888. .control-right {
  889. top: 27%;
  890. right: -8%;
  891. transform: rotate(45deg);
  892. border-radius: 5px 100% 5px 0;
  893. }
  894. .control-right i {
  895. transform: rotate(-45deg);
  896. }
  897. .control-right .control-inner {
  898. left: -1px;
  899. bottom: -1px;
  900. border-top: 1px solid #78aee4;
  901. border-right: 1px solid #78aee4;
  902. border-radius: 0 100% 0 0;
  903. }
  904. .control-right .fa {
  905. transform: rotate(-45deg) translateX(7px);
  906. }
  907. .control-bottom {
  908. left: 27%;
  909. bottom: -8%;
  910. transform: rotate(45deg);
  911. border-radius: 0 5px 100% 5px;
  912. }
  913. .control-bottom i {
  914. transform: rotate(-45deg);
  915. }
  916. .control-bottom .control-inner {
  917. top: -1px;
  918. left: -1px;
  919. border-bottom: 1px solid #78aee4;
  920. border-right: 1px solid #78aee4;
  921. border-radius: 0 0 100% 0;
  922. }
  923. .control-bottom .fa {
  924. transform: rotate(-45deg) translateY(7px);
  925. }
  926. .trank {
  927. width: 80%;
  928. height: 180px;
  929. text-align: left;
  930. padding: 0 10%;
  931. overflow: auto;
  932. }
  933. .trankInfo {
  934. width: 80%;
  935. padding: 0 10%;
  936. }
  937. </style>