-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
80 lines (70 loc) · 2 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Currently Playing on Spotify</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #121212;
color: #FFFFFF;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
}
h1 {
color: #1DB954;
font-size: 2.5rem;
margin-bottom: 20px;
}
#songInfo {
margin-top: 20px;
text-align: center;
font-size: 1.2rem;
}
iframe {
border: none;
margin-top: 20px;
width: 100%;
max-width: 500px;
height: 380px;
/* Adjust the height to make sure it's enough to show the full player */
}
.container {
text-align: center;
padding: 20px;
border-radius: 10px;
background-color: #282828;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
</style>
<meta http-equiv="Content-Security-Policy" content="frame-ancestors 'self' https://open.spotify.com;">
</head>
<body>
<div class="container">
<h1>Currently Playing on Spotify</h1>
<div id="songInfo">Loading...</div>
</div>
<script>
async function fetchCurrentSong() {
const response = await fetch('http://localhost:8888/current');
const data = await response.json();
const songInfo = document.getElementById('songInfo');
if (data.song) {
songInfo.innerHTML = `
<p>Currently playing: <strong>${data.song}</strong> by <strong>${data.artist}</strong></p>
<iframe src="https://open.spotify.com/embed/track/${data.track_id}" allowtransparency="true" allow="encrypted-media"></iframe>
`;
} else {
songInfo.innerHTML = '<p>No track currently playing.</p>';
}
}
fetchCurrentSong();
setInterval(fetchCurrentSong, 30000); // Refresh every 30 seconds
</script>
</body>
</html>