index.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>player</title>
  6. <style>
  7. .sk-chase {
  8. width: 40px;
  9. height: 40px;
  10. position: absolute;
  11. top: 50%;
  12. left: 50%;
  13. transform: translate(-50%, -50%);
  14. display: block;
  15. animation: sk-chase 2.5s infinite linear both;
  16. }
  17. .sk-chase-dot {
  18. width: 100%;
  19. height: 100%;
  20. position: absolute;
  21. left: 0;
  22. top: 0;
  23. animation: sk-chase-dot 2.0s infinite ease-in-out both;
  24. }
  25. .sk-chase-dot:before {
  26. content: '';
  27. display: block;
  28. width: 25%;
  29. height: 25%;
  30. background-color: #8cc5ff;
  31. border-radius: 100%;
  32. animation: sk-chase-dot-before 2.0s infinite ease-in-out both;
  33. }
  34. .sk-chase-dot:nth-child(1) { animation-delay: -1.1s; }
  35. .sk-chase-dot:nth-child(2) { animation-delay: -1.0s; }
  36. .sk-chase-dot:nth-child(3) { animation-delay: -0.9s; }
  37. .sk-chase-dot:nth-child(4) { animation-delay: -0.8s; }
  38. .sk-chase-dot:nth-child(5) { animation-delay: -0.7s; }
  39. .sk-chase-dot:nth-child(6) { animation-delay: -0.6s; }
  40. .sk-chase-dot:nth-child(1):before { animation-delay: -1.1s; }
  41. .sk-chase-dot:nth-child(2):before { animation-delay: -1.0s; }
  42. .sk-chase-dot:nth-child(3):before { animation-delay: -0.9s; }
  43. .sk-chase-dot:nth-child(4):before { animation-delay: -0.8s; }
  44. .sk-chase-dot:nth-child(5):before { animation-delay: -0.7s; }
  45. .sk-chase-dot:nth-child(6):before { animation-delay: -0.6s; }
  46. @keyframes sk-chase {
  47. 100% { transform: rotate(360deg); }
  48. }
  49. @keyframes sk-chase-dot {
  50. 80%, 100% { transform: rotate(360deg); }
  51. }
  52. @keyframes sk-chase-dot-before {
  53. 50% {
  54. transform: scale(0.4);
  55. } 100%, 0% {
  56. transform: scale(1.0);
  57. }
  58. }
  59. #error_text {
  60. width: 100%;
  61. height: 100%;
  62. text-align: center;
  63. display: none;
  64. position: absolute;
  65. top: 0;
  66. left: 0;
  67. font-size: 20px;
  68. font-weight: 600;
  69. background-color: #8cc5ff;
  70. }
  71. body::-webkit-scrollbar {
  72. display: none;
  73. }
  74. </style>
  75. </head>
  76. <body style="margin: 0; width: 100%; text-align: center; z-index:999; background-color: transparent; overflow: hidden" >
  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. const options = {
  133. video: document.getElementById('video'),
  134. canvas: document.getElementById('canvas'),
  135. drawer: document.getElementById('draw'),
  136. // wsUrl:'ws://111.2.71.225:10080/camera_relay?tcpaddr=admin%3Ahmkj6688%40192.168.1.144',
  137. // rtspUrl: 'rtsp://admin:hmkj6688@192.168.1.144',
  138. user: '',
  139. pwd: ''
  140. };
  141. options.wsUrl = data[1];
  142. options.rtspUrl = data[2];
  143. console.log(options.rtspUrl);
  144. let player = new Player(options);
  145. player.init();
  146. player.on('error', function () {
  147. console.log('连接失败')
  148. let er = document.getElementById('error_text');
  149. er.style.display = 'block';
  150. // er.style.lineHeight = height + 'px';
  151. er.style.lineHeight = height + 'px';
  152. });
  153. player.on('noStream', function () {
  154. console.log('noStream');
  155. player.close();
  156. player = null;
  157. player = new Player(options);
  158. player.init();
  159. player.connect();
  160. });
  161. // 首次播放
  162. player.on('canplay', function () {
  163. //player.close();
  164. let sk = document.getElementsByClassName('sk-chase')[0];
  165. sk.style.display = 'none';
  166. });
  167. player.on('initialCompleted', function () {
  168. });
  169. player.on('ROIFinished', function () {
  170. console.log('ROIFinished');
  171. });
  172. player.connect();
  173. window.onload = function() {
  174. document.addEventListener('dblclick', onDocumenDblClick);
  175. };
  176. </script>
  177. </html>