OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 Polymer({ | 5 Polymer({ |
6 is: 'audio-player', | 6 is: 'audio-player', |
7 | 7 |
8 properties: { | 8 properties: { |
9 /** | 9 /** |
10 * Flag whether the audio is playing or paused. True if playing, or false | 10 * Flag whether the audio is playing or paused. True if playing, or false |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 | 50 |
51 /** | 51 /** |
52 * Whether the expanded button is ON. | 52 * Whether the expanded button is ON. |
53 */ | 53 */ |
54 expanded: { | 54 expanded: { |
55 type: Boolean, | 55 type: Boolean, |
56 observer: 'expandedChanged' | 56 observer: 'expandedChanged' |
57 }, | 57 }, |
58 | 58 |
59 /** | 59 /** |
60 * Whether the volume slider is shown. | |
61 */ | |
62 volumeSliderShown: { | |
63 type: Boolean, | |
64 observer: 'volumeSliderShownChanged' | |
65 }, | |
66 | |
67 /** | |
60 * Track index of the current track. | 68 * Track index of the current track. |
61 */ | 69 */ |
62 currentTrackIndex: { | 70 currentTrackIndex: { |
63 type: Number, | 71 type: Number, |
64 observer: 'currentTrackIndexChanged' | 72 observer: 'currentTrackIndexChanged' |
65 }, | 73 }, |
66 | 74 |
67 /** | 75 /** |
68 * Model object of the Audio Player. | 76 * Model object of the Audio Player. |
69 * @type {AudioPlayerModel} | 77 * @type {AudioPlayerModel} |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 | 136 |
129 /** | 137 /** |
130 * Handles change event for expanded state of track list. | 138 * Handles change event for expanded state of track list. |
131 */ | 139 */ |
132 expandedChanged: function(expanded) { | 140 expandedChanged: function(expanded) { |
133 if (this.model) | 141 if (this.model) |
134 this.model.expanded = expanded; | 142 this.model.expanded = expanded; |
135 }, | 143 }, |
136 | 144 |
137 /** | 145 /** |
146 * Handles change event for volumeSliderShown state. | |
147 */ | |
148 volumeSliderShownChanged: function(volumeSliderShown) { | |
149 if (this.model) | |
150 this.model.volumeSliderShown = volumeSliderShown; | |
151 }, | |
152 | |
153 /** | |
138 * Initializes an element. This method is called automatically when the | 154 * Initializes an element. This method is called automatically when the |
139 * element is ready. | 155 * element is ready. |
140 */ | 156 */ |
141 ready: function() { | 157 ready: function() { |
142 this.addEventListener('keydown', this.onKeyDown_.bind(this)); | 158 this.addEventListener('keydown', this.onKeyDown_.bind(this)); |
143 | 159 |
144 this.$.audioController.addEventListener('dragging-changed', | 160 this.$.audioController.addEventListener('dragging-changed', |
145 this.onDraggingChanged_.bind(this)); | 161 this.onDraggingChanged_.bind(this)); |
146 | 162 |
147 this.$.audio.volume = 0; // Temporary initial volume. | 163 this.$.audio.volume = 0; // Temporary initial volume. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 * Invoked when the model changed. | 230 * Invoked when the model changed. |
215 * @param {AudioPlayerModel} newModel New model. | 231 * @param {AudioPlayerModel} newModel New model. |
216 * @param {AudioPlayerModel} oldModel Old model. | 232 * @param {AudioPlayerModel} oldModel Old model. |
217 */ | 233 */ |
218 modelChanged: function(newModel, oldModel) { | 234 modelChanged: function(newModel, oldModel) { |
219 // Setting up the UI | 235 // Setting up the UI |
220 if (newModel !== oldModel && newModel) { | 236 if (newModel !== oldModel && newModel) { |
221 this.shuffle = newModel.shuffle; | 237 this.shuffle = newModel.shuffle; |
222 this.repeat = newModel.repeat; | 238 this.repeat = newModel.repeat; |
223 this.volume = newModel.volume; | 239 this.volume = newModel.volume; |
224 this.expanded = newModel.expanded; | 240 this.expanded = newModel.expanded; |
yawano
2015/10/30 08:28:25
You need to set volumeSliderShown here.
fukino
2015/10/30 09:05:25
Oops, thanks! Done.
| |
225 } | 241 } |
226 }, | 242 }, |
227 | 243 |
228 /** | 244 /** |
229 * Invoked when time is changed. | 245 * Invoked when time is changed. |
230 * @param {number} newValue new time (in ms). | 246 * @param {number} newValue new time (in ms). |
231 * @param {number} oldValue old time (in ms). | 247 * @param {number} oldValue old time (in ms). |
232 */ | 248 */ |
233 timeChanged: function(newValue, oldValue) { | 249 timeChanged: function(newValue, oldValue) { |
234 // Ignores updates from the audio element. | 250 // Ignores updates from the audio element. |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
461 | 477 |
462 /** | 478 /** |
463 * Computes volume value for audio element. (should be in [0.0, 1.0]) | 479 * Computes volume value for audio element. (should be in [0.0, 1.0]) |
464 * @param {number} volume Volume which is set in the UI. ([0, 100]) | 480 * @param {number} volume Volume which is set in the UI. ([0, 100]) |
465 * @return {number} | 481 * @return {number} |
466 */ | 482 */ |
467 computeAudioVolume_: function(volume) { | 483 computeAudioVolume_: function(volume) { |
468 return volume / 100; | 484 return volume / 100; |
469 } | 485 } |
470 }); | 486 }); |
OLD | NEW |