Skip to content

Commit 1f76fae

Browse files
Add files via upload
1 parent 29154a4 commit 1f76fae

2 files changed

Lines changed: 145 additions & 0 deletions

File tree

index.html

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<!DOCTYPE html>
2+
<html lang="zh-CN">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>直播站</title>
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
8+
<!-- HLS & FLV -->
9+
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
10+
<script src="https://cdn.jsdelivr.net/npm/flv.js@latest"></script>
11+
12+
<style>
13+
body {
14+
margin: 0;
15+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
16+
background: #0f0f0f;
17+
color: #eee;
18+
}
19+
20+
header {
21+
display: flex;
22+
justify-content: space-between;
23+
align-items: center;
24+
padding: 12px 20px;
25+
background: #1a1a1a;
26+
border-bottom: 1px solid #333;
27+
}
28+
29+
header h1 {
30+
margin: 0;
31+
font-size: 18px;
32+
}
33+
34+
#time {
35+
font-size: 14px;
36+
opacity: 0.9;
37+
}
38+
39+
main {
40+
display: flex;
41+
flex-direction: column;
42+
align-items: center;
43+
padding: 20px;
44+
gap: 16px;
45+
}
46+
47+
video {
48+
width: 100%;
49+
max-width: 960px;
50+
background: #000;
51+
}
52+
53+
#quote {
54+
max-width: 960px;
55+
font-size: 15px;
56+
opacity: 0.85;
57+
text-align: center;
58+
min-height: 1.5em;
59+
}
60+
61+
footer {
62+
position: fixed;
63+
left: 10px;
64+
bottom: 8px;
65+
font-size: 12px;
66+
opacity: 0.6;
67+
}
68+
</style>
69+
</head>
70+
<body>
71+
72+
<header>
73+
<h1>我的直播站</h1>
74+
<div id="time"></div>
75+
</header>
76+
77+
<main>
78+
<!-- 播放器:你只改 src -->
79+
<video id="player" controls autoplay muted></video>
80+
81+
<div id="quote">加载中…</div>
82+
</main>
83+
84+
<footer>
85+
© 2026 Your Site Name
86+
</footer>
87+
88+
<script>
89+
/* ===== 实时时间 ===== */
90+
function updateTime() {
91+
const now = new Date();
92+
document.getElementById("time").textContent =
93+
now.toLocaleString("zh-CN", { hour12: false });
94+
}
95+
updateTime();
96+
setInterval(updateTime, 1000);
97+
98+
/* ===== 播放器 ===== */
99+
const video = document.getElementById("player");
100+
101+
// ↓↓↓ 在这里填你的流地址 ↓↓↓
102+
const streamUrl = ""; // 例如:https://example.com/live.m3u8
103+
104+
if (streamUrl.endsWith(".m3u8")) {
105+
if (Hls.isSupported()) {
106+
const hls = new Hls();
107+
hls.loadSource(streamUrl);
108+
hls.attachMedia(video);
109+
} else {
110+
video.src = streamUrl;
111+
}
112+
} else if (streamUrl.endsWith(".flv")) {
113+
if (flvjs.isSupported()) {
114+
const flvPlayer = flvjs.createPlayer({
115+
type: 'flv',
116+
url: streamUrl
117+
});
118+
flvPlayer.attachMediaElement(video);
119+
flvPlayer.load();
120+
}
121+
} else if (streamUrl) {
122+
video.src = streamUrl;
123+
}
124+
125+
/* ===== 一言 JSON ===== */
126+
fetch("quotes.json")
127+
.then(res => res.json())
128+
.then(list => {
129+
if (Array.isArray(list) && list.length > 0) {
130+
const item = list[Math.floor(Math.random() * list.length)];
131+
document.getElementById("quote").textContent =
132+
typeof item === "string" ? item : item.text;
133+
}
134+
})
135+
.catch(() => {
136+
document.getElementById("quote").textContent = "获取一言失败";
137+
});
138+
</script>
139+
140+
</body>
141+
</html>

quotes,json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[
2+
"Hello world!",
3+
"In solitude, where we are least alone. \n ——『ヨスガノソラ』"
4+
]

0 commit comments

Comments
 (0)