This commit is contained in:
sxlxc
2025-07-19 18:12:38 +08:00
parent 72c6842238
commit fb9eaefc84

View File

@@ -1,13 +1,26 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Fira+Sans&display=swap" rel="stylesheet">
<title>HLS Player Test</title> <title>HLS Player Test</title>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script> <script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<style>
body {
font-family: "Fira Sans", sans-serif;
font-weight: 400;
font-style: normal;
}
</style>
</head> </head>
<body> <body>
<h1>Live Stream</h1> <h1>Live Stream</h1>
<div style="display: flex; justify-content: center;">
<video id="video" width="80%" controls></video> <video id="video" width="80%" controls></video>
</div>
<script> <script>
var video = document.getElementById('video'); var video = document.getElementById('video');
// ** CHANGE THIS URL TO YOUR STREAM URL ** // ** CHANGE THIS URL TO YOUR STREAM URL **
@@ -17,12 +30,12 @@
var hls = new Hls(); var hls = new Hls();
hls.loadSource(videoSrc); hls.loadSource(videoSrc);
hls.attachMedia(video); hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function() { hls.on(Hls.Events.MANIFEST_PARSED, function () {
video.play(); video.play();
}); });
} else if (video.canPlayType('application/vnd.apple.mpegurl')) { } else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = videoSrc; video.src = videoSrc;
video.addEventListener('loadedmetadata', function() { video.addEventListener('loadedmetadata', function () {
video.play(); video.play();
}); });
} }