|
8 | 8 | max-width: 800px; |
9 | 9 | margin: 2rem auto; |
10 | 10 | padding: 0 1rem; |
11 | | - background-color: #121212; |
12 | | - color: white; |
| 11 | + background-color: #f5f5f5; |
13 | 12 | } |
14 | 13 | .credentials { |
15 | 14 | display: flex; |
|
20 | 19 | input { |
21 | 20 | padding: 0.5rem; |
22 | 21 | width: 100%; |
23 | | - background: #282828; |
24 | | - border: 1px solid #404040; |
25 | | - color: white; |
26 | | - border-radius: 4px; |
27 | 22 | } |
28 | 23 | .setup-button { |
29 | | - padding: 0.75rem 1.5rem; |
| 24 | + padding: 0.5rem 1rem; |
30 | 25 | 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; |
40 | 26 | } |
41 | 27 | .hidden { |
42 | 28 | display: none; |
|
48 | 34 | min-height: 80vh; |
49 | 35 | } |
50 | 36 | #pauseResumeButton { |
51 | | - width: 120px; |
52 | | - height: 120px; |
| 37 | + width: 80px; |
| 38 | + height: 80px; |
53 | 39 | border-radius: 50%; |
54 | 40 | border: none; |
55 | | - background: linear-gradient(145deg, #1DB954, #1ed760); |
| 41 | + background-color: #1DB954; |
56 | 42 | color: white; |
57 | | - font-size: 28px; |
| 43 | + font-size: 24px; |
58 | 44 | cursor: pointer; |
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; |
| 45 | + transition: transform 0.2s; |
64 | 46 | } |
65 | 47 | #pauseResumeButton:hover { |
66 | 48 | 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); |
71 | 49 | } |
72 | 50 | </style> |
73 | 51 | </head> |
|
137 | 115 | return hashParams; |
138 | 116 | } |
139 | 117 |
|
140 | | - async function playTrackById(trackId) { |
141 | | - const token = localStorage.getItem('spotify_access_token'); |
142 | | - try { |
143 | | - const response = await fetch('https://api.spotify.com/v1/me/player/play', { |
144 | | - method: 'PUT', |
145 | | - headers: { |
146 | | - 'Authorization': `Bearer ${token}`, |
147 | | - 'Content-Type': 'application/json' |
148 | | - }, |
149 | | - body: JSON.stringify({ |
150 | | - uris: [`spotify:track:${trackId}`] |
151 | | - }) |
152 | | - }); |
153 | | - if (response.status === 204) { |
154 | | - updatePauseResumeButton(true); |
155 | | - } |
156 | | - } catch (error) { |
157 | | - console.error('Error playing track:', error); |
158 | | - } |
159 | | - } |
160 | | - |
161 | 118 | function initializePlayer(token) { |
162 | 119 | document.getElementById('setup').classList.add('hidden'); |
163 | 120 | document.getElementById('player').classList.remove('hidden'); |
|
198 | 155 | }) |
199 | 156 | }); |
200 | 157 |
|
201 | | - // Auto-play the track if track ID is present in URL |
| 158 | + // Auto-play using button click |
202 | 159 | const trackId = getUrlParameter('track'); |
203 | 160 | if (trackId) { |
204 | 161 | setTimeout(() => { |
205 | | - playTrackById(trackId); |
206 | | - }, 1000); // Small delay to ensure device is ready |
| 162 | + pauseResumeButton.click(); |
| 163 | + }, 1000); |
207 | 164 | } |
208 | 165 | } catch (error) { |
209 | 166 | console.error('Error during player initialization:', error); |
|
0 commit comments