| 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 * @fileoverview MediaControls class implements media playback controls | 8 * @fileoverview MediaControls class implements media playback controls |
| 9 * that exist outside of the audio/video HTML element. | 9 * that exist outside of the audio/video HTML element. |
| 10 */ | 10 */ |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 * @param {number} value [0..1]. | 739 * @param {number} value [0..1]. |
| 740 * @private | 740 * @private |
| 741 */ | 741 */ |
| 742 MediaControls.AnimatedSlider.prototype.setValueToUI_ = function(value) { | 742 MediaControls.AnimatedSlider.prototype.setValueToUI_ = function(value) { |
| 743 if (this.animationInterval_) { | 743 if (this.animationInterval_) { |
| 744 clearInterval(this.animationInterval_); | 744 clearInterval(this.animationInterval_); |
| 745 } | 745 } |
| 746 var oldValue = this.getValueFromUI_(); | 746 var oldValue = this.getValueFromUI_(); |
| 747 var step = 0; | 747 var step = 0; |
| 748 this.animationInterval_ = setInterval(function() { | 748 this.animationInterval_ = setInterval(function() { |
| 749 step++; | 749 step++; |
| 750 var currentValue = oldValue + | 750 var currentValue = oldValue + |
| 751 (value - oldValue) * (step / MediaControls.AnimatedSlider.STEPS); | 751 (value - oldValue) * (step / MediaControls.AnimatedSlider.STEPS); |
| 752 MediaControls.Slider.prototype.setValueToUI_.call(this, currentValue); | 752 MediaControls.Slider.prototype.setValueToUI_.call(this, currentValue); |
| 753 if (step == MediaControls.AnimatedSlider.STEPS) { | 753 if (step == MediaControls.AnimatedSlider.STEPS) { |
| 754 clearInterval(this.animationInterval_); | 754 clearInterval(this.animationInterval_); |
| 755 } | 755 } |
| 756 }.bind(this), | 756 }.bind(this), |
| 757 MediaControls.AnimatedSlider.DURATION / MediaControls.AnimatedSlider.STEPS); | 757 MediaControls.AnimatedSlider.DURATION / MediaControls.AnimatedSlider.STEPS); |
| 758 }; | 758 }; |
| 759 | 759 |
| 760 /** | 760 /** |
| 761 * Create a customized slider with a precise time feedback. | 761 * Create a customized slider with a precise time feedback. |
| 762 * | 762 * |
| 763 * The time value is shown above the slider bar at the mouse position. | 763 * The time value is shown above the slider bar at the mouse position. |
| 764 * | 764 * |
| 765 * @param {HTMLElement} container The containing div element. | 765 * @param {HTMLElement} container The containing div element. |
| 766 * @param {number} value Initial value [0..1]. | 766 * @param {number} value Initial value [0..1]. |
| 767 * @param {number} range Number of distinct slider positions to be supported. | 767 * @param {number} range Number of distinct slider positions to be supported. |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 * @param {HTMLElement} containerElement The container for the controls. | 956 * @param {HTMLElement} containerElement The container for the controls. |
| 957 * @param {function} onMediaError Function to display an error message. | 957 * @param {function} onMediaError Function to display an error message. |
| 958 * @param {function(string):string} stringFunction Function providing localized | 958 * @param {function(string):string} stringFunction Function providing localized |
| 959 * strings. | 959 * strings. |
| 960 * @param {function=} opt_fullScreenToggle Function to toggle fullscreen mode. | 960 * @param {function=} opt_fullScreenToggle Function to toggle fullscreen mode. |
| 961 * @param {HTMLElement=} opt_stateIconParent The parent for the icon that | 961 * @param {HTMLElement=} opt_stateIconParent The parent for the icon that |
| 962 * gives visual feedback when the playback state changes. | 962 * gives visual feedback when the playback state changes. |
| 963 * @constructor | 963 * @constructor |
| 964 */ | 964 */ |
| 965 function VideoControls(containerElement, onMediaError, stringFunction, | 965 function VideoControls(containerElement, onMediaError, stringFunction, |
| 966 opt_fullScreenToggle, opt_stateIconParent) { | 966 opt_fullScreenToggle, opt_stateIconParent) { |
| 967 MediaControls.call(this, containerElement, onMediaError); | 967 MediaControls.call(this, containerElement, onMediaError); |
| 968 this.stringFunction_ = stringFunction; | 968 this.stringFunction_ = stringFunction; |
| 969 | 969 |
| 970 this.container_.classList.add('video-controls'); | 970 this.container_.classList.add('video-controls'); |
| 971 this.initPlayButton(); | 971 this.initPlayButton(); |
| 972 this.initTimeControls(true /* show seek mark */); | 972 this.initTimeControls(true /* show seek mark */); |
| 973 this.initVolumeControls(); | 973 this.initVolumeControls(); |
| 974 | 974 |
| 975 if (opt_fullScreenToggle) { | 975 if (opt_fullScreenToggle) { |
| 976 this.fullscreenButton_ = | 976 this.fullscreenButton_ = |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1227 AudioControls.prototype.onAdvanceClick_ = function(forward) { | 1227 AudioControls.prototype.onAdvanceClick_ = function(forward) { |
| 1228 if (!forward && | 1228 if (!forward && |
| 1229 (this.getMedia().currentTime > AudioControls.TRACK_RESTART_THRESHOLD)) { | 1229 (this.getMedia().currentTime > AudioControls.TRACK_RESTART_THRESHOLD)) { |
| 1230 // We are far enough from the beginning of the current track. | 1230 // We are far enough from the beginning of the current track. |
| 1231 // Restart it instead of than skipping to the previous one. | 1231 // Restart it instead of than skipping to the previous one. |
| 1232 this.getMedia().currentTime = 0; | 1232 this.getMedia().currentTime = 0; |
| 1233 } else { | 1233 } else { |
| 1234 this.advanceTrack_(forward); | 1234 this.advanceTrack_(forward); |
| 1235 } | 1235 } |
| 1236 }; | 1236 }; |
| OLD | NEW |