devicePlayer.vue 34 KB

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