samipote

Untitled

Aug 25th, 2023
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.79 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en"> <!-- specify the language of the document -->
  3. <head>
  4. <meta charset="UTF-8"> <!-- specify the character encoding of the document -->
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- specify the viewport settings for responsive design -->
  6. <meta name="description" content="The Sports Watcher is a web app that lets you watch live streams of various sports games."> <!-- provide a brief summary of the web page for search engines and users -->
  7. <title>The Sports Watcher</title>
  8. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
  9. <link href="https://vjs.zencdn.net/8.5.2/video-js.css" rel="stylesheet" />
  10. <link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;700&display=swap" rel="stylesheet">
  11. <style>
  12. :root {
  13. --bg-color: linear-gradient(to right, #000000, #3c3d5b, #000000); /* define a CSS variable for background color */
  14. --text-color: #fff; /* define a CSS variable for text color */
  15. --shadow-color: rgba(0,0,0,0.3); /* define a CSS variable for shadow color */
  16. --accent-color: #ffcc00; /* define a CSS variable for accent color */
  17. --rotation-degree: 5deg;
  18. --scale-value: 1.1;
  19. }
  20.  
  21. body {
  22. font-family: 'Montserrat', sans-serif;
  23. background: var(--bg-color); /* use the CSS variable for background color */
  24. margin: 0;
  25. color: var(--text-color); /* use the CSS variable for text color */
  26. }
  27.  
  28. .container {
  29. margin: 0 auto;
  30. max-width: 1200px;
  31. padding: 2%;
  32. }
  33.  
  34. header {
  35. /* use a semantic element for the header */
  36. text-align: center;
  37. margin-top: 2%;
  38. }
  39.  
  40. h1 {
  41. font-weight: 700;
  42. color: var(--text-color);
  43. text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
  44. transition: all 0.3s ease;
  45. }
  46.  
  47. h1:hover {
  48. transform: scale(1.1);
  49. }
  50.  
  51. nav {
  52. /* use a semantic element for the navigation */
  53. display: flex;
  54. justify-content: center;
  55. align-items: center;
  56. }
  57.  
  58. #gamesDropdown {
  59. display: block;
  60. width: 100%;
  61. padding: 0.4em 1em;
  62. font-size: 1em;
  63. margin-bottom: 2%;
  64. border: none;
  65. border-radius: 20px;
  66. background-color: var(--text-color);
  67. color: #333;
  68. box-shadow: 0 10px 10px var(--shadow-color); /* use the CSS variable for shadow color */
  69. transition: all 0.3s ease;
  70. }
  71.  
  72. #gamesDropdown:hover {
  73. box-shadow: 0 15px 15px var(--shadow-color);
  74. }
  75.  
  76. #gamesDropdown:focus {
  77. outline: none;
  78. border-color: var(--accent-color); /* use the CSS variable for accent color */
  79. box-shadow: 0 0 0 0.2rem rgba(255,204,0,.25);
  80. }
  81.  
  82. main {
  83. /* use a semantic element for the main content */
  84. margin-top: 5%;
  85. }
  86.  
  87. .video-container {
  88. position: relative;
  89. width: 100%;
  90. padding-top: 56.25%;
  91. border-radius: 20px;
  92. overflow: hidden;
  93. box-shadow: 0 10px 10px var(--shadow-color);
  94. perspective: 3000x; /* Add perspective for 3D transformations */
  95. transition: transform 3s; /* Add smooth transition for the transform property */
  96. }
  97. .video-container:hover{
  98. /* Scale the video on hover to create a 3D depth effect */
  99. transform: scale(var(--scale-value));
  100. }
  101. .video-container__player {
  102. /* use BEM methodology to name CSS classes and avoid specificity issues and conflicts */
  103. position:absolute;
  104. top :0;
  105. left :0;
  106. width :100%;
  107. height :100%;
  108. transform-style: preserve-3d; /* Make sure the 3D transformations are applied to child elements too */
  109. }
  110. @media screen and (max-width :768px) {
  111. /* use a media query to apply different styles for smaller screens */
  112. header {
  113. margin-top :5%;
  114. }
  115. nav {
  116. flex-direction : column; /* stack the nav items vertically */
  117. }
  118. #gamesDropdown {
  119. width :80%; /* reduce the width of the dropdown */
  120. }
  121. main {
  122. margin-top :10%; /* increase the margin-top of the main content */
  123. }
  124. .video-container {
  125. border-radius :10px; /* reduce the border-radius of the video container */
  126. }
  127. }
  128.  
  129. @media (orientation : portrait) {
  130. /* use a media query to apply different styles for portrait mode */
  131. .video-container__player {
  132. object-fit : cover; /* fit the video to the container */
  133. }
  134. }
  135. </style>
  136. </head>
  137. <body>
  138. <div class="container">
  139. <header>
  140. <!-- use a semantic element for the header -->
  141. <h1>The Sports Watcher</h1>
  142. </header>
  143. <nav>
  144. <!-- use a semantic element for the navigation -->
  145. <select id="gamesDropdown" onchange="loadGame()" class="form-control"></select>
  146. </nav>
  147. <main>
  148. <!-- use a semantic element for the main content -->
  149. <div class="video-container mt-5">
  150. <video-js id="player" class="video-js vjs-default-skin video-container__player" controls preload="none" data-setup='{}'>
  151. <!-- use BEM methodology to name CSS classes and avoid specificity issues and conflicts -->
  152. <p class="vjs-no-js">
  153. To view this video please enable JavaScript, and consider upgrading to a web browser that
  154. <a href="http://videojs.com/html5-video-support/" target="_blank" style="color:var(--accent-color);">supports HTML5 video</a> <!-- use the CSS variable for accent color -->
  155. </p>
  156. </video-js>
  157. </div>
  158. </main>
  159. </div>
  160. <script src="https://vjs.zencdn.net/8.5.2/video.js"></script>
  161. <script>
  162. let player = videojs('player');
  163.  
  164. // Listen for fullscreen changes and adjust control bar visibility
  165. player.on('fullscreenchange', function() {
  166. if (player.isFullscreen()) {
  167. player.controls(false); // hides the control bar
  168. } else {
  169. player.controls(true); // shows the control bar
  170. }
  171. });
  172. let gamesDropdown = document.getElementById('gamesDropdown');
  173. let games = {};
  174. const apiUrl = '/games';
  175. fetch(apiUrl)
  176. .then(response => response.json())
  177. .then(gamesData => {
  178. gamesData.forEach(game => {
  179. if (!games[game.sport]) {
  180. games[game.sport] = [];
  181. }
  182. games[game.sport].push(game);
  183. });
  184. for (let sport in games) {
  185. let optgroup = document.createElement('optgroup');
  186. optgroup.label = sport;
  187. games[sport].forEach(game => {
  188. let option = document.createElement('option');
  189. option.text = game.title;
  190. option.value = game.streamLink;
  191. optgroup.appendChild(option);
  192. });
  193. gamesDropdown.appendChild(optgroup);
  194. }
  195. loadGame();
  196. })
  197. .catch(error => {
  198. console.error('Error fetching games:', error);
  199. });
  200. function loadGame() {
  201. let streamLink = gamesDropdown.value;
  202. if (streamLink) {
  203. streamLink = streamLink.replace('https://', ''); // remove 'https://'
  204. streamLink = streamLink.replace('http://', ''); // remove 'http://'
  205. // Fetch headers from the proxy URL
  206. fetch('/proxy/' + streamLink, { method: 'HEAD' })
  207. .then(response => {
  208. if (response.ok) {
  209. let type = response.headers.get('content-type');
  210. // Setup the player with the obtained type
  211. player.src({ src: '/proxy/' + streamLink, type: type });
  212. } else {
  213. console.error("Error fetching video type:", response.statusText);
  214. }
  215. })
  216. .catch(error => {
  217. console.error("Failed to fetch video type:", error);
  218. });
  219. }
  220. }
  221. </script>
  222. </body>
  223. </html>
  224.  
  225.  
Advertisement
Add Comment
Please, Sign In to add comment