Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.43 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <!--<link id="favicon" rel="icon" type="image/x-icon" href="assets/favicon.ico">-->
  8. <title>Care</title>
  9. <style>
  10. body {
  11. background-color: black;
  12. width: 100%;
  13. height: 100%;
  14. overflow: hidden;
  15. }
  16.  
  17. * {
  18. box-sizing: border-box;
  19. }
  20.  
  21. #jwplayerdiv {
  22. position: absolute;
  23. max-width: 100%;
  24. max-height: 100%;
  25. pointer-events: none;
  26. }
  27.  
  28. .video-overlay {
  29. height: 100%;
  30. width: 100%;
  31. position: absolute;
  32. }
  33.  
  34. .controls {
  35. position: absolute;
  36. display: flex;
  37. flex-direction: column;
  38. justify-content: space-between;
  39. align-content: space-between;
  40. height: 100%;
  41. width: 100%;
  42. padding: 15px;
  43. }
  44.  
  45. .controls__time {
  46. width: 100%;
  47. display: flex;
  48. align-items: center;
  49. justify-content: center;
  50. }
  51.  
  52. button {
  53. background-color: white;
  54. border: 0;
  55. padding: 14px;
  56. margin: 12px;
  57. font-size: 16px;
  58. opacity: .6;
  59. font-weight: bold;
  60. }
  61.  
  62. button:hover {
  63. opacity: 1;
  64. }
  65.  
  66. .camera {
  67.  
  68. }
  69.  
  70. .camera--selected {
  71. opacity: 1;
  72. }
  73.  
  74. #cameraSwitch {
  75.  
  76. }
  77. </style>
  78. </head>
  79. <body>
  80. <div id="root">
  81. <div id="jwplayerdiv"></div>
  82.  
  83. <!--<div class="video-overlay"></div>-->
  84.  
  85. <div class="controls">
  86. <div id="cameraSwitch"></div>
  87.  
  88. <div></div>
  89.  
  90. <div class="controls__time">
  91. <button id="time-minus3s">-3 sec</button>
  92. <button id="time-live">Live</button>
  93. </div>
  94. </div>
  95. </div>
  96.  
  97. <script src="https://content.jwplatform.com/libraries/wr6i4gal.js"></script>
  98.  
  99. <script>
  100. (function() {
  101. let allCameras = [
  102. "http://192.168.18.169/r/streams/rec1/15-35-24.mpd",
  103. "http://192.168.18.169/r/streams/rec1/15-33-15.mpd"
  104. ]
  105.  
  106. let player;
  107.  
  108. function loadJwPlayer(videoUrl) {
  109. let ywPlayerLoadInterval = setInterval(() => {
  110. if (typeof jwplayer !== "undefined") {
  111. _loadYwPlayer(videoUrl);
  112. clearInterval(ywPlayerLoadInterval);
  113. }
  114. }, 200);
  115.  
  116. function _loadYwPlayer(videoUrl) {
  117. player = jwplayer('jwplayerdiv').setup({
  118. file: videoUrl,
  119. controls: false,
  120. displaytitle: false
  121. });
  122. }
  123. }
  124.  
  125. function setSelectedCamera(i) {
  126. for(let other of document.getElementById("cameraSwitch").childNodes) {
  127. if(other.getAttribute("camera") == i) {
  128. other.classList.add("camera--selected");
  129. } else {
  130. other.classList.remove("camera--selected");
  131. }
  132. }
  133. }
  134.  
  135. allCameras.forEach((c,i) => {
  136. let btn = document.createElement("button");
  137. btn.innerHTML = `Camera ${i+1}`;
  138. btn.classList.add("camera");
  139. btn.setAttribute("camera", i);
  140.  
  141. btn.onclick = () => {
  142. loadJwPlayer(c);
  143. setSelectedCamera(i);
  144. };
  145.  
  146. document.getElementById("cameraSwitch").append(btn);
  147. });
  148.  
  149. document.getElementById("time-minus3s").addEventListener("click", function(ev) {
  150. player.seek(player.getPosition() - 3);
  151. });
  152.  
  153.  
  154. document.getElementById("time-live").addEventListener("click", function(ev) {
  155. player.seek(-1);
  156. });
  157.  
  158. loadJwPlayer(allCameras[0]);
  159. setSelectedCamera(0);
  160. })();
  161. </script>
  162. </body>
  163. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement