Spaces:
Running
Running
File size: 1,828 Bytes
899d1e1 0afeddc 899d1e1 0afeddc 1d818b8 0afeddc 1d818b8 899d1e1 0afeddc 899d1e1 0bcdffe 899d1e1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | function playVideo(charName) {
const cleanName = charName.split('-').pop().trim().toLowerCase();
const videoPath = `https://gilbertclaus.pythonanywhere.com/video/Ark ReCode/${charName}/${cleanName}}.m3u8`;
const encodedURL = encodeURI(videoPath);
const wrapper = document.getElementById("videoWrapper");
wrapper.innerHTML = "";
const video = document.createElement("video");
video.width = 360;
video.controls = true;
video.autoplay = true;
video.volume = 0.1;
video.style.marginTop = "20px";
wrapper.appendChild(video);
if (Hls.isSupported()) {
const hls = new Hls();
hls.loadSource(encodedURL);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, () => {
video.play();
});
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
// Safari atau browser yang sudah dukung .m3u8
video.src = encodedURL;
video.addEventListener('loadedmetadata', () => {
video.play();
});
} else {
// Fallback, tidak bisa memutar HLS
wrapper.innerHTML = "<p>Browser kamu tidak mendukung streaming video ini.</p>";
}
}
function fetchData() {
const input = document.getElementById("charName").value.trim();
const charaBtns = document.querySelectorAll(".chara");
if (input === "") {
// Ambil status tombol pertama sebagai acuan
const isHidden = charaBtns[0].style.display === "none" || charaBtns[0].style.display === "";
// Toggle semua tombol
charaBtns.forEach(btn => {
btn.style.display = isHidden ? "inline-block" : "none";
});
} else {
const name = document.getElementById("charName").value;
alert(`Fungsi fetchData untuk karakter "${name}" belum diimplementasikan`);
}
} |