| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 /** | 5 /** |
| 6 * This Polymer element shows media controls for a route that is currently cast | 6 * This Polymer element shows media controls for a route that is currently cast |
| 7 * to a device. | 7 * to a device. |
| 8 * @implements {RouteControlsInterface} | 8 * @implements {RouteControlsInterface} |
| 9 */ | 9 */ |
| 10 Polymer({ | 10 Polymer({ |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 /** | 33 /** |
| 34 * The volume shown in the volume control, between 0 and 1. | 34 * The volume shown in the volume control, between 0 and 1. |
| 35 * @private {number} | 35 * @private {number} |
| 36 */ | 36 */ |
| 37 displayedVolume_: { | 37 displayedVolume_: { |
| 38 type: Number, | 38 type: Number, |
| 39 value: 0, | 39 value: 0, |
| 40 }, | 40 }, |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * The timestamp for when the initial media status was loaded. |
| 44 * @private {number} |
| 45 */ |
| 46 initialLoadTime_: { |
| 47 type: Number, |
| 48 value: 0, |
| 49 }, |
| 50 |
| 51 /** |
| 43 * Set to true when the user is dragging the seek bar. Updates for the | 52 * Set to true when the user is dragging the seek bar. Updates for the |
| 44 * current time from the browser will be ignored when set to true. | 53 * current time from the browser will be ignored when set to true. |
| 45 * @private {boolean} | 54 * @private {boolean} |
| 46 */ | 55 */ |
| 47 isSeeking_: { | 56 isSeeking_: { |
| 48 type: Boolean, | 57 type: Boolean, |
| 49 value: false, | 58 value: false, |
| 50 }, | 59 }, |
| 51 | 60 |
| 52 /** | 61 /** |
| 53 * Set to true when the user is dragging the volume bar. Volume updates from | 62 * Set to true when the user is dragging the volume bar. Volume updates from |
| 54 * the browser will be ignored when set to true. | 63 * the browser will be ignored when set to true. |
| 55 * @private {boolean} | 64 * @private {boolean} |
| 56 */ | 65 */ |
| 57 isVolumeChanging_: { | 66 isVolumeChanging_: { |
| 58 type: Boolean, | 67 type: Boolean, |
| 59 value: false, | 68 value: false, |
| 60 }, | 69 }, |
| 61 | 70 |
| 62 /** | 71 /** |
| 72 * The timestamp for when the route details view was opened. |
| 73 * @type {number} |
| 74 */ |
| 75 routeDetailsOpenTime: { |
| 76 type: Number, |
| 77 value: 0, |
| 78 }, |
| 79 |
| 80 /** |
| 63 * The status of the media route shown. | 81 * The status of the media route shown. |
| 64 * @type {!media_router.RouteStatus} | 82 * @type {!media_router.RouteStatus} |
| 65 */ | 83 */ |
| 66 routeStatus: { | 84 routeStatus: { |
| 67 type: Object, | 85 type: Object, |
| 68 observer: 'onRouteStatusChange_', | 86 observer: 'onRouteStatusChange_', |
| 69 value: new media_router.RouteStatus( | 87 value: new media_router.RouteStatus( |
| 70 '', '', false, false, false, false, false, false, 0, 0, 0), | 88 '', '', false, false, false, false, false, false, 0, 0, 0), |
| 71 }, | 89 }, |
| 72 }, | 90 }, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 */ | 183 */ |
| 166 onPlayPause_: function() { | 184 onPlayPause_: function() { |
| 167 if (this.routeStatus.isPaused) { | 185 if (this.routeStatus.isPaused) { |
| 168 media_router.browserApi.playCurrentMedia(); | 186 media_router.browserApi.playCurrentMedia(); |
| 169 } else { | 187 } else { |
| 170 media_router.browserApi.pauseCurrentMedia(); | 188 media_router.browserApi.pauseCurrentMedia(); |
| 171 } | 189 } |
| 172 }, | 190 }, |
| 173 | 191 |
| 174 /** | 192 /** |
| 175 * Resets the route controls. Called when the route details view is closed. | |
| 176 */ | |
| 177 reset: function() { | |
| 178 this.routeStatus = new media_router.RouteStatus( | |
| 179 '', '', false, false, false, false, false, false, 0, 0, 0); | |
| 180 media_router.ui.setRouteControls(null); | |
| 181 }, | |
| 182 | |
| 183 /** | |
| 184 * Updates seek and volume bars if the user is not currently dragging on | 193 * Updates seek and volume bars if the user is not currently dragging on |
| 185 * them. | 194 * them. |
| 186 * @param {!media_router.RouteStatus} newRouteStatus | 195 * @param {!media_router.RouteStatus} newRouteStatus |
| 187 * | 196 * |
| 188 * @private | 197 * @private |
| 189 */ | 198 */ |
| 190 onRouteStatusChange_: function(newRouteStatus) { | 199 onRouteStatusChange_: function(newRouteStatus) { |
| 191 if (!this.isSeeking_) { | 200 if (!this.isSeeking_) { |
| 192 this.displayedCurrentTime_ = newRouteStatus.currentTime; | 201 this.displayedCurrentTime_ = newRouteStatus.currentTime; |
| 193 } | 202 } |
| 194 if (!this.isVolumeChanging_) { | 203 if (!this.isVolumeChanging_) { |
| 195 this.displayedVolume_ = newRouteStatus.volume; | 204 this.displayedVolume_ = newRouteStatus.volume; |
| 196 } | 205 } |
| 197 if (newRouteStatus.description !== '') { | 206 if (newRouteStatus.description !== '') { |
| 198 this.displayedDescription_ = newRouteStatus.description; | 207 this.displayedDescription_ = newRouteStatus.description; |
| 199 } | 208 } |
| 209 if (!this.initialLoadTime_) { |
| 210 this.initialLoadTime_ = Date.now(); |
| 211 media_router.browserApi.reportWebUIRouteControllerLoaded( |
| 212 this.initialLoadTime_ - this.routeDetailsOpenTime); |
| 213 } |
| 200 }, | 214 }, |
| 201 | 215 |
| 202 /** | 216 /** |
| 203 * Called when the route is updated. Updates the description shown if it has | 217 * Called when the route is updated. Updates the description shown if it has |
| 204 * not been provided by status updates. | 218 * not been provided by status updates. |
| 205 * @param {!media_router.Route} route | 219 * @param {!media_router.Route} route |
| 206 */ | 220 */ |
| 207 onRouteUpdated: function(route) { | 221 onRouteUpdated: function(route) { |
| 208 if (this.routeStatus.description === '') { | 222 if (this.routeStatus.description === '') { |
| 209 this.displayedDescription_ = | 223 this.displayedDescription_ = |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 * Called when the user starts dragging the volume bar. | 265 * Called when the user starts dragging the volume bar. |
| 252 * @param {!Event} e | 266 * @param {!Event} e |
| 253 * | 267 * |
| 254 * @private | 268 * @private |
| 255 */ | 269 */ |
| 256 onVolumeChangeStart_: function(e) { | 270 onVolumeChangeStart_: function(e) { |
| 257 this.isVolumeChanging_ = true; | 271 this.isVolumeChanging_ = true; |
| 258 var target = /** @type {{immediateValue: number}} */ (e.target); | 272 var target = /** @type {{immediateValue: number}} */ (e.target); |
| 259 this.volumeSliderValue_ = target.immediateValue; | 273 this.volumeSliderValue_ = target.immediateValue; |
| 260 }, | 274 }, |
| 275 |
| 276 /** |
| 277 * Resets the route controls. Called when the route details view is closed. |
| 278 */ |
| 279 reset: function() { |
| 280 this.routeStatus = new media_router.RouteStatus( |
| 281 '', '', false, false, false, false, false, false, 0, 0, 0); |
| 282 media_router.ui.setRouteControls(null); |
| 283 }, |
| 261 }); | 284 }); |
| OLD | NEW |