devicePlayer.vue 31 KB

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