index.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>player</title>
  6. <!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.0.0/p5.min.js"></script>-->
  7. <!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.0.0/addons/p5.sound.min.js"></script>-->
  8. <!-- <script src="https://unpkg.com/ml5@latest/dist/ml5.min.js"></script>-->
  9. <style>
  10. .sk-chase {
  11. width: 40px;
  12. height: 40px;
  13. position: absolute;
  14. top: 50%;
  15. left: 50%;
  16. transform: translate(-50%, -50%);
  17. display: block;
  18. animation: sk-chase 2.5s infinite linear both;
  19. }
  20. .sk-chase-dot {
  21. width: 100%;
  22. height: 100%;
  23. position: absolute;
  24. left: 0;
  25. top: 0;
  26. animation: sk-chase-dot 2.0s infinite ease-in-out both;
  27. }
  28. .sk-chase-dot:before {
  29. content: '';
  30. display: block;
  31. width: 25%;
  32. height: 25%;
  33. background-color: #8cc5ff;
  34. border-radius: 100%;
  35. animation: sk-chase-dot-before 2.0s infinite ease-in-out both;
  36. }
  37. .sk-chase-dot:nth-child(1) { animation-delay: -1.1s; }
  38. .sk-chase-dot:nth-child(2) { animation-delay: -1.0s; }
  39. .sk-chase-dot:nth-child(3) { animation-delay: -0.9s; }
  40. .sk-chase-dot:nth-child(4) { animation-delay: -0.8s; }
  41. .sk-chase-dot:nth-child(5) { animation-delay: -0.7s; }
  42. .sk-chase-dot:nth-child(6) { animation-delay: -0.6s; }
  43. .sk-chase-dot:nth-child(1):before { animation-delay: -1.1s; }
  44. .sk-chase-dot:nth-child(2):before { animation-delay: -1.0s; }
  45. .sk-chase-dot:nth-child(3):before { animation-delay: -0.9s; }
  46. .sk-chase-dot:nth-child(4):before { animation-delay: -0.8s; }
  47. .sk-chase-dot:nth-child(5):before { animation-delay: -0.7s; }
  48. .sk-chase-dot:nth-child(6):before { animation-delay: -0.6s; }
  49. @keyframes sk-chase {
  50. 100% { transform: rotate(360deg); }
  51. }
  52. @keyframes sk-chase-dot {
  53. 80%, 100% { transform: rotate(360deg); }
  54. }
  55. @keyframes sk-chase-dot-before {
  56. 50% {
  57. transform: scale(0.4);
  58. } 100%, 0% {
  59. transform: scale(1.0);
  60. }
  61. }
  62. #error_text {
  63. width: 100%;
  64. height: 100%;
  65. text-align: center;
  66. display: none;
  67. position: absolute;
  68. top: 0;
  69. left: 0;
  70. font-size: 20px;
  71. font-weight: 600;
  72. background-color: #8cc5ff;
  73. }
  74. </style>
  75. </head>
  76. <body style="margin: 0; width: 100%; text-align: center; z-index:999; background-color: #fff" >
  77. <video width="100%" id="video"></video>
  78. <canvas id="canvas"></canvas>
  79. <canvas id="draw"></canvas>
  80. <div class="sk-chase">
  81. <div class="sk-chase-dot"></div>
  82. <div class="sk-chase-dot"></div>
  83. <div class="sk-chase-dot"></div>
  84. <div class="sk-chase-dot"></div>
  85. <div class="sk-chase-dot"></div>
  86. <div class="sk-chase-dot"></div>
  87. </div>
  88. <div id="error_text" >服务器连接失败,请联系管理员</div>
  89. </body>
  90. <script type="module">
  91. import Player from "./src/player.js";
  92. var clickTimeId;
  93. let str = location.href;
  94. let num = str.indexOf('?');
  95. str = str.substr(num+1);
  96. let data = str.split(',');
  97. let isShow = Number(data[0]);
  98. let key = data[4];
  99. let video = document.getElementsByTagName('body')[0];
  100. let height = video.clientHeight;
  101. video.dblclick = function () {
  102. };
  103. function onDocumentClick(event) {
  104. // 取消上次延时未执行的方法
  105. clearTimeout(clickTimeId);
  106. //执行延时
  107. clickTimeId = setTimeout(function() {
  108. //此处为单击事件要执行的代码
  109. console.log("鼠标单击");
  110. }, 250);
  111. }
  112. function onDocumenDblClick(event) {
  113. // 取消上次延时未执行的方法
  114. clearTimeout(clickTimeId);
  115. console.log("鼠标双击");
  116. // isFullscreenEnabled();
  117. let video = document.getElementById('video');
  118. if (video.requestFullscreen) { //w3c
  119. console.log(video.requestFullscreen);
  120. console.log(video.requestFullscreen());
  121. video.requestFullscreen();
  122. } else if (video.mozRequestFullScreen) { //moz Firefox
  123. video.mozRequestFullScreen();
  124. } else if (video.msRequestFullscreen) { //IE
  125. video.msRequestFullscreen();
  126. } else if (video.oRequestFullscreen) { //Opera
  127. video.oRequestFullscreen();
  128. } else if (video.webkitRequestFullscreen) { //webkit内核 Chrome Safari
  129. video.webkitRequestFullScreen();
  130. }
  131. }
  132. // close.onclick = function () {
  133. // let video = document.getElementById('bodySng');
  134. // }
  135. // function isFullscreenEnabled() {
  136. // return (document.fullscreenEnabled || document.mozFullScreenEnabled || document.webkitFullscreenEnabled || document.msFullscreenEnabled);
  137. // }
  138. const options = {
  139. video: document.getElementById('video'),
  140. canvas: document.getElementById('canvas'),
  141. drawer: document.getElementById('draw'),
  142. // wsUrl:'ws://111.2.71.225:10080/camera_relay?tcpaddr=admin%3Ahmkj6688%40192.168.1.144',
  143. // rtspUrl: 'rtsp://admin:hmkj6688@192.168.1.144',
  144. user: '',
  145. pwd: ''
  146. };
  147. options.wsUrl = data[1];
  148. options.rtspUrl = data[2];
  149. console.log(options.rtspUrl);
  150. let player = new Player(options);
  151. player.init();
  152. player.on('error', function () {
  153. console.log('连接失败')
  154. let er = document.getElementById('error_text');
  155. er.style.display = 'block';
  156. // er.style.lineHeight = height + 'px';
  157. er.style.lineHeight = height + 'px';
  158. });
  159. player.on('noStream', function () {
  160. console.log('noStream');
  161. player.close();
  162. player = null;
  163. player = new Player(options);
  164. player.init();
  165. player.connect();
  166. });
  167. // 首次播放
  168. player.on('canplay', function () {
  169. //player.close();
  170. let sk = document.getElementsByClassName('sk-chase')[0];
  171. sk.style.display = 'none';
  172. });
  173. player.on('initialCompleted', function () {
  174. });
  175. player.on('ROIFinished', function () {
  176. console.log('ROIFinished');
  177. });
  178. player.connect();
  179. window.onload = function() {
  180. document.addEventListener('dblclick', onDocumenDblClick);
  181. };
  182. // document.getElementById('close').onclick = ()=>{
  183. // player.close();
  184. // };
  185. // document.getElementById('ROIreset').onclick = () =>{
  186. // player.resetROI();
  187. // };
  188. // document.getElementById('ROIset').onclick = () =>{
  189. // let data = [[
  190. // {x: 2861, y: 4395},
  191. // {x: 6403, y: 4013},
  192. // {x: 3260, y: 7986},
  193. // {x: 640, y: 6252}
  194. // ]];
  195. // player.setROI(data);
  196. // };
  197. // document.getElementById('ROIdata').onclick = () =>{
  198. // let result = player.getROIData();
  199. // };
  200. // document.getElementById('ROIsetNum').onclick = ()=> {
  201. // let num = document.getElementById('ROINum').value;
  202. // player.setPolygonNum(num);
  203. // }
  204. // document.getElementById('ROIChange1').onclick = ()=> {
  205. // player.changeROIType('Polygon1');
  206. // }
  207. //
  208. // document.getElementById('ROIChange2').onclick = ()=> {
  209. // player.changeROIType('Polygon2');
  210. // }
  211. //
  212. // document.getElementById('ROIChange3').onclick = ()=> {
  213. // player.changeROIType('Polygon1Line1');
  214. // }
  215. //
  216. // document.getElementById('ROIChange4').onclick = ()=> {
  217. // player.changeROIType('Line2');
  218. // }
  219. </script>
  220. </html>