index.html 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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_text {
  21. position: absolute;
  22. top: 40%;
  23. left: 50%;
  24. transform: translate(-50%, -50%);
  25. display: block;
  26. color: #fff;
  27. }
  28. .sk-chase-dot {
  29. width: 100%;
  30. height: 100%;
  31. position: absolute;
  32. left: 0;
  33. top: 0;
  34. animation: sk-chase-dot 2.0s infinite ease-in-out both;
  35. }
  36. .sk-chase-dot:before {
  37. content: '';
  38. display: block;
  39. width: 25%;
  40. height: 25%;
  41. background-color: #8cc5ff;
  42. border-radius: 100%;
  43. animation: sk-chase-dot-before 2.0s infinite ease-in-out both;
  44. }
  45. .sk-chase-dot:nth-child(1) { animation-delay: -1.1s; }
  46. .sk-chase-dot:nth-child(2) { animation-delay: -1.0s; }
  47. .sk-chase-dot:nth-child(3) { animation-delay: -0.9s; }
  48. .sk-chase-dot:nth-child(4) { animation-delay: -0.8s; }
  49. .sk-chase-dot:nth-child(5) { animation-delay: -0.7s; }
  50. .sk-chase-dot:nth-child(6) { animation-delay: -0.6s; }
  51. .sk-chase-dot:nth-child(1):before { animation-delay: -1.1s; }
  52. .sk-chase-dot:nth-child(2):before { animation-delay: -1.0s; }
  53. .sk-chase-dot:nth-child(3):before { animation-delay: -0.9s; }
  54. .sk-chase-dot:nth-child(4):before { animation-delay: -0.8s; }
  55. .sk-chase-dot:nth-child(5):before { animation-delay: -0.7s; }
  56. .sk-chase-dot:nth-child(6):before { animation-delay: -0.6s; }
  57. @keyframes sk-chase {
  58. 100% { transform: rotate(360deg); }
  59. }
  60. @keyframes sk-chase-dot {
  61. 80%, 100% { transform: rotate(360deg); }
  62. }
  63. @keyframes sk-chase-dot-before {
  64. 50% {
  65. transform: scale(0.4);
  66. } 100%, 0% {
  67. transform: scale(1.0);
  68. }
  69. }
  70. #error_text {
  71. width: 170px;
  72. height: 170px;
  73. background: url("./image/siagn.png") no-repeat;
  74. background-size: 100%;
  75. position: absolute;
  76. top: 50%;
  77. left: 50%;
  78. transform: translate(-50%, -50%);
  79. display: none;
  80. }
  81. body::-webkit-scrollbar {
  82. display: none;
  83. }
  84. </style>
  85. </head>
  86. <body style="margin: 0; width: 100%; text-align: center; z-index:999; background-color: transparent; overflow:hidden " >
  87. <video width="100%" id="video"></video>
  88. <canvas id="canvas"></canvas>
  89. <canvas id="draw"></canvas>
  90. <div id="sk_text" class="sk_text">视频加载中..</div>
  91. <div class="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 type="module">
  102. import Player from "./src/player.js";
  103. var clickTimeId;
  104. let str = location.href;
  105. let num = str.indexOf('?');
  106. str = str.substr(num+1);
  107. let data = str.split(',');
  108. let isShow = Number(data[0]);
  109. let key = data[4];
  110. let video = document.getElementsByTagName('body')[0];
  111. let height = video.clientHeight;
  112. // 定时器
  113. let timer = null;
  114. let count = 0;
  115. video.dblclick = function () {
  116. };
  117. function onDocumentClick(event) {
  118. // 取消上次延时未执行的方法
  119. clearTimeout(clickTimeId);
  120. //执行延时
  121. clickTimeId = setTimeout(function() {
  122. //此处为单击事件要执行的代码
  123. console.log("鼠标单击");
  124. }, 250);
  125. }
  126. function onDocumenDblClick(event) {
  127. // 取消上次延时未执行的方法
  128. clearTimeout(clickTimeId);
  129. console.log("鼠标双击");
  130. // isFullscreenEnabled();
  131. let video = document.getElementById('video');
  132. if (video.requestFullscreen) { //w3c
  133. console.log(video.requestFullscreen);
  134. console.log(video.requestFullscreen());
  135. video.requestFullscreen();
  136. } else if (video.mozRequestFullScreen) { //moz Firefox
  137. video.mozRequestFullScreen();
  138. } else if (video.msRequestFullscreen) { //IE
  139. video.msRequestFullscreen();
  140. } else if (video.oRequestFullscreen) { //Opera
  141. video.oRequestFullscreen();
  142. } else if (video.webkitRequestFullscreen) { //webkit内核 Chrome Safari
  143. video.webkitRequestFullScreen();
  144. }
  145. }
  146. // close.onclick = function () {
  147. // let video = document.getElementById('bodySng');
  148. // }
  149. // function isFullscreenEnabled() {
  150. // return (document.fullscreenEnabled || document.mozFullScreenEnabled || document.webkitFullscreenEnabled || document.msFullscreenEnabled);
  151. // }
  152. const options = {
  153. video: document.getElementById('video'),
  154. canvas: document.getElementById('canvas'),
  155. drawer: document.getElementById('draw'),
  156. // wsUrl:'ws://111.2.71.225:10080/camera_relay?tcpaddr=admin%3Ahmkj6688%40192.168.1.144',
  157. // rtspUrl: 'rtsp://admin:hmkj6688@192.168.1.144',
  158. user: '',
  159. pwd: ''
  160. };
  161. options.wsUrl = data[1];
  162. options.rtspUrl = data[2];
  163. let player = new Player(options);
  164. player.init();
  165. player.on('error', function () {
  166. clearInterval(timer)
  167. console.log('连接失败')
  168. let er = document.getElementById('error_text');
  169. er.style.display = 'block';
  170. // er.style.lineHeight = height + 'px';
  171. er.style.lineHeight = height + 'px';
  172. });
  173. player.on('noStream', function () {
  174. console.log('noStream');
  175. player.close();
  176. player = null;
  177. player = new Player(options);
  178. player.init();
  179. player.connect();
  180. });
  181. // 首次播放
  182. player.on('canplay', function () {
  183. clearInterval(timer)
  184. let sk = document.getElementsByClassName('sk-chase')[0];
  185. sk.style.display = 'none';
  186. let text = document.getElementById('sk_text');
  187. text.style.display = 'none';
  188. });
  189. player.on('initialCompleted', function () {
  190. });
  191. player.on('ROIFinished', function () {
  192. console.log('ROIFinished');
  193. });
  194. player.connect();
  195. window.onload = function() {
  196. document.addEventListener('dblclick', onDocumenDblClick);
  197. };
  198. timer = setInterval(() => {
  199. count++;
  200. if(count > 5) {
  201. player.close();
  202. count = 0;
  203. let er = document.getElementById('error_text');
  204. er.style.display = 'block';
  205. er.style.lineHeight = height + 'px';
  206. let sk = document.getElementsByClassName('sk-chase')[0];
  207. sk.style.display = 'none';
  208. let text = document.getElementById('sk_text');
  209. text.style.display = 'none';
  210. clearInterval(timer)
  211. }
  212. }, 1000)
  213. </script>
  214. </html>