devicePlayer.vue 39 KB

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