hnVideoLive.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. var _this, dataObj = [],
  2. nowYsy = null;
  3. var _Player = {
  4. one: null
  5. };
  6. var loading = null;
  7. new Vue({
  8. el: '#app',
  9. data: function() {
  10. return {
  11. dataLi: [],
  12. nowTab: {},
  13. tabArr: {},
  14. playSucc: {
  15. one: false,
  16. two: false,
  17. thr: false,
  18. fou: false
  19. },
  20. videoNum: 1
  21. }
  22. },
  23. created() {
  24. _this = this;
  25. nowYsy = JSON.parse(localStorage.getItem("nowShip"));
  26. _this.initAjax();
  27. },
  28. mounted() {
  29. window.addEventListener('message', (data) => {
  30. nowYsy = JSON.parse(localStorage.getItem("nowShip"));
  31. _this.initAjax();
  32. })
  33. },
  34. methods: {
  35. initAjax() {
  36. if (nowYsy != null && nowYsy != "null") {
  37. loading = this.$loading({
  38. background: 'rgba(0, 0, 0, 0.4)'
  39. })
  40. }
  41. dataObj = [];
  42. _this.getList();
  43. },
  44. getList() {
  45. if (nowYsy != null && nowYsy != "null") {
  46. getOneYsy(nowYsy.sn,function(sfg){
  47. let _opts = {
  48. url: ys7Url + "/api/lapp/device/camera/list",
  49. type:"POST"
  50. };
  51. let _data = {
  52. "deviceSerial": nowYsy.sn,
  53. "accessToken": getCookie("ylToken")
  54. };
  55. let _hea = {
  56. "Content-Type": "application/x-www-form-urlencoded"
  57. };
  58. postAxios(_opts, _data, _hea).then((res) => {
  59. if (res.code == 200) {
  60. dataObj = res.data;
  61. } else {
  62. dataObj = [];
  63. }
  64. _this.checkList(sfg.status);
  65. loading.close();
  66. })
  67. },true);
  68. }
  69. },
  70. checkList(_sta) {
  71. let _arr = [];
  72. if (nowYsy.sn != "" && dataObj.length) {
  73. dataObj.forEach((it, ind) => {
  74. if (it.channelName.indexOf("@") == -1 && nowYsy.sn.indexOf(it.deviceSerial) != -1) {
  75. it.name = it.channelName.split("PTZ")[0].split("_")[0];
  76. it.fatSat = _sta;
  77. _arr.push(it);
  78. }
  79. })
  80. }
  81. _this.closeVid();
  82. _this.dataLi = _arr;
  83. },
  84. changTab(key) {
  85. let _flag = true;
  86. if (_this.tabArr[key.deviceSerial + "_" + key.channelNo] != undefined) {
  87. _this.$message({
  88. showClose: true,
  89. message: '设备已经在播放!!!',
  90. type: 'warning'
  91. });
  92. return;
  93. }
  94. for (let val in _Player) {
  95. if (_Player[val] == null) {
  96. _this.dataLi.forEach(item => {
  97. if ((item.deviceSerial == key.deviceSerial) && (key.channelNo == item
  98. .channelNo)) {
  99. if (item.status == 1 && item.fatSat == 1) {
  100. _this.nowTab[val] = item;
  101. _this.tabArr[item.deviceSerial + "_" + item.channelNo] = item;
  102. _this.playEzopen(val);
  103. } else {
  104. _this.$message({
  105. showClose: true,
  106. message: '设备离线中!!!',
  107. type: 'warning'
  108. });
  109. }
  110. }
  111. })
  112. _flag = false;
  113. break;
  114. }
  115. }
  116. if (_flag) {
  117. _this.$message({
  118. showClose: true,
  119. message: '暂无可用通道!!!',
  120. type: 'warning'
  121. });
  122. }
  123. },
  124. playEzopen(key) {
  125. let _wid = $("#videoWeiHie").width();
  126. let _hie = $("#videoWeiHie").height();
  127. let _src = "ezopen://open.ys7.com/" + (_this.nowTab[key].deviceSerial) + "/" + (_this.nowTab[key].channelNo) + ".live";
  128. _Player[key] = new EZUIKit.EZUIKitPlayer({
  129. id: "playWind_" + key,
  130. autoplay: true,
  131. url: _src,
  132. accessToken: getCookie("ylToken"),
  133. width: (parseFloat(_wid) - 2)/(_this.videoNum>1?2:1),
  134. height: (parseFloat(_hie) - 2)/(_this.videoNum>1?2:1),
  135. audio: false,
  136. plugin: ['talk'],
  137. themeData: {
  138. "header": {
  139. "color": "#1890ff",
  140. "activeColor": "#FFFFFF",
  141. "backgroundColor": "#000000",
  142. "btnList": [
  143. {
  144. "iconId": "deviceName",
  145. "part": "left",
  146. "defaultActive": 0,
  147. "memo": "顶部设备名称",
  148. "isrender": 1
  149. }]
  150. },
  151. "footer": {
  152. "color": "#FFFFFF",
  153. "activeColor": "#1890FF",
  154. "backgroundColor": "#00000021",
  155. "btnList": [{
  156. "iconId": "play",
  157. "part": "left",
  158. "defaultActive": 1,
  159. "memo": "播放",
  160. "isrender": 1
  161. },
  162. {
  163. "iconId": "capturePicture",
  164. "part": "left",
  165. "defaultActive": 0,
  166. "memo": "截屏按钮",
  167. "isrender": 1
  168. },
  169. {
  170. "iconId": "sound",
  171. "part": "left",
  172. "defaultActive": 0,
  173. "memo": "声音按钮",
  174. "isrender": 1
  175. },
  176. {
  177. "iconId": "recordvideo",
  178. "part": "left",
  179. "defaultActive": 0,
  180. "memo": "录制按钮",
  181. "isrender": 1
  182. },
  183. {
  184. "iconId": "hd",
  185. "part": "right",
  186. "defaultActive": 0,
  187. "memo": "清晰度切换按钮",
  188. "isrender": 1
  189. },
  190. {
  191. "iconId": "webExpend",
  192. "part": "right",
  193. "defaultActive": 0,
  194. "memo": "网页全屏按钮",
  195. "isrender": 1
  196. },
  197. {
  198. "iconId": "expend",
  199. "part": "right",
  200. "defaultActive": 0,
  201. "memo": "全局全屏按钮",
  202. "isrender": 1
  203. }
  204. ]
  205. }
  206. },
  207. decoderPath: staticUrl,
  208. handleError: _this.handleError(key),
  209. handleSuccess: _this.handleSuccess(key),
  210. });
  211. },
  212. handleError(key) {
  213. if (_Player[key] != null) {
  214. _this.closeVid(key)
  215. _this.$message({
  216. showClose: true,
  217. message: '视频播放失败!!!',
  218. type: 'error'
  219. });
  220. }
  221. },
  222. closeVid(key) {
  223. if (_Player[key] != null) {
  224. _Player[key].stop();
  225. _Player[key].destroy();
  226. _this.playSucc[key] = false;
  227. _Player[key] = null;
  228. delete _this.tabArr[_this.nowTab[key].deviceSerial + "_" + _this.nowTab[key].channelNo];
  229. delete _this.nowTab[key];
  230. }
  231. },
  232. handleSuccess(key) {
  233. _this.playSucc[key] = true;
  234. },
  235. closePla(key){
  236. _this.closeVid(key);
  237. },
  238. changeVidNum(key) {
  239. if (_this.videoNum == 4 && key == 1) {
  240. for (let val in _Player) {
  241. if (val != "one") {
  242. _this.closeVid(val);
  243. }
  244. }
  245. _Player = {
  246. one: _Player["one"]
  247. };
  248. }
  249. if (_this.videoNum == 1 && key == 4) {
  250. _Player = {
  251. one: _Player["one"],
  252. two: null,
  253. thr: null,
  254. fou: null
  255. };
  256. }
  257. _this.videoNum = key;
  258. if (_Player["one"] != null) {
  259. _Player["one"].stop();
  260. _Player["one"].destroy();
  261. _Player["one"] = null;
  262. _this.playEzopen("one");
  263. }
  264. }
  265. }
  266. })