devicePlayer.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. <template>
  2. <div id="devicePlayer" v-loading="isLoging">
  3. <el-dialog title="视频播放" top="0" :close-on-click-modal="false" :visible.sync="showVideoDialog" :destroy-on-close="true" @close="close()">
  4. <!-- <LivePlayer v-if="showVideoDialog" ref="videoPlayer" :videoUrl="videoUrl" :error="videoError" :message="videoError" :hasaudio="hasaudio" fluent autoplay live></LivePlayer> -->
  5. <player ref="videoPlayer" :visible.sync="showVideoDialog" :videoUrl="videoUrl" :error="videoError" :message="videoError" :hasaudio="hasaudio" fluent autoplay live></player>
  6. <div id="shared" style="text-align: right; margin-top: 1rem;">
  7. <el-tabs v-model="tabActiveName" @tab-click="tabHandleClick">
  8. <el-tab-pane label="实时视频" name="media">
  9. <div style="margin-bottom: 0.5rem;">
  10. <!-- <el-button type="primary" size="small" @click="playRecord(true, '')">播放</el-button>-->
  11. <!-- <el-button type="primary" size="small" @click="startRecord()">录制</el-button>-->
  12. <!-- <el-button type="primary" size="small" @click="stopRecord()">停止录制</el-button>-->
  13. </div>
  14. <div style="display: flex; margin-bottom: 0.5rem; height: 2.5rem;">
  15. <span style="width: 5rem; line-height: 2.5rem; text-align: right;">播放地址:</span>
  16. <el-input v-model="getPlayerShared.sharedUrl" :disabled="true" v-on:click.native="copySharedInfo(getPlayerShared.sharedUrl)"></el-input>
  17. </div>
  18. <div style="display: flex; margin-bottom: 0.5rem; height: 2.5rem;">
  19. <span style="width: 5rem; line-height: 2.5rem; text-align: right;">iframe:</span>
  20. <el-input v-model="getPlayerShared.sharedIframe" :disabled="true" v-on:click.native="copySharedInfo(getPlayerShared.sharedIframe)"></el-input>
  21. </div>
  22. <div style="display: flex; margin-bottom: 0.5rem; height: 2.5rem;">
  23. <span style="width: 5rem; line-height: 2.5rem; text-align: right;">资源地址:</span>
  24. <el-input v-model="getPlayerShared.sharedRtmp" :disabled="true" v-on:click.native="copySharedInfo(getPlayerShared.sharedRtmp)"></el-input>
  25. </div>
  26. </el-tab-pane>
  27. <!--{"code":0,"data":{"paths":["22-29-30.mp4"],"rootPath":"/home/kkkkk/Documents/ZLMediaKit/release/linux/Debug/www/record/hls/kkkkk/2020-05-11/"}}-->
  28. <el-tab-pane label="录像查询" name="record" v-if="showRrecord">
  29. <el-date-picker size="mini" v-model="videoHistory.date" type="date" value-format="yyyy-MM-dd" placeholder="日期" @change="queryRecords()"></el-date-picker>
  30. <el-table :data="videoHistory.searchHistoryResult" height="150" v-loading="recordsLoading">
  31. <el-table-column label="名称" prop="name"></el-table-column>
  32. <el-table-column label="文件" prop="filePath"></el-table-column>
  33. <el-table-column label="开始时间" prop="startTime" :formatter="timeFormatter"></el-table-column>
  34. <el-table-column label="结束时间" prop="endTime" :formatter="timeFormatter"></el-table-column>
  35. <el-table-column label="操作">
  36. <template slot-scope="scope">
  37. <el-button icon="el-icon-video-play" size="mini" @click="playRecord(scope.row)">播放</el-button>
  38. </template>
  39. </el-table-column>
  40. </el-table>
  41. </el-tab-pane>
  42. <!--遥控界面-->
  43. <el-tab-pane label="云台控制" name="control" v-if="showPtz">
  44. <div style="display: flex; justify-content: left;">
  45. <div class="control-wrapper">
  46. <div class="control-btn control-top" @mousedown="ptzCamera(0, 2, 0)" @mouseup="ptzCamera(0, 0, 0)">
  47. <i class="el-icon-caret-top"></i>
  48. <div class="control-inner-btn control-inner"></div>
  49. </div>
  50. <div class="control-btn control-left" @mousedown="ptzCamera(2, 0, 0)" @mouseup="ptzCamera(0, 0, 0)">
  51. <i class="el-icon-caret-left"></i>
  52. <div class="control-inner-btn control-inner"></div>
  53. </div>
  54. <div class="control-btn control-bottom" @mousedown="ptzCamera(0, 1, 0)" @mouseup="ptzCamera(0, 0, 0)">
  55. <i class="el-icon-caret-bottom"></i>
  56. <div class="control-inner-btn control-inner"></div>
  57. </div>
  58. <div class="control-btn control-right" @mousedown="ptzCamera(1, 0, 0)" @mouseup="ptzCamera(0, 0, 0)">
  59. <i class="el-icon-caret-right"></i>
  60. <div class="control-inner-btn control-inner"></div>
  61. </div>
  62. <div class="control-round">
  63. <div class="control-round-inner"><i class="fa fa-pause-circle"></i></div>
  64. </div>
  65. <div style="position: absolute; left: 7.25rem; top: 1.25rem" @mousedown="ptzCamera(0, 0, 1)" @mouseup="ptzCamera(0, 0, 0)"><i class="el-icon-zoom-in control-zoom-btn" style="font-size: 1.875rem;"></i></div>
  66. <div style="position: absolute; left: 7.25rem; top: 3.25rem; font-size: 1.875rem;" @mousedown="ptzCamera(0, 0, 2)" @mouseup="ptzCamera(0, 0, 0)"><i class="el-icon-zoom-out control-zoom-btn"></i></div>
  67. <div class="contro-speed" style="position: absolute; left: 4px; top: 7rem; width: 9rem;">
  68. <el-slider v-model="controSpeed" :max="255"></el-slider>
  69. </div>
  70. </div>
  71. <div class="control-panel">
  72. <el-button-group>
  73. <el-tag style="position :absolute; left: 0rem; top: 0rem; width: 5rem; text-align: center" size="medium" type="info">预置位编号</el-tag>
  74. <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>
  75. <el-button style="position: absolute; left: 11rem; top: 0rem; width: 5rem" size="mini" icon="el-icon-add-location" @click="presetPosition(129, presetPos)">设置</el-button>
  76. <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>
  77. <el-button style="position: absolute; left: 16rem; top: 0rem; width: 5rem" size="mini" icon="el-icon-delete-location" @click="presetPosition(131, presetPos)">删除</el-button>
  78. <el-tag style="position :absolute; left: 0rem; top: 2.5rem; width: 5rem; text-align: center" size="medium" type="info">巡航速度</el-tag>
  79. <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>
  80. <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>
  81. <el-tag style="position :absolute; left: 16rem; top: 2.5rem; width: 5rem; text-align: center" size="medium" type="info">停留时间</el-tag>
  82. <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>
  83. <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>
  84. <el-tag style="position :absolute; left: 0rem; top: 4.5rem; width: 5rem; text-align: center" size="medium" type="info">巡航组编号</el-tag>
  85. <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>
  86. <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>
  87. <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>
  88. <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>
  89. <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>
  90. <el-tag style="position :absolute; left: 0rem; top: 7rem; width: 5rem; text-align: center" size="medium" type="info">扫描速度</el-tag>
  91. <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>
  92. <el-button style="position: absolute; left: 11rem; top: 7rem; width: 5rem" size="mini" icon="el-icon-loading" @click="setSpeedOrTime(138, scanGroup, scanSpeed)">设置</el-button>
  93. <el-tag style="position :absolute; left: 0rem; top: 9rem; width: 5rem; text-align: center" size="medium" type="info">扫描组编号</el-tag>
  94. <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>
  95. <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>
  96. <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>
  97. <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>
  98. <el-button style="position: absolute; left: 27rem; top: 9rem; width: 5rem" size="mini" type="danger" icon="el-icon-switch-button" @click="ptzCamera(0, 0, 0)">停止</el-button>
  99. </el-button-group>
  100. </div>
  101. </div>
  102. </el-tab-pane>
  103. <el-tab-pane label="编码信息" name="codec" v-loading="tracksLoading">
  104. <p>
  105. 无法播放或者没有声音?&nbsp&nbsp&nbsp试一试
  106. <el-button size="mini" type="primary" v-if="!coverPlaying" @click="coverPlay">转码播放</el-button>
  107. <el-button size="mini" type="danger" v-if="coverPlaying" @click="convertStopClick">停止转码</el-button>
  108. </p>
  109. <div class="trank" >
  110. <div v-for="(item, index) in tracks">
  111. <span >流 {{index}}</span>
  112. <div class="trankInfo" v-if="item.codec_type == 0">
  113. <p>格式: {{item.codec_id_name}}</p>
  114. <p>类型: 视频</p>
  115. <p>分辨率: {{item.width}} x {{item.height}}</p>
  116. <p>帧率: {{item.fps}}</p>
  117. </div>
  118. <div class="trankInfo" v-if="item.codec_type == 1">
  119. <p>格式: {{item.codec_id_name}}</p>
  120. <p>类型: 音频</p>
  121. <p>采样位数: {{item.sample_bit}}</p>
  122. <p>采样率: {{item.sample_rate}}</p>
  123. </div>
  124. </div>
  125. </div>
  126. </el-tab-pane>
  127. </el-tabs>
  128. </div>
  129. </el-dialog>
  130. </div>
  131. </template>
  132. <script>
  133. // import player from '../dialog/rtcPlayer.vue'
  134. import player from '../dialog/easyPlayer.vue'
  135. export default {
  136. name: 'devicePlayer',
  137. props: {},
  138. components: {
  139. player,
  140. },
  141. computed: {
  142. getPlayerShared: function () {
  143. return {
  144. sharedUrl: window.location.host + '/' + this.videoUrl,
  145. sharedIframe: '<iframe src="' + window.location.host + '/' + this.videoUrl + '"></iframe>',
  146. sharedRtmp: this.videoUrl
  147. };
  148. }
  149. },
  150. created() {},
  151. data() {
  152. return {
  153. video: 'http://lndxyj.iqilu.com/public/upload/2019/10/14/8c001ea0c09cdc59a57829dabc8010fa.mp4',
  154. videoUrl: '',
  155. videoHistory: {
  156. date: '',
  157. searchHistoryResult: [] //媒体流历史记录搜索结果
  158. },
  159. showVideoDialog: false,
  160. streamId: '',
  161. app : '',
  162. convertKey: '',
  163. deviceId: '',
  164. channelId: '',
  165. tabActiveName: 'media',
  166. hasaudio: false,
  167. loadingRecords: false,
  168. recordsLoading: false,
  169. isLoging: false,
  170. controSpeed: 30,
  171. timeVal: 0,
  172. timeMin: 0,
  173. timeMax: 1440,
  174. presetPos: 1,
  175. cruisingSpeed: 100,
  176. cruisingTime: 5,
  177. cruisingGroup: 0,
  178. scanSpeed: 100,
  179. scanGroup: 0,
  180. tracks: [],
  181. coverPlaying:false,
  182. tracksLoading: false,
  183. recordPlay: "",
  184. showPtz: true,
  185. showRrecord: true,
  186. };
  187. },
  188. methods: {
  189. tabHandleClick: function(tab, event) {
  190. console.log(tab)
  191. var that = this;
  192. that.tracks = [];
  193. that.tracksLoading = true;
  194. if (tab.name == "codec") {
  195. this.$axios({
  196. method: 'get',
  197. url: '/zlm/index/api/getMediaInfo?vhost=__defaultVhost__&schema=rtmp&app='+ this.app +'&stream='+ this.streamId
  198. }).then(function (res) {
  199. that.tracksLoading = false;
  200. if (res.data.code == 0 && res.data.online) {
  201. that.tracks = res.data.tracks;
  202. }else{
  203. that.$message({
  204. showClose: true,
  205. message: '获取编码信息失败,',
  206. type: 'warning'
  207. });
  208. }
  209. }).catch(function (e) {});
  210. }
  211. },
  212. openDialog: function (tab, deviceId, channelId, param) {
  213. this.tabActiveName = tab;
  214. this.channelId = channelId;
  215. this.deviceId = deviceId;
  216. this.streamId = "";
  217. this.app = "";
  218. this.videoUrl = ""
  219. if (!!this.$refs.videoPlayer) {
  220. this.$refs.videoPlayer.pause();
  221. }
  222. switch (tab) {
  223. case "media":
  224. this.play(param.streamInfo, param.hasAudio)
  225. break;
  226. case "record":
  227. this.showVideoDialog = true;
  228. this.videoHistory.date = param.date;
  229. this.queryRecords()
  230. break;
  231. case "streamPlay":
  232. this.tabActiveName = "media";
  233. this.showRrecord = false,
  234. this.showPtz = false,
  235. this.play(param.streamInfo, param.hasAudio)
  236. break;
  237. case "control":
  238. break;
  239. }
  240. },
  241. timeAxisSelTime: function (val) {
  242. console.log(val)
  243. },
  244. play: function (streamInfo, hasAudio) {
  245. this.hasaudio = hasAudio;
  246. this.isLoging = false;
  247. // this.videoUrl = streamInfo.rtc;
  248. this.videoUrl = streamInfo.ws_flv;
  249. this.streamId = streamInfo.streamId;
  250. this.app = streamInfo.app;
  251. this.playFromStreamInfo(false, streamInfo)
  252. },
  253. coverPlay: function () {
  254. var that = this;
  255. this.coverPlaying = true;
  256. this.$refs.videoPlayer.pause()
  257. that.$axios({
  258. method: 'post',
  259. url: '/api/play/convert/' + that.streamId
  260. }).then(function (res) {
  261. if (res.data.code == 0) {
  262. that.convertKey = res.data.key;
  263. setTimeout(()=>{
  264. that.isLoging = false;
  265. that.playFromStreamInfo(false, res.data.data);
  266. }, 2000)
  267. } else {
  268. that.isLoging = false;
  269. that.coverPlaying = false;
  270. that.$message({
  271. showClose: true,
  272. message: '转码失败',
  273. type: 'error'
  274. });
  275. }
  276. }).catch(function (e) {
  277. console.log(e)
  278. that.coverPlaying = false;
  279. that.$message({
  280. showClose: true,
  281. message: '播放错误',
  282. type: 'error'
  283. });
  284. });
  285. },
  286. convertStopClick: function() {
  287. this.convertStop(()=>{
  288. this.$refs.videoPlayer.play(this.videoUrl)
  289. });
  290. },
  291. convertStop: function(callback) {
  292. var that = this;
  293. that.$refs.videoPlayer.pause()
  294. this.$axios({
  295. method: 'post',
  296. url: '/api/play/convertStop/' + this.convertKey
  297. }).then(function (res) {
  298. if (res.data.code == 0) {
  299. console.log(res.data.msg)
  300. }else {
  301. console.error(res.data.msg)
  302. }
  303. if (callback )callback();
  304. }).catch(function (e) {});
  305. that.coverPlaying = false;
  306. that.convertKey = "";
  307. // if (callback )callback();
  308. },
  309. playFromStreamInfo: function (realHasAudio, streamInfo) {
  310. this.showVideoDialog = true;
  311. this.hasaudio = realHasAudio && this.hasaudio;
  312. this.$refs.videoPlayer.play(streamInfo.ws_flv)
  313. },
  314. close: function () {
  315. console.log('关闭视频');
  316. if (!!this.$refs.videoPlayer){
  317. this.$refs.videoPlayer.pause();
  318. }
  319. this.videoUrl = '';
  320. this.coverPlaying = false;
  321. this.showVideoDialog = false;
  322. if (this.convertKey != '') {
  323. this.convertStop();
  324. }
  325. this.convertKey = ''
  326. if (this.recordPlay != '') {
  327. this.stopPlayRecord();
  328. }
  329. this.recordPlay = ''
  330. },
  331. copySharedInfo: function (data) {
  332. console.log('复制内容:' + data);
  333. this.coverPlaying = false;
  334. this.tracks = []
  335. let _this = this;
  336. this.$copyText(data).then(
  337. function (e) {
  338. _this.$message({
  339. showClose: true,
  340. message: '复制成功',
  341. type: 'success'
  342. });
  343. },
  344. function (e) {
  345. _this.$message({
  346. showClose: true,
  347. message: '复制失败,请手动复制',
  348. type: 'error'
  349. });
  350. }
  351. );
  352. },
  353. queryRecords: function () {
  354. if (!this.videoHistory.date) {
  355. return;
  356. }
  357. this.recordsLoading = true;
  358. this.videoHistory.searchHistoryResult = [];
  359. let that = this;
  360. var startTime = this.videoHistory.date + " 00:00:00";
  361. var endTime = this.videoHistory.date + " 23:59:59";
  362. this.$axios({
  363. method: 'get',
  364. url: '/api/gb_record/query/' + this.deviceId + '/' + this.channelId + '?startTime=' + startTime + '&endTime=' + endTime
  365. }).then(function (res) {
  366. // 处理时间信息
  367. that.videoHistory.searchHistoryResult = res.data.recordList;
  368. that.recordsLoading = false;
  369. }).catch(function (e) {
  370. console.log(e.message);
  371. // that.videoHistory.searchHistoryResult = falsificationData.recordData;
  372. });
  373. },
  374. onTimeChange: function (video) {
  375. // this.queryRecords()
  376. },
  377. playRecord: function (row) {
  378. let that = this;
  379. if (that.streamId != "") {
  380. that.stopPlayRecord(function () {
  381. that.streamId = "",
  382. that.playRecord(row);
  383. })
  384. } else {
  385. this.$axios({
  386. method: 'get',
  387. url: '/api/playback/start/' + this.deviceId + '/' + this.channelId + '?startTime=' + row.startTime + '&endTime=' +
  388. row.endTime
  389. }).then(function (res) {
  390. var streamInfo = res.data;
  391. that.streamId = streamInfo.streamId;
  392. that.videoUrl = streamInfo.ws_flv;
  393. that.recordPlay = true;
  394. });
  395. }
  396. },
  397. stopPlayRecord: function (callback) {
  398. this.$refs.videoPlayer.pause();
  399. this.videoUrl = '';
  400. this.$axios({
  401. method: 'get',
  402. url: '/api/playback/stop/' + this.streamId
  403. }).then(function (res) {
  404. if (callback) callback()
  405. });
  406. },
  407. ptzCamera: function (leftRight, upDown, zoom) {
  408. console.log('云台控制:' + leftRight + ' : ' + upDown + " : " + zoom);
  409. let that = this;
  410. this.$axios({
  411. method: 'post',
  412. // url: '/api/ptz/' + this.deviceId + '/' + this.channelId + '?leftRight=' + leftRight + '&upDown=' + upDown +
  413. // '&inOut=' + zoom + '&moveSpeed=50&zoomSpeed=50'
  414. url: '/api/ptz/control/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + (zoom * 16 + upDown * 4 + leftRight) + '&horizonSpeed=' + this.controSpeed + '&verticalSpeed=' + this.controSpeed + '&zoomSpeed=' + this.controSpeed
  415. }).then(function (res) {});
  416. },
  417. //////////////////////播放器事件处理//////////////////////////
  418. videoError: function (e) {
  419. console.log("播放器错误:" + JSON.stringify(e));
  420. },
  421. presetPosition: function (cmdCode, presetPos) {
  422. console.log('预置位控制:' + this.presetPos + ' : 0x' + cmdCode.toString(16));
  423. let that = this;
  424. this.$axios({
  425. method: 'post',
  426. url: '/api/ptz/front_end_command/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + cmdCode + '&parameter1=0&parameter2=' + presetPos + '&combindCode2=0'
  427. }).then(function (res) {});
  428. },
  429. setSpeedOrTime: function (cmdCode, groupNum, parameter) {
  430. let that = this;
  431. let parameter2 = parameter % 256;
  432. let combindCode2 = Math.floor(parameter / 256) * 16;
  433. console.log('前端控制:0x' + cmdCode.toString(16) + ' 0x' + groupNum.toString(16) + ' 0x' + parameter2.toString(16) + ' 0x' + combindCode2.toString(16));
  434. this.$axios({
  435. method: 'post',
  436. url: '/api/ptz/front_end_command/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + cmdCode + '&parameter1=' + groupNum + '&parameter2=' + parameter2 + '&combindCode2=' + combindCode2
  437. }).then(function (res) {});
  438. },
  439. setCommand: function (cmdCode, groupNum, parameter) {
  440. let that = this;
  441. console.log('前端控制:0x' + cmdCode.toString(16) + ' 0x' + groupNum.toString(16) + ' 0x' + parameter.toString(16) + ' 0x0');
  442. this.$axios({
  443. method: 'post',
  444. url: '/api/ptz/front_end_command/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + cmdCode + '&parameter1=' + groupNum + '&parameter2=' + parameter + '&combindCode2=0'
  445. }).then(function (res) {});
  446. },
  447. formatTooltip: function (val) {
  448. var h = parseInt(val / 60);
  449. var hStr = h < 10 ? ("0" + h) : h;
  450. var s = val % 60;
  451. var sStr = s < 10 ? ("0" + s) : s;
  452. return h + ":" + sStr;
  453. },
  454. timeFormatter: function (row, column, cellValue, index) {
  455. return cellValue.split(" ")[1];
  456. },
  457. mergeTime: function (timeArray) {
  458. var resultArray = [];
  459. for (let i = 0; i < timeArray.length; i++) {
  460. var startTime = new Date(timeArray[i].startTime);
  461. var endTime = new Date(timeArray[i].endTime);
  462. if (i == 0) {
  463. resultArray[0] = {
  464. startTime: startTime,
  465. endTime: endTime
  466. }
  467. }
  468. for (let j = 0; j < resultArray.length; j++) {
  469. if (startTime > resultArray[j].endTime) { // 合并
  470. if (startTime - resultArray[j].endTime <= 1000) {
  471. resultArray[j].endTime = endTime;
  472. } else {
  473. resultArray[resultArray.length] = {
  474. startTime: startTime,
  475. endTime: endTime
  476. }
  477. }
  478. } else if (resultArray[j].startTime > endTime) { // 合并
  479. if (resultArray[j].startTime - endTime <= 1000) {
  480. resultArray[j].startTime = startTime;
  481. } else {
  482. resultArray[resultArray.length] = {
  483. startTime: startTime,
  484. endTime: endTime
  485. }
  486. }
  487. }
  488. }
  489. }
  490. console.log(resultArray)
  491. return resultArray;
  492. }
  493. }
  494. };
  495. </script>
  496. <style>
  497. .control-wrapper {
  498. position: relative;
  499. width: 6.25rem;
  500. height: 6.25rem;
  501. max-width: 6.25rem;
  502. max-height: 6.25rem;
  503. border-radius: 100%;
  504. margin-top: 1.5rem;
  505. margin-left: 0.5rem;
  506. float: left;
  507. }
  508. .control-panel {
  509. position: relative;
  510. top: 0;
  511. left: 5rem;
  512. height: 11rem;
  513. max-height: 11rem;
  514. }
  515. .control-btn {
  516. display: flex;
  517. justify-content: center;
  518. position: absolute;
  519. width: 44%;
  520. height: 44%;
  521. border-radius: 5px;
  522. border: 1px solid #78aee4;
  523. box-sizing: border-box;
  524. transition: all 0.3s linear;
  525. }
  526. .control-btn:hover {
  527. cursor:pointer
  528. }
  529. .control-btn i {
  530. font-size: 20px;
  531. color: #78aee4;
  532. display: flex;
  533. justify-content: center;
  534. align-items: center;
  535. }
  536. .control-btn i:hover {
  537. cursor:pointer
  538. }
  539. .control-zoom-btn:hover {
  540. cursor:pointer
  541. }
  542. .control-round {
  543. position: absolute;
  544. top: 21%;
  545. left: 21%;
  546. width: 58%;
  547. height: 58%;
  548. background: #fff;
  549. border-radius: 100%;
  550. }
  551. .control-round-inner {
  552. position: absolute;
  553. left: 13%;
  554. top: 13%;
  555. display: flex;
  556. justify-content: center;
  557. align-items: center;
  558. width: 70%;
  559. height: 70%;
  560. font-size: 40px;
  561. color: #78aee4;
  562. border: 1px solid #78aee4;
  563. border-radius: 100%;
  564. transition: all 0.3s linear;
  565. }
  566. .control-inner-btn {
  567. position: absolute;
  568. width: 60%;
  569. height: 60%;
  570. background: #fafafa;
  571. }
  572. .control-top {
  573. top: -8%;
  574. left: 27%;
  575. transform: rotate(-45deg);
  576. border-radius: 5px 100% 5px 0;
  577. }
  578. .control-top i {
  579. transform: rotate(45deg);
  580. border-radius: 5px 100% 5px 0;
  581. }
  582. .control-top .control-inner {
  583. left: -1px;
  584. bottom: 0;
  585. border-top: 1px solid #78aee4;
  586. border-right: 1px solid #78aee4;
  587. border-radius: 0 100% 0 0;
  588. }
  589. .control-top .fa {
  590. transform: rotate(45deg) translateY(-7px);
  591. }
  592. .control-left {
  593. top: 27%;
  594. left: -8%;
  595. transform: rotate(45deg);
  596. border-radius: 5px 0 5px 100%;
  597. }
  598. .control-left i {
  599. transform: rotate(-45deg);
  600. }
  601. .control-left .control-inner {
  602. right: -1px;
  603. top: -1px;
  604. border-bottom: 1px solid #78aee4;
  605. border-left: 1px solid #78aee4;
  606. border-radius: 0 0 0 100%;
  607. }
  608. .control-left .fa {
  609. transform: rotate(-45deg) translateX(-7px);
  610. }
  611. .control-right {
  612. top: 27%;
  613. right: -8%;
  614. transform: rotate(45deg);
  615. border-radius: 5px 100% 5px 0;
  616. }
  617. .control-right i {
  618. transform: rotate(-45deg);
  619. }
  620. .control-right .control-inner {
  621. left: -1px;
  622. bottom: -1px;
  623. border-top: 1px solid #78aee4;
  624. border-right: 1px solid #78aee4;
  625. border-radius: 0 100% 0 0;
  626. }
  627. .control-right .fa {
  628. transform: rotate(-45deg) translateX(7px);
  629. }
  630. .control-bottom {
  631. left: 27%;
  632. bottom: -8%;
  633. transform: rotate(45deg);
  634. border-radius: 0 5px 100% 5px;
  635. }
  636. .control-bottom i {
  637. transform: rotate(-45deg);
  638. }
  639. .control-bottom .control-inner {
  640. top: -1px;
  641. left: -1px;
  642. border-bottom: 1px solid #78aee4;
  643. border-right: 1px solid #78aee4;
  644. border-radius: 0 0 100% 0;
  645. }
  646. .control-bottom .fa {
  647. transform: rotate(-45deg) translateY(7px);
  648. }
  649. .trank {
  650. width: 80%;
  651. height: 180px;
  652. text-align: left;
  653. padding: 0 10%;
  654. overflow: auto;
  655. }
  656. .trankInfo {
  657. width: 80%;
  658. padding: 0 10%;
  659. }
  660. </style>