index.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. /*.close {*/
  11. /* width: 40px;*/
  12. /* height: 40px;*/
  13. /* background-image: url('./image/close.png') ;*/
  14. /* background-size: 100% 100%;*/
  15. /* position: fixed;*/
  16. /* top: 20px;*/
  17. /* right: 20px;*/
  18. /* z-index: 99;*/
  19. /* cursor: pointer;*/
  20. /* display: none;*/
  21. /*}*/
  22. </style>
  23. </head>
  24. <body style="margin: 0; width: 100%; text-align: center; z-index:999;" >
  25. <!-- <i class="close"></i>-->
  26. <!--onload="open()"-->
  27. <video width="100%" id="video"></video>
  28. <canvas id="canvas"></canvas>
  29. <canvas id="draw"></canvas>
  30. <!-- <button id="full">全屏</button>-->
  31. </body>
  32. <script type="module">
  33. import Player from "./src/player.js";
  34. var clickTimeId;
  35. let str = location.href;
  36. let num = str.indexOf('?');
  37. str = str.substr(num+1);
  38. let data = str.split(',');
  39. let isShow = Number(data[0]);
  40. let key = data[4];
  41. const close = document.getElementsByClassName('close')[0];
  42. let video = document.getElementsByTagName('body')[0];
  43. video.dblclick = function () {
  44. };
  45. function onDocumentClick(event) {
  46. // 取消上次延时未执行的方法
  47. clearTimeout(clickTimeId);
  48. //执行延时
  49. clickTimeId = setTimeout(function() {
  50. //此处为单击事件要执行的代码
  51. console.log("鼠标单击");
  52. }, 250);
  53. }
  54. function onDocumenDblClick(event) {
  55. // 取消上次延时未执行的方法
  56. clearTimeout(clickTimeId);
  57. console.log("鼠标双击");
  58. // isFullscreenEnabled();
  59. let video = document.getElementById('video');
  60. if (video.requestFullscreen) { //w3c
  61. console.log(video.requestFullscreen);
  62. console.log(video.requestFullscreen());
  63. video.requestFullscreen();
  64. } else if (video.mozRequestFullScreen) { //moz Firefox
  65. video.mozRequestFullScreen();
  66. } else if (video.msRequestFullscreen) { //IE
  67. video.msRequestFullscreen();
  68. } else if (video.oRequestFullscreen) { //Opera
  69. video.oRequestFullscreen();
  70. } else if (video.webkitRequestFullscreen) { //webkit内核 Chrome Safari
  71. video.webkitRequestFullScreen();
  72. }
  73. }
  74. const options = {
  75. video: document.getElementById('video'),
  76. canvas: document.getElementById('canvas'),
  77. drawer: document.getElementById('draw'),
  78. // wsUrl:'ws://111.2.71.225:10080/camera_relay?tcpaddr=admin%3Ahmkj6688%40192.168.1.144',
  79. // rtspUrl: 'rtsp://admin:hmkj6688@192.168.1.144',
  80. user: '',
  81. pwd: ''
  82. };
  83. options.wsUrl = data[1];
  84. options.rtspUrl = data[2];
  85. let player = new Player(options);
  86. player.init();
  87. player.on('error', function () {
  88. console.log('连接失败')
  89. });
  90. player.on('noStream', function () {
  91. console.log('noStream');
  92. player.close();
  93. player = null;
  94. player = new Player(options);
  95. player.init();
  96. player.connect();
  97. });
  98. player.on('canplay', function () {
  99. //player.close();
  100. });
  101. player.on('initialCompleted', function () {
  102. });
  103. player.on('ROIFinished', function () {
  104. console.log('ROIFinished');
  105. });
  106. player.connect();
  107. window.onload = function() {
  108. document.addEventListener('dblclick', onDocumenDblClick);
  109. };
  110. </script>
  111. </html>