File size: 3,518 Bytes
410048c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Mini Web Player</title>
    <style>
        body {
            background: #181818;
            color: #fff;
            font-family: 'Segoe UI', Arial, sans-serif;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
            margin: 0;
        }
        .player-container {
            background: #232323;
            border-radius: 16px;
            box-shadow: 0 4px 24px rgba(0,0,0,0.4);
            padding: 32px 24px 24px 24px;
            max-width: 350px;
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        .album-art {
            width: 180px;
            height: 180px;
            border-radius: 12px;
            background: #333;
            margin-bottom: 20px;
            object-fit: cover;
            box-shadow: 0 2px 12px rgba(0,0,0,0.3);
        }
        .song-title {
            font-size: 1.2em;
            font-weight: bold;
            margin-bottom: 6px;
            text-align: center;
        }
        .song-meta {
            font-size: 0.95em;
            color: #aaa;
            margin-bottom: 18px;
            text-align: center;
        }
        audio {
            width: 100%;
            margin-top: 10px;
        }
        .no-song {
            color: #ff7675;
            margin-top: 20px;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="player-container">
        <img id="album-art" class="album-art" src="" alt="Album Art" style="display:none;"/>
        <div id="song-title" class="song-title">Loading...</div>
        <div id="song-meta" class="song-meta"></div>
        <audio id="audio" controls autoplay>
            <source id="audio-src" src="/stream" type="audio/mpeg">
            Your browser does not support the audio element.
        </audio>
        <div id="no-song" class="no-song" style="display:none;">No song playing.</div>
    </div>
    <script>
    async function fetchSongInfo() {
        try {
            const res = await fetch('/current');
            if (!res.ok) throw new Error('No song');
            const data = await res.json();
            document.getElementById('no-song').style.display = 'none';
            document.getElementById('song-title').innerText = data.title || 'Unknown Title';
            document.getElementById('song-meta').innerText = (data.dur ? `Duration: ${data.dur}` : '') + (data.link ? ` | <a href='${data.link}' target='_blank' style='color:#1db954;'>Source</a>` : '');
            // Album art
            if (data.thumb || data.img) {
                document.getElementById('album-art').src = data.thumb || data.img;
                document.getElementById('album-art').style.display = 'block';
            } else {
                document.getElementById('album-art').style.display = 'none';
            }
        } catch (e) {
            document.getElementById('song-title').innerText = '';
            document.getElementById('song-meta').innerText = '';
            document.getElementById('album-art').style.display = 'none';
            document.getElementById('no-song').style.display = 'block';
        }
    }
    fetchSongInfo();
    setInterval(fetchSongInfo, 5000);
    </script>
</body>
</html>