|
8 | 8 | max-width: 800px; |
9 | 9 | margin: 2rem auto; |
10 | 10 | padding: 0 1rem; |
| 11 | + background-color: #121212; |
| 12 | + color: white; |
11 | 13 | } |
12 | 14 | .credentials { |
13 | 15 | display: flex; |
|
18 | 20 | input { |
19 | 21 | padding: 0.5rem; |
20 | 22 | width: 100%; |
| 23 | + background: #282828; |
| 24 | + border: 1px solid #404040; |
| 25 | + color: white; |
| 26 | + border-radius: 4px; |
21 | 27 | } |
22 | 28 | .setup-button { |
23 | | - padding: 0.5rem 1rem; |
| 29 | + padding: 0.75rem 1.5rem; |
24 | 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; |
25 | 40 | } |
26 | 41 | .hidden { |
27 | 42 | display: none; |
|
32 | 47 | align-items: center; |
33 | 48 | min-height: 80vh; |
34 | 49 | } |
35 | | - #playPauseButton { |
36 | | - width: 100px; |
37 | | - height: 100px; |
| 50 | + #pauseResumeButton { |
| 51 | + width: 120px; |
| 52 | + height: 120px; |
38 | 53 | border-radius: 50%; |
39 | 54 | border: none; |
40 | | - background-color: #1DB954; |
| 55 | + background: linear-gradient(145deg, #1DB954, #1ed760); |
41 | 56 | color: white; |
42 | | - font-size: 24px; |
| 57 | + font-size: 28px; |
43 | 58 | cursor: pointer; |
44 | | - 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; |
| 64 | + } |
| 65 | + #pauseResumeButton:hover { |
| 66 | + transform: scale(1.05); |
| 67 | + box-shadow: 0 8px 16px rgba(29, 185, 84, 0.4); |
45 | 68 | } |
46 | | - #playPauseButton:hover { |
47 | | - transform: scale(1.1); |
| 69 | + #pauseResumeButton:active { |
| 70 | + transform: scale(0.95); |
48 | 71 | } |
49 | 72 | </style> |
50 | 73 | </head> |
|
54 | 77 | <button class="setup-button" onclick="startAuth()">Initialize Player</button> |
55 | 78 | </div> |
56 | 79 | <div id="player" class="hidden"> |
57 | | - <button id="playPauseButton">▶</button> |
| 80 | + <button id="pauseResumeButton">⏸️</button> |
58 | 81 | </div> |
59 | 82 |
|
60 | 83 | <script> |
61 | 84 | let playerInstance = null; |
62 | 85 | let isPlaying = false; |
63 | 86 | const redirectUri = 'http://gptgames.dev/tools/spotify_test.html'; |
64 | | - const playPauseButton = document.getElementById('playPauseButton'); |
| 87 | + const pauseResumeButton = document.getElementById('pauseResumeButton'); |
65 | 88 |
|
66 | | - function togglePlayPause() { |
| 89 | + function togglePauseResume() { |
67 | 90 | if (isPlaying) { |
68 | 91 | playerInstance.pause(); |
69 | 92 | } else { |
70 | | - const trackId = getUrlParameter('track'); |
71 | | - if (trackId) { |
72 | | - playTrackById(trackId); |
73 | | - } else { |
74 | | - playerInstance.resume(); |
75 | | - } |
| 93 | + playerInstance.resume(); |
76 | 94 | } |
77 | 95 | } |
78 | 96 |
|
79 | | - function updatePlayPauseButton(playing) { |
| 97 | + function updatePauseResumeButton(playing) { |
80 | 98 | isPlaying = playing; |
81 | | - playPauseButton.textContent = isPlaying ? '▐▐' : '▶'; |
| 99 | + pauseResumeButton.textContent = isPlaying ? '⏸️' : '▶️'; |
82 | 100 | } |
83 | 101 |
|
84 | 102 | function getUrlParameter(name) { |
|
133 | 151 | }) |
134 | 152 | }); |
135 | 153 | if (response.status === 204) { |
136 | | - updatePlayPauseButton(true); |
| 154 | + updatePauseResumeButton(true); |
137 | 155 | } |
138 | 156 | } catch (error) { |
139 | 157 | console.error('Error playing track:', error); |
|
162 | 180 |
|
163 | 181 | playerInstance.addListener('player_state_changed', state => { |
164 | 182 | if (state) { |
165 | | - updatePlayPauseButton(!state.paused); |
| 183 | + updatePauseResumeButton(!state.paused); |
166 | 184 | } |
167 | 185 | }); |
168 | 186 |
|
|
179 | 197 | play: false |
180 | 198 | }) |
181 | 199 | }); |
| 200 | + |
| 201 | + // Auto-play the track if track ID is present in URL |
| 202 | + const trackId = getUrlParameter('track'); |
| 203 | + if (trackId) { |
| 204 | + setTimeout(() => { |
| 205 | + playTrackById(trackId); |
| 206 | + }, 1000); // Small delay to ensure device is ready |
| 207 | + } |
182 | 208 | } catch (error) { |
183 | 209 | console.error('Error during player initialization:', error); |
184 | 210 | } |
185 | 211 | }); |
186 | 212 |
|
187 | | - playPauseButton.onclick = togglePlayPause; |
| 213 | + pauseResumeButton.onclick = togglePauseResume; |
188 | 214 | playerInstance.connect(); |
189 | 215 | } |
190 | 216 |
|
|
0 commit comments