index.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>player</title>
  6. <script type="text/javascript" src="./src/SuperRender_20.js"></script>
  7. <style>
  8. .container {
  9. position: absolute;
  10. top: 0;
  11. left: 0;
  12. }
  13. #canvas {
  14. position: absolute;
  15. }
  16. .sk-chase {
  17. width: 40px;
  18. height: 40px;
  19. position: absolute;
  20. top: 50%;
  21. left: 50%;
  22. transform: translate(-50%, -50%);
  23. display: block;
  24. animation: sk-chase 2.5s infinite linear both;
  25. }
  26. .sk-chase-dot {
  27. width: 100%;
  28. height: 100%;
  29. position: absolute;
  30. left: 0;
  31. top: 0;
  32. animation: sk-chase-dot 2.0s infinite ease-in-out both;
  33. }
  34. .sk-chase-dot:before {
  35. content: '';
  36. display: block;
  37. width: 25%;
  38. height: 25%;
  39. background-color: #8cc5ff;
  40. border-radius: 100%;
  41. animation: sk-chase-dot-before 2.0s infinite ease-in-out both;
  42. }
  43. .sk-chase-dot:nth-child(1) { animation-delay: -1.1s; }
  44. .sk-chase-dot:nth-child(2) { animation-delay: -1.0s; }
  45. .sk-chase-dot:nth-child(3) { animation-delay: -0.9s; }
  46. .sk-chase-dot:nth-child(4) { animation-delay: -0.8s; }
  47. .sk-chase-dot:nth-child(5) { animation-delay: -0.7s; }
  48. .sk-chase-dot:nth-child(6) { animation-delay: -0.6s; }
  49. .sk-chase-dot:nth-child(1):before { animation-delay: -1.1s; }
  50. .sk-chase-dot:nth-child(2):before { animation-delay: -1.0s; }
  51. .sk-chase-dot:nth-child(3):before { animation-delay: -0.9s; }
  52. .sk-chase-dot:nth-child(4):before { animation-delay: -0.8s; }
  53. .sk-chase-dot:nth-child(5):before { animation-delay: -0.7s; }
  54. .sk-chase-dot:nth-child(6):before { animation-delay: -0.6s; }
  55. @keyframes sk-chase {
  56. 100% { transform: rotate(360deg); }
  57. }
  58. @keyframes sk-chase-dot {
  59. 80%, 100% { transform: rotate(360deg); }
  60. }
  61. @keyframes sk-chase-dot-before {
  62. 50% {
  63. transform: scale(0.4);
  64. } 100%, 0% {
  65. transform: scale(1.0);
  66. }
  67. }
  68. #error_text {
  69. width: 170px;
  70. height: 170px;
  71. background: url("./image/siagn.png") no-repeat;
  72. background-size: 100%;
  73. position: absolute;
  74. top: 50%;
  75. left: 50%;
  76. transform: translate(-50%, -50%);
  77. display: none;
  78. }
  79. body::-webkit-scrollbar {
  80. display: none;
  81. }
  82. </style>
  83. </head>
  84. <body style="margin: 0; padding: 0; width: 100%; height: 100%; z-index:999; background-color: transparent; overflow: hidden">
  85. <video id="video"></video>
  86. <div class="container">
  87. <canvas id="canvas"></canvas>
  88. <canvas id="videoCanvas"></canvas>
  89. </div>
  90. <canvas id="draw" ></canvas>
  91. <div class="sk-chase" id="sk-chase">
  92. <div class="sk-chase-dot"></div>
  93. <div class="sk-chase-dot"></div>
  94. <div class="sk-chase-dot"></div>
  95. <div class="sk-chase-dot"></div>
  96. <div class="sk-chase-dot"></div>
  97. <div class="sk-chase-dot"></div>
  98. </div>
  99. <div id="error_text"></div>
  100. </body>
  101. <!-- <script src="./node_modules/file-saver/FileSaver.js"/> -->
  102. <script src="./src/md5.js" type="text/javascript"></script>
  103. <script type="module">
  104. import Player from "./src/player.js";
  105. var clickTimeId;
  106. let str = location.href;
  107. let num = str.indexOf('?');
  108. str = str.substr(num+1);
  109. let data = str.split(',');
  110. console.log(data);
  111. // 下标0 wsUrl, 1 rtspUrl, 2 canvas 宽度, 3 canvas高度
  112. let video = document.getElementById('video');
  113. let height = video.clientHeight;
  114. video.dblclick = function () {
  115. };
  116. // function onDocumentClick(event) {
  117. // // 取消上次延时未执行的方法
  118. // clearTimeout(clickTimeId);
  119. // //执行延时
  120. // clickTimeId = setTimeout(function() {
  121. // //此处为单击事件要执行的代码
  122. // console.log("鼠标单击");
  123. // }, 250);
  124. // }
  125. // 设置高度宽度
  126. document.getElementById('canvas').width = data[2];
  127. document.getElementById('canvas').height = data[3];
  128. document.getElementById('videoCanvas').width = data[2];
  129. document.getElementById('videoCanvas').height = data[3];
  130. const options = {
  131. video: document.getElementById('video'),
  132. canvas: document.getElementById('canvas'),
  133. drawer: document.getElementById('draw'),
  134. wsUrl: '',
  135. rtspUrl: '',
  136. user: '',
  137. pwd: ''
  138. }
  139. options.wsUrl = data[0];
  140. options.rtspUrl = data[1];
  141. let player = new Player(options);
  142. player.init();
  143. player.on('error', function () {
  144. console.log('连接失败')
  145. let er = document.getElementById('error_text');
  146. er.style.display = 'block';
  147. let sk = document.getElementById('sk-chase');
  148. sk.style.display = 'none';
  149. });
  150. player.on('noStream', function () {
  151. console.log('noStream');
  152. player.close();
  153. player = null;
  154. player = new Player(options);
  155. player.init();
  156. player.connect();
  157. });
  158. player.on('canplay', function () {
  159. console.log('首次播放')
  160. //player.close();
  161. });
  162. player.on('initialCompleted', function () {
  163. let data = [[
  164. {x: 2861, y: 4395},
  165. {x: 6403, y: 4013},
  166. {x: 3260, y: 7986},
  167. {x: 640, y: 6252}
  168. ]];
  169. console.log('initialCompleted')
  170. player.setROI(data);
  171. });
  172. player.on('ROIFinished', function () {
  173. console.log('ROIFinished');
  174. });
  175. player.connect();
  176. let sk = document.getElementById('sk-chase');
  177. sk.style.display = 'none';
  178. // document.getElementById('close').onclick = ()=>{
  179. // player.close();
  180. // };
  181. // document.getElementById('ROIreset').onclick = () =>{
  182. // player.resetROI();
  183. // };
  184. //
  185. // document.getElementById('ROIset').onclick = () =>{
  186. // let data = [[
  187. // {x: 2861, y: 4395},
  188. // {x: 6403, y: 4013},
  189. // {x: 3260, y: 7986},
  190. // {x: 640, y: 6252}
  191. // ]];
  192. // player.setROI(data);
  193. // };
  194. //
  195. // document.getElementById('ROIdata').onclick = () =>{
  196. // let result = player.getROIData();
  197. // console.log(result)
  198. // };
  199. //
  200. // document.getElementById('ROIsetNum').onclick = ()=> {
  201. // let num = document.getElementById('ROINum').value;
  202. // player.setPolygonNum(num);
  203. // }
  204. function onDocumenDblClick(event) {
  205. show = !show;
  206. let width = window.screen.width;
  207. let height = window.screen.height;
  208. let canvas = document.getElementById('canvas');
  209. if(show) {
  210. if (document.body.requestFullscreen) { //解决兼容性问题
  211. document.body.requestFullscreen();
  212. } else if (document.body.webkitRequestFullScreen) { //兼容谷歌 /Edge
  213. document.body.webkitRequestFullScreen();
  214. } else if (document.body.mozRequestFullScreen) { //Firefox
  215. document.body.mozRequestFullScreen();
  216. }else if(document.body.msRequestFullscreen){//ie
  217. document.body.msRequestFullscreen();
  218. }
  219. canvas.style.position = 'fixed';
  220. canvas.style.top = 0;
  221. canvas.style.left = 0;
  222. document.getElementById('canvas').width = width;
  223. document.getElementById('canvas').height = height;
  224. document.getElementById('videoCanvas').width = width;
  225. document.getElementById('videoCanvas').height = height;
  226. } else {
  227. if(document.exitFullscreen) {
  228. document.exitFullscreen();
  229. } else if(document.mozCancelFullScreen) {
  230. document.mozCancelFullScreen();
  231. } else if(document.webkitExitFullscreen) {
  232. document.webkitExitFullscreen();
  233. }else if(document.msExitFullscreen) {
  234. document.msExitFullscreen();
  235. }
  236. document.getElementById('canvas').width = data[2];
  237. document.getElementById('canvas').height = data[3];
  238. document.getElementById('videoCanvas').width = data[2];
  239. document.getElementById('videoCanvas').height = data[3];
  240. }
  241. }
  242. let cloc = 0;
  243. let show = false;
  244. document.getElementById('canvas').onclick = function (e) {
  245. e.preventDefault();
  246. cloc++;
  247. setTimeout(() => {
  248. cloc = 0;
  249. }, 500)
  250. if(cloc == 2) {
  251. onDocumenDblClick()
  252. }
  253. }
  254. </script>
  255. </html>