173 // auto-refresh on track advance |
173 // auto-refresh on track advance |
174 if ( ct_advance_timeout ) |
174 if ( ct_advance_timeout ) |
175 { |
175 { |
176 clearTimeout(ct_advance_timeout); |
176 clearTimeout(ct_advance_timeout); |
177 } |
177 } |
|
178 // countdown/up timer |
178 var time_remaining = response.current_track_length - response.current_track_pos; |
179 var time_remaining = response.current_track_length - response.current_track_pos; |
179 current_track_length = response.current_track_length; |
180 current_track_length = response.current_track_length; |
180 current_track_pos = response.current_track_pos; |
181 current_track_pos = response.current_track_pos; |
181 if ( ct_counter ) |
182 if ( ct_counter ) |
182 clearInterval(ct_counter); |
183 clearInterval(ct_counter); |
183 update_clock(); |
184 update_clock(); |
|
185 |
|
186 // set page title |
|
187 updateTitle(response.current_track_artist, response.current_track_album, response.current_track_title); |
|
188 |
|
189 // if not playing, set the position slider to zero |
|
190 if ( !is_playing ) |
|
191 { |
|
192 posslide_set_position(0); |
|
193 } |
|
194 |
|
195 // set advance timer |
184 if ( is_playing && time_remaining > 0 ) |
196 if ( is_playing && time_remaining > 0 ) |
185 { |
197 { |
186 ct_advance_timeout = setTimeout(refresh_playlist, ( 1000 * time_remaining )); |
198 ct_advance_timeout = setTimeout(refresh_playlist, ( 1000 * time_remaining )); |
187 ct_counter = setInterval(update_clock, 1000); |
199 ct_counter = setInterval(update_clock, 1000); |
188 } |
200 } |
257 { |
269 { |
258 ct_advance_timeout = setTimeout(refresh_playlist, ( 1000 * time_remaining )); |
270 ct_advance_timeout = setTimeout(refresh_playlist, ( 1000 * time_remaining )); |
259 update_clock(); |
271 update_clock(); |
260 ct_counter = setInterval(update_clock, 1000); |
272 ct_counter = setInterval(update_clock, 1000); |
261 } |
273 } |
|
274 updateTitle(response.current_track_artist, response.current_track_album, response.current_track_title); |
262 } |
275 } |
263 }); |
276 }); |
264 } |
277 } |
265 |
278 |
266 function set_playback_position(pos) |
279 function set_playback_position(pos) |