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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * Interval for updating media info (in ms). | 8 * Interval for updating media info (in ms). |
9 * @type {number} | 9 * @type {number} |
10 * @const | 10 * @const |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 217 |
218 /** | 218 /** |
219 * Plays the video. | 219 * Plays the video. |
220 * @param {boolean=} opt_seeking True when seeking. False otherwise. | 220 * @param {boolean=} opt_seeking True when seeking. False otherwise. |
221 */ | 221 */ |
222 play: function(opt_seeking) { | 222 play: function(opt_seeking) { |
223 if (this.playInProgress_) | 223 if (this.playInProgress_) |
224 return; | 224 return; |
225 | 225 |
226 var play = function() { | 226 var play = function() { |
| 227 // If the casted media is already playing and a pause request is not in |
| 228 // progress, we can skip this play request. |
227 if (this.castMedia_.playerState === | 229 if (this.castMedia_.playerState === |
228 chrome.cast.media.PlayerState.PLAYING) { | 230 chrome.cast.media.PlayerState.PLAYING && |
| 231 !this.pauseInProgress_) { |
| 232 this.playInProgress_ = false; |
229 return; | 233 return; |
230 } | 234 } |
231 | 235 |
232 var playRequest = new chrome.cast.media.PlayRequest(); | 236 var playRequest = new chrome.cast.media.PlayRequest(); |
233 playRequest.customData = {seeking: !!opt_seeking}; | 237 playRequest.customData = {seeking: !!opt_seeking}; |
234 | 238 |
235 this.castMedia_.play( | 239 this.castMedia_.play( |
236 playRequest, | 240 playRequest, |
237 function() { | 241 function() { |
238 this.playInProgress_ = false; | 242 this.playInProgress_ = false; |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 this.dispatchEvent(new Event('durationchange')); | 492 this.dispatchEvent(new Event('durationchange')); |
489 } | 493 } |
490 | 494 |
491 // Media is being unloaded. | 495 // Media is being unloaded. |
492 if (!alive) { | 496 if (!alive) { |
493 this.unloadMedia_(); | 497 this.unloadMedia_(); |
494 return; | 498 return; |
495 } | 499 } |
496 }, | 500 }, |
497 }; | 501 }; |
OLD | NEW |