OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * @param {HTMLElement} container Container element. | 8 * @param {HTMLElement} container Container element. |
9 * @constructor | 9 * @constructor |
10 */ | 10 */ |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 if (this.player_) | 191 if (this.player_) |
192 this.player_.onPageUnload(); | 192 this.player_.onPageUnload(); |
193 | 193 |
194 if (this.volumeManager_) | 194 if (this.volumeManager_) |
195 this.volumeManager_.dispose(); | 195 this.volumeManager_.dispose(); |
196 }; | 196 }; |
197 | 197 |
198 /** | 198 /** |
199 * Selects a new track to play. | 199 * Selects a new track to play. |
200 * @param {number} newTrack New track number. | 200 * @param {number} newTrack New track number. |
| 201 * @param {number} time New playback position (in second). |
201 * @private | 202 * @private |
202 */ | 203 */ |
203 AudioPlayer.prototype.select_ = function(newTrack) { | 204 AudioPlayer.prototype.select_ = function(newTrack, time) { |
204 if (this.currentTrackIndex_ == newTrack) return; | 205 if (this.currentTrackIndex_ == newTrack) return; |
205 | 206 |
206 this.currentTrackIndex_ = newTrack; | 207 this.currentTrackIndex_ = newTrack; |
207 this.player_.currentTrackIndex = this.currentTrackIndex_; | 208 this.player_.currentTrackIndex = this.currentTrackIndex_; |
| 209 this.player_.audioController.time = time; |
208 Platform.performMicrotaskCheckpoint(); | 210 Platform.performMicrotaskCheckpoint(); |
209 | 211 |
210 if (!window.appReopen) | 212 if (!window.appReopen) |
211 this.player_.audioElement.play(); | 213 this.player_.audioElement.play(); |
212 | 214 |
213 window.appState.position = this.currentTrackIndex_; | 215 window.appState.position = this.currentTrackIndex_; |
214 window.appState.time = 0; | 216 window.appState.time = 0; |
215 util.saveAppState(); | 217 util.saveAppState(); |
216 | 218 |
217 var entry = this.entries_[this.currentTrackIndex_]; | 219 var entry = this.entries_[this.currentTrackIndex_]; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 this.title = (metadata.media && metadata.media.title) || | 420 this.title = (metadata.media && metadata.media.title) || |
419 this.getDefaultTitle(); | 421 this.getDefaultTitle(); |
420 this.artist = error || | 422 this.artist = error || |
421 (metadata.media && metadata.media.artist) || this.getDefaultArtist(); | 423 (metadata.media && metadata.media.artist) || this.getDefaultArtist(); |
422 }; | 424 }; |
423 | 425 |
424 // Starts loading the audio player. | 426 // Starts loading the audio player. |
425 window.addEventListener('polymer-ready', function(e) { | 427 window.addEventListener('polymer-ready', function(e) { |
426 AudioPlayer.load(); | 428 AudioPlayer.load(); |
427 }); | 429 }); |
OLD | NEW |