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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 return; | 114 return; |
115 | 115 |
116 this.trackListItems_.splice(0); | 116 this.trackListItems_.splice(0); |
117 | 117 |
118 for (var i = 0; i != this.entries_.length; i++) { | 118 for (var i = 0; i != this.entries_.length; i++) { |
119 var entry = this.entries_[i]; | 119 var entry = this.entries_[i]; |
120 var onClick = this.select_.bind(this, i, false /* no restore */); | 120 var onClick = this.select_.bind(this, i, false /* no restore */); |
121 this.trackListItems_.push(new AudioPlayer.TrackInfo(entry, onClick)); | 121 this.trackListItems_.push(new AudioPlayer.TrackInfo(entry, onClick)); |
122 } | 122 } |
123 | 123 |
| 124 // Makes it sure that the handler of the track list is called, before the |
| 125 // handler of the track index. |
| 126 Platform.performMicrotaskCheckpoint(); |
| 127 |
124 this.select_(position, !!time); | 128 this.select_(position, !!time); |
125 | 129 |
126 // Load the selected track metadata first, then load the rest. | 130 // Load the selected track metadata first, then load the rest. |
127 this.loadMetadata_(position); | 131 this.loadMetadata_(position); |
128 for (i = 0; i != this.entries_.length; i++) { | 132 for (i = 0; i != this.entries_.length; i++) { |
129 if (i != position) | 133 if (i != position) |
130 this.loadMetadata_(i); | 134 this.loadMetadata_(i); |
131 } | 135 } |
132 }.bind(this)); | 136 }.bind(this)); |
133 }.bind(this)); | 137 }.bind(this)); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 this.title = (metadata.media && metadata.media.title) || | 404 this.title = (metadata.media && metadata.media.title) || |
401 this.getDefaultTitle(); | 405 this.getDefaultTitle(); |
402 this.artist = error || | 406 this.artist = error || |
403 (metadata.media && metadata.media.artist) || this.getDefaultArtist(); | 407 (metadata.media && metadata.media.artist) || this.getDefaultArtist(); |
404 }; | 408 }; |
405 | 409 |
406 // Starts loading the audio player. | 410 // Starts loading the audio player. |
407 window.addEventListener('WebComponentsReady', function(e) { | 411 window.addEventListener('WebComponentsReady', function(e) { |
408 AudioPlayer.load(); | 412 AudioPlayer.load(); |
409 }); | 413 }); |
OLD | NEW |