videoLive.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. var _this, dataObj = [],nowYsy = null;
  2. var _Player = null,loading = null;
  3. new Vue({
  4. el: '#app',
  5. data: function() {
  6. return {
  7. dataLi: [],
  8. nowTab: {},
  9. playSucc: false,
  10. pauseSucc: true,
  11. videoTape: false,
  12. audioSucc: false,
  13. talkSucc: false,
  14. cotrSucc: false,
  15. textContent: "",
  16. dialogVisible: false
  17. }
  18. },
  19. created() {
  20. _this = this;
  21. nowYsy = JSON.parse(localStorage.getItem("nowShip"));
  22. _this.initAjax();
  23. },
  24. mounted(){
  25. window.addEventListener('message',(data)=>{
  26. nowYsy = JSON.parse(localStorage.getItem("nowShip"));
  27. _this.initAjax();
  28. })
  29. },
  30. methods: {
  31. initAjax(){
  32. // checkNuuid();
  33. loading = this.$loading({
  34. background: 'rgba(0, 0, 0, 0.4)'
  35. })
  36. dataObj = [];
  37. _this.getList();
  38. },
  39. getList(){
  40. if(nowYsy !=null && nowYsy != "null"){
  41. // getOneYsy(nowYsy.sn,function(sfg){
  42. // let _opts = {
  43. // url: ys7Url + "/api/lapp/device/camera/list",
  44. // type:"POST"
  45. // };
  46. // let _data = {
  47. // "deviceSerial": nowYsy.sn,
  48. // "accessToken": getCookie("ylToken")
  49. // };
  50. // let _hea = {
  51. // "Content-Type": "application/x-www-form-urlencoded"
  52. // };
  53. // postAxios(_opts, _data, _hea).then((res) => {
  54. let res = {
  55. data: [{
  56. "deviceSerial": "K61426288",
  57. "ipcSerial": "7L04B43PAG4A724",
  58. "channelNo": 1,
  59. "deviceName": "振浮6 DS-7916N-R4(K61426288)",
  60. "localName": "振浮6 DS-7916N-R4(K61426288)",
  61. "channelName": "驾驶室",
  62. "status": 1,
  63. "isShared": "0",
  64. "picUrl": "https://statics.ys7.com/device/assets/imgs/public/homeDevice.jpeg",
  65. "isEncrypt": 0,
  66. "videoLevel": 0,
  67. "relatedIpc": true,
  68. "isAdd": 1,
  69. "devType": "DH-IPC-HDW2433T-A-V4"
  70. },
  71. {
  72. "deviceSerial": "K61426288",
  73. "ipcSerial": "8H0970BPHAE80BC",
  74. "channelNo": 10,
  75. "deviceName": "振浮6 DS-7916N-R4(K61426288)",
  76. "localName": "振浮6 DS-7916N-R4(K61426288)",
  77. "channelName": "船尾右舷向前",
  78. "status": 1,
  79. "isShared": "0",
  80. "picUrl": "https://statics.ys7.com/device/assets/imgs/public/homeDevice.jpeg",
  81. "isEncrypt": 0,
  82. "videoLevel": 0,
  83. "relatedIpc": true,
  84. "isAdd": 1,
  85. "devType": "IPC-HFW2433F-ZSA"
  86. },
  87. {
  88. "deviceSerial": "K61426288",
  89. "ipcSerial": "8H0970BPHAE0950",
  90. "channelNo": 11,
  91. "deviceName": "振浮6 DS-7916N-R4(K61426288)",
  92. "localName": "振浮6 DS-7916N-R4(K61426288)",
  93. "channelName": "船尾左向后",
  94. "status": 1,
  95. "isShared": "0",
  96. "picUrl": "https://statics.ys7.com/device/assets/imgs/public/homeDevice.jpeg",
  97. "isEncrypt": 0,
  98. "videoLevel": 0,
  99. "relatedIpc": true,
  100. "isAdd": 1,
  101. "devType": "IPC-HFW2433F-ZSA"
  102. },
  103. {
  104. "deviceSerial": "K61426288",
  105. "ipcSerial": "7M027F6PAG30481",
  106. "channelNo": 12,
  107. "deviceName": "振浮6 DS-7916N-R4(K61426288)",
  108. "localName": "振浮6 DS-7916N-R4(K61426288)",
  109. "channelName": "船尾右向后",
  110. "status": 1,
  111. "isShared": "0",
  112. "picUrl": "https://statics.ys7.com/device/assets/imgs/public/homeDevice.jpeg",
  113. "isEncrypt": 0,
  114. "videoLevel": 0,
  115. "relatedIpc": true,
  116. "isAdd": 1,
  117. "devType": "IPC-HFW2433F-ZSA"
  118. },
  119. {
  120. "deviceSerial": "K61426288",
  121. "ipcSerial": "8H0D67FPAG4C400",
  122. "channelNo": 13,
  123. "deviceName": "振浮6 DS-7916N-R4(K61426288)",
  124. "localName": "振浮6 DS-7916N-R4(K61426288)",
  125. "channelName": "前大桅向后",
  126. "status": 1,
  127. "isShared": "0",
  128. "picUrl": "https://statics.ys7.com/device/assets/imgs/public/homeDevice.jpeg",
  129. "isEncrypt": 0,
  130. "videoLevel": 0,
  131. "relatedIpc": true,
  132. "isAdd": 1,
  133. "devType": "DH-IPC-HFW1430M-A-I1"
  134. }],
  135. code: 200
  136. };
  137. let sfg = { status: 1 };
  138. if(res.code == 200){
  139. dataObj = res.data;
  140. }else{
  141. dataObj = [];
  142. }
  143. _this.checkList(sfg.status);
  144. loading.close();
  145. // })
  146. // },true);
  147. }
  148. },
  149. checkList(_sta){
  150. let _arr = [];
  151. if(nowYsy.sn != ""&&dataObj.length){
  152. dataObj.forEach((it,ind) => {
  153. if(it.channelName.indexOf("@") == -1&&nowYsy.sn.indexOf(it.deviceSerial) != -1){
  154. it.name = it.channelName.split("PTZ")[0].split("_")[0];
  155. it.fatSat = _sta;
  156. _arr.push(it);
  157. }
  158. })
  159. }
  160. _this.closeVid();
  161. _this.dataLi = _arr;
  162. },
  163. changTab(key){
  164. _this.dataLi.forEach(item=>{
  165. if((item.deviceSerial+''+item.channelNo) == key){
  166. if(item.status == 1&&item.fatSat == 1){
  167. _this.nowTab = item;
  168. _this.playEzopen();
  169. }else{
  170. _this.$message({
  171. showClose: true,
  172. message: '设备离线中!!!',
  173. type: 'warning'
  174. });
  175. }
  176. }
  177. })
  178. // let ind = _this.dataLi.findIndex((it,ind) => {return it.deviceSerial+''+it.channelNo == id});
  179. // console.log(ind)
  180. // if(ind != -1){
  181. // _this.closeVid();
  182. // if(_this.dataLi[ind].channelNo != _this.nowTab.channelNo){
  183. // _this.nowTab = _this.dataLi[ind];
  184. // if(_this.nowTab.status == 0){
  185. // _this.$message({
  186. // showClose: true,
  187. // message: '设备离线中!!!',
  188. // type: 'warning'
  189. // });
  190. // }else{
  191. // _this.playEzopen();
  192. // }
  193. // }
  194. // }
  195. },
  196. playEzopen(){
  197. if(_Player != null){
  198. _Player.stop();
  199. }
  200. let _wid = $(".videobox").width();
  201. let _hie = $(".videobox").height();
  202. let _src = "ezopen://open.ys7.com/"+(_this.nowTab.deviceSerial)+"/"+(_this.nowTab.channelNo)+".live";
  203. _Player = new EZUIKit.EZUIKitPlayer({
  204. id: 'playWind',
  205. autoplay: true,
  206. url: _src,
  207. accessToken: getCookie("ylToken"),
  208. width:_wid,
  209. height:_hie,
  210. audio:false,
  211. plugin: ['talk'],
  212. decoderPath: staticUrl,
  213. handleError: _this.handleError,
  214. handleSuccess: _this.handleSuccess,
  215. });
  216. },
  217. handleError(){
  218. _this.closeVid()
  219. _this.$message({
  220. showClose: true,
  221. message: '视频播放失败!!!',
  222. type: 'error'
  223. });
  224. },
  225. closeVid(){
  226. if(_Player != null){
  227. _Player.stop();
  228. }
  229. _this.playSucc = false;
  230. _Player = null;
  231. _this.nowTab = {};
  232. _this.pauseSucc = true;
  233. _this.videoTape = false;
  234. _this.audioSucc = false;
  235. _this.talkSucc = false;
  236. _this.cotrSucc = false;
  237. },
  238. handleSuccess(){
  239. _this.playSucc = true;
  240. },
  241. // 截图
  242. capPic() {
  243. if(_Player != null){
  244. var capPictProm = _Player.capturePicture();
  245. capPictProm.then((data) => {
  246. // console.log("promise 获取 数据", data)
  247. })
  248. }
  249. },
  250. // 关闭
  251. closePla(){
  252. _this.closeVid();
  253. },
  254. // 暂停、播放
  255. changPause(){
  256. if(_Player != null){
  257. if(_this.pauseSucc){
  258. _Player.stop();
  259. _this.pauseSucc = false;
  260. }else{
  261. _Player.play();
  262. _this.pauseSucc = true;
  263. }
  264. }
  265. },
  266. // 录像
  267. changTape(){
  268. if(_Player != null){
  269. if(_this.videoTape){
  270. let tapeProm = _Player.stopSave();
  271. tapeProm.then((data) => {
  272. _this.$message({
  273. showClose: true,
  274. message: '录制结束!!!',
  275. type: 'success'
  276. });
  277. _this.videoTape = false;
  278. })
  279. }else{
  280. let tapeProm = _Player.startSave();
  281. tapeProm.then((data) => {
  282. _this.$message({
  283. showClose: true,
  284. message: '开始录制!!!',
  285. type: 'success'
  286. });
  287. _this.videoTape = true;
  288. })
  289. }
  290. }
  291. },
  292. // 全屏
  293. fullScreen() {
  294. if(_Player != null){
  295. // var fullProm = playr.fullScreen();
  296. let ele = document.getElementById("playWind");
  297. if (ele.requestFullscreen) {
  298. ele.requestFullscreen();
  299. } else if (ele.mozRequestFullScreen) {
  300. ele.mozRequestFullScreen();
  301. } else if (ele.webkitRequestFullscreen) {
  302. ele.webkitRequestFullscreen();
  303. } else if (ele.msRequestFullscreen) {
  304. ele.msRequestFullscreen();
  305. }
  306. // fullProm.then((data) => {
  307. // // console.log("promise 获取 数据", data)
  308. // })
  309. }
  310. },
  311. // 关开声音
  312. changAudio(){
  313. if(_Player != null){
  314. if(_this.audioSucc){
  315. _Player.closeSound();
  316. _this.audioSucc = false;
  317. }else{
  318. _Player.openSound();
  319. _this.audioSucc = true;
  320. }
  321. }
  322. },
  323. // 打开对讲
  324. openTalk(){
  325. if(_Player != null){
  326. if(_this.nowTab.channelNo == 4&&_this.nowTab.deviceSerial == "J93363609"){
  327. if(_this.talkSucc){
  328. _Player.stopTalk();
  329. _this.$message({
  330. showClose: true,
  331. message: '对讲关闭!!!',
  332. type: 'success'
  333. });
  334. _this.talkSucc = false;
  335. }else{
  336. _Player.startTalk();
  337. _this.$message({
  338. showClose: true,
  339. message: '对讲开始!!!',
  340. type: 'success'
  341. });
  342. _this.talkSucc = true;
  343. }
  344. }else{
  345. _this.$message({
  346. showClose: true,
  347. message: "该摄像头不支持语音对讲功能!",
  348. type: 'error'
  349. });
  350. }
  351. }
  352. },
  353. showCotr(){
  354. if(_Player != null){
  355. if(!_this.cotrSucc){
  356. if(_this.nowTab.channelName.indexOf("PTZ") != -1){
  357. _this.cotrSucc = true;
  358. }else{
  359. _this.$message({
  360. showClose: true,
  361. message: "该摄像头不支持云台控制功能!",
  362. type: 'error'
  363. });
  364. }
  365. }else{
  366. _this.cotrSucc = false;
  367. }
  368. }
  369. },
  370. // 云台控制
  371. setCotr(_dire){
  372. let _opts = {
  373. url: ys7Url + "/api/lapp/device/ptz/start",
  374. type:"POST"
  375. };
  376. let _data = {
  377. "accessToken": getCookie("ylToken"),
  378. "deviceSerial": _this.nowTab.deviceSerial,
  379. "channelNo": _this.nowTab.channelNo,
  380. "direction": _dire,
  381. "speed": 1
  382. };
  383. let _hea = {
  384. "Content-Type": "application/x-www-form-urlencoded"
  385. };
  386. postAxios(_opts, _data, _hea).then((res) => {
  387. if(res.code != 200){
  388. _this.$message({
  389. showClose: true,
  390. message: res.msg,
  391. type: 'error'
  392. });
  393. }
  394. })
  395. },
  396. stopCotr(_dire){
  397. let _opts = {
  398. url: ys7Url + "/api/lapp/device/ptz/stop",
  399. type:"POST"
  400. };
  401. let _data = {
  402. "accessToken": getCookie("ylToken"),
  403. "deviceSerial": _this.nowTab.deviceSerial,
  404. "channelNo": _this.nowTab.channelNo,
  405. "direction": _dire,
  406. "speed": 1
  407. };
  408. let _hea = {
  409. "Content-Type": "application/x-www-form-urlencoded"
  410. };
  411. postAxios(_opts, _data, _hea).then((res) => {
  412. if(res.code != 200){
  413. _this.$message({
  414. showClose: true,
  415. message: res.msg,
  416. type: 'error'
  417. });
  418. }
  419. })
  420. },
  421. setFirst(){
  422. let _opts = {
  423. url: ys7Url + "/api/lapp/device/preset/move",
  424. type:"POST"
  425. };
  426. let _data = {
  427. "accessToken": getCookie("ylToken"),
  428. "deviceSerial": _this.nowTab.deviceSerial,
  429. "channelNo": _this.nowTab.channelNo,
  430. "index": it.channelName.split("PTZ")[1]
  431. };
  432. let _hea = {
  433. "Content-Type": "application/x-www-form-urlencoded"
  434. };
  435. postAxios(_opts, _data, _hea).then((res) => {
  436. if(res.code != 200){
  437. _this.$message({
  438. showClose: true,
  439. message: res.msg,
  440. type: 'error'
  441. });
  442. }
  443. })
  444. },
  445. //
  446. showSend(){
  447. _this.textContent = "";
  448. _this.dialogVisible = true;
  449. },
  450. // 文本语音下发
  451. confirmSend(){
  452. if(!_this.textContent.length){
  453. _this.$message({
  454. showClose: true,
  455. message: '请先填写需要下发的内容!!!',
  456. type: 'error'
  457. });
  458. return;
  459. }
  460. let _obj = {
  461. "cmd":{
  462. "id":"501",
  463. "cmd":"CmdSendText",
  464. "name":"文本信息下发",
  465. "pid":"50",
  466. "seq":501,
  467. "support":",HS_1,BB_1,",
  468. "exclude":"",
  469. "timeOut":60,
  470. "offline":"0",
  471. "isShow":true,
  472. "pname":"信息指令",
  473. "module":"MsgText",
  474. },
  475. "cmd2":"CmdSendText",
  476. "carIds":["2166624"],
  477. "params":{
  478. "signBit":"00010000",
  479. "textMsg":"123",
  480. }
  481. };
  482. sendTxt(_obj).then(res => {
  483. console.log(res)
  484. })
  485. }
  486. }
  487. })