forked from RoonLabs/roon-connect-stream-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
363 lines (345 loc) · 12.1 KB
/
index.html
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>中文在线广播播放器</title>
<link rel="icon" href="image/icon.jpg" type="image/jpeg">
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #f8f9fa;
color: #333;
}
.container {
background: white;
padding: 30px;
border-radius: 15px;
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
h1 {
color: #2c3e50;
text-align: center;
margin-bottom: 30px;
font-weight: 300;
}
.input-group {
margin-bottom: 30px;
}
input[type="url"], input[type="number"] {
padding: 12px;
border: 1px solid #e1e4e8;
border-radius: 8px;
font-size: 16px;
margin-bottom: 10px;
background-color: #f8f9fa;
}
input[type="url"] {
width: 100%;
}
input[type="number"] {
width: 80px;
}
.button-group {
margin: 20px 0;
display: flex;
flex-wrap: wrap;
gap: 10px;
align-items: center;
}
button {
padding: 12px 24px;
border: none;
border-radius: 8px;
font-size: 16px;
cursor: pointer;
transition: all 0.3s ease;
}
.play-btn {
background-color: #3498db;
color: white;
width: 100%;
}
.play-btn:hover {
background-color: #2980b9;
}
.stop-btn {
background-color: #e74c3c;
color: white;
}
.stop-btn:hover {
background-color: #c0392b;
}
.volume-btn {
background-color: #2ecc71;
color: white;
}
.volume-btn:hover {
background-color: #27ae60;
}
#status {
margin-top: 20px;
padding: 10px;
border-radius: 8px;
text-align: center;
}
.success {
background-color: #d4edda;
color: #155724;
}
.error {
background-color: #f8d7da;
color: #721c24;
}
.control-section {
margin-top: 20px;
padding-top: 20px;
border-top: 1px solid #eee;
}
h2 {
color: #34495e;
margin-bottom: 15px;
font-weight: 400;
}
.quick-play {
margin: 20px 0;
padding: 15px;
background: #f8f9fa;
border-radius: 8px;
border: 1px solid #e1e4e8;
}
.quick-play a {
color: #3498db;
text-decoration: none;
display: block;
padding: 12px;
margin: 5px 0;
background: white;
border-radius: 6px;
transition: all 0.3s ease;
border: 1px solid #e1e4e8;
}
.quick-play a:hover {
color: #2980b9;
background: #f8f9fa;
transform: translateX(5px);
}
@media (max-width: 768px) {
.container {
padding: 15px;
}
.quick-play a {
padding: 15px;
font-size: 15px;
}
.button-group {
flex-direction: column;
}
.button-group button {
width: 100%;
}
}
.footer {
margin-top: 30px;
text-align: center;
color: #7f8c8d;
font-size: 14px;
padding-top: 20px;
border-top: 1px solid #eee;
}
.qrcode-section {
text-align: center;
margin-top: 30px;
padding: 20px;
background: #f8f9fa;
border-radius: 8px;
}
.qrcode-section img {
max-width: 200px;
border-radius: 8px;
margin: 10px 0;
}
.qrcode-section a {
color: #3498db;
text-decoration: none;
display: block;
margin-top: 10px;
}
</style>
</head>
<body>
<div class="container">
<h1>中文在线广播播放器</h1>
<!-- 播放控制 -->
<div class="input-group">
<input type="url" id="streamUrl" placeholder="请输入流媒体URL" required>
<button class="play-btn" onclick="playStream()">播放</button>
</div>
<!-- 停止播放按钮 -->
<div class="control-section">
<h2>播放控制</h2>
<div class="button-group">
<button class="stop-btn" onclick="stopPlayback()">停止播放</button>
</div>
</div>
<!-- 音量控制 -->
<div class="control-section">
<h2>音量控制</h2>
<div class="button-group">
<button class="volume-btn" onclick="adjustVolume('up')">音量增加</button>
<button class="volume-btn" onclick="adjustVolume('down')">音量减小</button>
<input type="number" id="volumeInput" min="0" max="100" placeholder="音量值">
<button class="volume-btn" onclick="setVolume()">设置音量</button>
</div>
</div>
<!-- 快捷播放链接 -->
<div class="quick-play">
<h2>快捷播放</h2>
<a href="#" onclick="playQuickStream('https://lhttp.qingting.fm/live/267/64k.mp3'); return false;">
上海经典音乐广播FM94.7
</a>
<a href="#" onclick="playQuickStream('https://lhttp.qingting.fm/live/2803/64k.mp3'); return false;">
苏州音乐广播FM102.8
</a>
<a href="#" onclick="playQuickStream('https://lhttp.qingting.fm/live/273/64k.mp3'); return false;">
上海Love Radio广播FM103.7
</a>
<a href="#" onclick="playQuickStream('https://lhttp.qingting.fm/live/274/64k.mp3'); return false;">
上海动感101 FM101.7
</a>
<a href="#" onclick="playQuickStream('https://lhttp.qingting.fm/live/5022023/64k.mp3'); return false;">
上海爱乐数字音乐广播FM981
</a>
<a href="#" onclick="playQuickStream('https://lhttp.qingting.fm/live/4936/64k.mp3'); return false;">
江苏音乐广播魅力897
</a>
<a href="#" onclick="playQuickStream('https://lhttp.qingting.fm/live/4936/64k.mp3'); return false;">
南京音乐广播FM105.8
</a>
<a href="#" onclick="playQuickStream('https://lhttp.qingting.fm/live/276/64k.mp3'); return false;">
上海第一财经广播FM90.9
</a>
<a href="#" onclick="playQuickStream('https://lhttp.qingting.fm/live/268/64k.mp3'); return false;">
上海故事广播FM107.2
</a>
</div>
<div id="status"></div>
<!-- 公众号二维码 -->
<div class="qrcode-section">
<h2>扫一扫,关注EPOCH官方公众号</h2>
<a href="https://mp.weixin.qq.com/mp/appmsgalbum?__biz=Mzg2MjAwNjcwNQ==&action=getalbum&album_id=1651568080709320706&scene=21" target="_blank" rel="noopener">
<img src="image/qrcode_for_gh_75032b7b381b_344-300x300.jpg" alt="EPOCH官方公众号">
</a>
</div>
<!-- 版权信息 -->
<div class="footer">
© 2024 <a href="http://www.epochaudio.cn/" target="_blank" rel="noopener">门耳朵制作</a>
</div>
</div>
<script>
function playQuickStream(url) {
document.getElementById('streamUrl').value = url;
playStream();
}
async function playStream() {
const streamUrl = document.getElementById('streamUrl').value;
const statusDiv = document.getElementById('status');
if (!streamUrl) {
statusDiv.className = 'error';
statusDiv.textContent = '请输入有效的URL';
return;
}
try {
const response = await fetch('/play', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ url: streamUrl })
});
const result = await response.json();
if (response.ok) {
statusDiv.className = 'success';
statusDiv.textContent = '开始播放流媒体';
} else {
statusDiv.className = 'error';
statusDiv.textContent = result.error || '播放失败';
}
} catch (error) {
statusDiv.className = 'error';
statusDiv.textContent = '连接服务器失败';
}
}
async function stopPlayback() {
const statusDiv = document.getElementById('status');
try {
const response = await fetch('/stop', {
method: 'POST'
});
if (response.ok) {
statusDiv.className = 'success';
statusDiv.textContent = '已停止播放';
} else {
statusDiv.className = 'error';
statusDiv.textContent = '停止播放失败';
}
} catch (error) {
console.error('Error:', error);
statusDiv.className = 'error';
statusDiv.textContent = '操作失败';
}
}
async function adjustVolume(direction) {
const statusDiv = document.getElementById('status');
try {
const response = await fetch(`/volume/${direction}`, {
method: 'POST'
});
if (response.ok) {
statusDiv.className = 'success';
statusDiv.textContent = `音量${direction === 'up' ? '增加' : '减小'}成功`;
} else {
statusDiv.className = 'error';
statusDiv.textContent = '调整音量失败';
}
} catch (error) {
console.error('Error:', error);
statusDiv.className = 'error';
statusDiv.textContent = '操作失败';
}
}
async function setVolume() {
const volume = document.getElementById('volumeInput').value;
const statusDiv = document.getElementById('status');
if (volume === '' || isNaN(volume)) {
statusDiv.className = 'error';
statusDiv.textContent = '请���入有效的音量值';
return;
}
try {
const response = await fetch('/volume', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ volume: parseInt(volume) })
});
if (response.ok) {
statusDiv.className = 'success';
statusDiv.textContent = '音量设置成功';
} else {
statusDiv.className = 'error';
statusDiv.textContent = '音量设置失败';
}
} catch (error) {
console.error('Error:', error);
statusDiv.className = 'error';
statusDiv.textContent = '操作失败';
}
}
</script>
</body>
</html>