GilbertClaus commited on
Commit
0afeddc
·
1 Parent(s): 899d1e1
Files changed (2) hide show
  1. Ark ReCode/index.html +1 -0
  2. Ark ReCode/script.js +22 -4
Ark ReCode/index.html CHANGED
@@ -5,6 +5,7 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
6
  <title>Ark Re Code Scraper</title>
7
  <link rel="stylesheet" href="style.css">
 
8
  </head>
9
  <body>
10
  <!-- Background Video -->
 
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
6
  <title>Ark Re Code Scraper</title>
7
  <link rel="stylesheet" href="style.css">
8
+ <script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
9
  </head>
10
  <body>
11
  <!-- Background Video -->
Ark ReCode/script.js CHANGED
@@ -1,24 +1,42 @@
1
  function playVideo(charName) {
2
- const fileName = `Ark Re Code - ${charName}.mp4`;
3
- const videoPath = `https://gilbertclaus.pythonanywhere.com/video/Ark ReCode/${fileName}`;
4
  const encodedURL = encodeURI(videoPath);
5
 
6
  const wrapper = document.getElementById("videoWrapper");
7
  wrapper.innerHTML = "";
8
 
9
  const video = document.createElement("video");
10
- video.src = encodedURL;
11
  video.width = 360;
12
  video.controls = true;
13
  video.autoplay = true;
14
  video.volume = 0.1;
15
  video.style.marginTop = "20px";
16
  wrapper.appendChild(video);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  }
 
18
 
19
  function fetchData() {
20
  const input = document.getElementById("charName").value.trim();
21
- const charaBtn = document.getElementById("chara");
22
 
23
  if (input === "") {
24
  // Ambil status tombol pertama sebagai acuan
 
1
  function playVideo(charName) {
2
+ const cleanName = charName.split('-').pop().trim().toLowerCase();
3
+ const videoPath = `https://gilbertclaus.pythonanywhere.com/video/Ark ReCode/${charName}/${cleanName}}.m3u8`;
4
  const encodedURL = encodeURI(videoPath);
5
 
6
  const wrapper = document.getElementById("videoWrapper");
7
  wrapper.innerHTML = "";
8
 
9
  const video = document.createElement("video");
 
10
  video.width = 360;
11
  video.controls = true;
12
  video.autoplay = true;
13
  video.volume = 0.1;
14
  video.style.marginTop = "20px";
15
  wrapper.appendChild(video);
16
+
17
+ if (Hls.isSupported()) {
18
+ const hls = new Hls();
19
+ hls.loadSource(encodedURL);
20
+ hls.attachMedia(video);
21
+ hls.on(Hls.Events.MANIFEST_PARSED, () => {
22
+ video.play();
23
+ });
24
+ } else if (video.canPlayType('application/vnd.apple.mpegurl')) {
25
+ // Safari atau browser yang sudah dukung .m3u8
26
+ video.src = encodedURL;
27
+ video.addEventListener('loadedmetadata', () => {
28
+ video.play();
29
+ });
30
+ } else {
31
+ // Fallback, tidak bisa memutar HLS
32
+ wrapper.innerHTML = "<p>Browser kamu tidak mendukung streaming video ini.</p>";
33
+ }
34
  }
35
+
36
 
37
  function fetchData() {
38
  const input = document.getElementById("charName").value.trim();
39
+ const charaBtns = document.querySelectorAll(".chara");
40
 
41
  if (input === "") {
42
  // Ambil status tombol pertama sebagai acuan