devicePlayer.vue 48 KB

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