|
8 | 8 | max-width: 800px; |
9 | 9 | margin: 2rem auto; |
10 | 10 | padding: 0 1rem; |
11 | | - background-color: #f5f5f5; |
| 11 | + background-color: #121212; |
| 12 | + color: white; |
12 | 13 | } |
13 | 14 | .credentials { |
14 | 15 | display: flex; |
|
19 | 20 | input { |
20 | 21 | padding: 0.5rem; |
21 | 22 | width: 100%; |
| 23 | + background: #282828; |
| 24 | + border: 1px solid #404040; |
| 25 | + color: white; |
| 26 | + border-radius: 4px; |
22 | 27 | } |
23 | 28 | .setup-button { |
24 | | - padding: 0.5rem 1rem; |
| 29 | + padding: 0.75rem 1.5rem; |
25 | 30 | cursor: pointer; |
| 31 | + background: #1DB954; |
| 32 | + border: none; |
| 33 | + color: white; |
| 34 | + border-radius: 4px; |
| 35 | + font-weight: bold; |
| 36 | + transition: background-color 0.2s; |
| 37 | + } |
| 38 | + .setup-button:hover { |
| 39 | + background: #1ed760; |
26 | 40 | } |
27 | 41 | .hidden { |
28 | 42 | display: none; |
|
34 | 48 | min-height: 80vh; |
35 | 49 | } |
36 | 50 | #pauseResumeButton { |
37 | | - width: 80px; |
38 | | - height: 80px; |
| 51 | + width: 120px; |
| 52 | + height: 120px; |
39 | 53 | border-radius: 50%; |
40 | 54 | border: none; |
41 | | - background-color: #1DB954; |
| 55 | + background: linear-gradient(145deg, #1DB954, #1ed760); |
42 | 56 | color: white; |
43 | | - font-size: 24px; |
| 57 | + font-size: 28px; |
44 | 58 | cursor: pointer; |
45 | | - transition: transform 0.2s; |
| 59 | + transition: all 0.3s ease; |
| 60 | + box-shadow: 0 6px 12px rgba(29, 185, 84, 0.3); |
| 61 | + display: flex; |
| 62 | + align-items: center; |
| 63 | + justify-content: center; |
46 | 64 | } |
47 | 65 | #pauseResumeButton:hover { |
48 | 66 | transform: scale(1.05); |
| 67 | + box-shadow: 0 8px 16px rgba(29, 185, 84, 0.4); |
| 68 | + } |
| 69 | + #pauseResumeButton:active { |
| 70 | + transform: scale(0.95); |
49 | 71 | } |
50 | 72 | </style> |
51 | 73 | </head> |
|
155 | 177 | }) |
156 | 178 | }); |
157 | 179 |
|
158 | | - // Auto-play using button click |
| 180 | + // If there's a track ID in the URL |
159 | 181 | const trackId = getUrlParameter('track'); |
160 | 182 | if (trackId) { |
161 | | - setTimeout(() => { |
162 | | - pauseResumeButton.click(); |
163 | | - }, 5000); |
| 183 | + // First select the track via API |
| 184 | + try { |
| 185 | + await fetch('https://api.spotify.com/v1/me/player/play', { |
| 186 | + method: 'PUT', |
| 187 | + headers: { |
| 188 | + 'Authorization': `Bearer ${token}`, |
| 189 | + 'Content-Type': 'application/json' |
| 190 | + }, |
| 191 | + body: JSON.stringify({ |
| 192 | + uris: [`spotify:track:${trackId}`] |
| 193 | + }) |
| 194 | + }); |
| 195 | + |
| 196 | + // Then trigger the play button after 4 seconds |
| 197 | + setTimeout(() => { |
| 198 | + pauseResumeButton.click(); |
| 199 | + }, 4000); |
| 200 | + } catch (error) { |
| 201 | + console.error('Error playing track:', error); |
| 202 | + } |
164 | 203 | } |
165 | 204 | } catch (error) { |
166 | 205 | console.error('Error during player initialization:', error); |
|
0 commit comments