| 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 /** | 5 /** |
| 6 * @fileoverview MediaControls class implements media playback controls | 6 * @fileoverview MediaControls class implements media playback controls |
| 7 * that exist outside of the audio/video HTML element. | 7 * that exist outside of the audio/video HTML element. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 * This is the right moment to save the play state. | 482 * This is the right moment to save the play state. |
| 483 */ | 483 */ |
| 484 MediaControls.prototype.onPlayStateChanged = function() {}; | 484 MediaControls.prototype.onPlayStateChanged = function() {}; |
| 485 | 485 |
| 486 /** | 486 /** |
| 487 * Updates the play button state. | 487 * Updates the play button state. |
| 488 * @param {boolean} playing If the video is playing. | 488 * @param {boolean} playing If the video is playing. |
| 489 * @private | 489 * @private |
| 490 */ | 490 */ |
| 491 MediaControls.prototype.updatePlayButtonState_ = function(playing) { | 491 MediaControls.prototype.updatePlayButtonState_ = function(playing) { |
| 492 if (playing) { | 492 if (this.media_.ended && this.progressSlider_.isAtEnd()) { |
| 493 this.playButton_.setAttribute('state', |
| 494 MediaControls.ButtonStateType.ENDED); |
| 495 } else if (playing) { |
| 493 this.playButton_.setAttribute('state', | 496 this.playButton_.setAttribute('state', |
| 494 MediaControls.ButtonStateType.PLAYING); | 497 MediaControls.ButtonStateType.PLAYING); |
| 495 } else if (!this.media_.ended) { | 498 } else { |
| 496 this.playButton_.setAttribute('state', | 499 this.playButton_.setAttribute('state', |
| 497 MediaControls.ButtonStateType.DEFAULT); | 500 MediaControls.ButtonStateType.DEFAULT); |
| 498 } else { | |
| 499 this.playButton_.setAttribute('state', | |
| 500 MediaControls.ButtonStateType.ENDED); | |
| 501 } | 501 } |
| 502 }; | 502 }; |
| 503 | 503 |
| 504 /** | 504 /** |
| 505 * Restore play state. Base implementation is empty. | 505 * Restore play state. Base implementation is empty. |
| 506 */ | 506 */ |
| 507 MediaControls.prototype.restorePlayState = function() {}; | 507 MediaControls.prototype.restorePlayState = function() {}; |
| 508 | 508 |
| 509 /** | 509 /** |
| 510 * Encode current state into the page URL or the app state. | 510 * Encode current state into the page URL or the app state. |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 * Mousedown/mouseup handler. | 701 * Mousedown/mouseup handler. |
| 702 * @param {boolean} on True if the mouse is down. | 702 * @param {boolean} on True if the mouse is down. |
| 703 * @private | 703 * @private |
| 704 */ | 704 */ |
| 705 MediaControls.Slider.prototype.onInputDrag_ = function(on) { | 705 MediaControls.Slider.prototype.onInputDrag_ = function(on) { |
| 706 this.isDragging_ = on; | 706 this.isDragging_ = on; |
| 707 this.onDrag_(on); | 707 this.onDrag_(on); |
| 708 }; | 708 }; |
| 709 | 709 |
| 710 /** | 710 /** |
| 711 * Check if the slider position is at the end of the control. |
| 712 * @return {boolean} True if the slider position is at the end. |
| 713 */ |
| 714 MediaControls.Slider.prototype.isAtEnd = function() { |
| 715 return this.input_.value === this.input_.max; |
| 716 }; |
| 717 |
| 718 /** |
| 711 * Create a customized slider with animated thumb movement. | 719 * Create a customized slider with animated thumb movement. |
| 712 * | 720 * |
| 713 * @param {HTMLElement} container The containing div element. | 721 * @param {HTMLElement} container The containing div element. |
| 714 * @param {number} value Initial value [0..1]. | 722 * @param {number} value Initial value [0..1]. |
| 715 * @param {number} range Number of distinct slider positions to be supported. | 723 * @param {number} range Number of distinct slider positions to be supported. |
| 716 * @param {function(number)} onChange Value change handler. | 724 * @param {function(number)} onChange Value change handler. |
| 717 * @param {function(boolean)} onDrag Drag begin/end handler. | 725 * @param {function(boolean)} onDrag Drag begin/end handler. |
| 718 * @param {function(number):string} formatFunction Value formatting function. | 726 * @param {function(number):string} formatFunction Value formatting function. |
| 719 * @constructor | 727 * @constructor |
| 720 */ | 728 */ |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 AudioControls.prototype.onAdvanceClick_ = function(forward) { | 1265 AudioControls.prototype.onAdvanceClick_ = function(forward) { |
| 1258 if (!forward && | 1266 if (!forward && |
| 1259 (this.getMedia().currentTime > AudioControls.TRACK_RESTART_THRESHOLD)) { | 1267 (this.getMedia().currentTime > AudioControls.TRACK_RESTART_THRESHOLD)) { |
| 1260 // We are far enough from the beginning of the current track. | 1268 // We are far enough from the beginning of the current track. |
| 1261 // Restart it instead of than skipping to the previous one. | 1269 // Restart it instead of than skipping to the previous one. |
| 1262 this.getMedia().currentTime = 0; | 1270 this.getMedia().currentTime = 0; |
| 1263 } else { | 1271 } else { |
| 1264 this.advanceTrack_(forward); | 1272 this.advanceTrack_(forward); |
| 1265 } | 1273 } |
| 1266 }; | 1274 }; |
| OLD | NEW |