devicePlayer.vue 38 KB

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