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 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 */ | 1006 */ |
1007 VideoControls.RESUME_REWIND = 5; // seconds. | 1007 VideoControls.RESUME_REWIND = 5; // seconds. |
1008 | 1008 |
1009 VideoControls.prototype = { __proto__: MediaControls.prototype }; | 1009 VideoControls.prototype = { __proto__: MediaControls.prototype }; |
1010 | 1010 |
1011 /** | 1011 /** |
1012 * Shows icon feedback for the current state of the video player. | 1012 * Shows icon feedback for the current state of the video player. |
1013 * @private | 1013 * @private |
1014 */ | 1014 */ |
1015 VideoControls.prototype.showIconFeedback_ = function() { | 1015 VideoControls.prototype.showIconFeedback_ = function() { |
1016 this.stateIcon_.removeAttribute('state'); | 1016 var stateIcon = this.stateIcon_; |
| 1017 stateIcon.removeAttribute('state'); |
| 1018 |
1017 setTimeout(function() { | 1019 setTimeout(function() { |
1018 this.stateIcon_.setAttribute('state', this.isPlaying() ? 'play' : 'pause'); | 1020 var newState = this.isPlaying() ? 'play' : 'pause'; |
| 1021 |
| 1022 var onAnimationEnd = function(state, event) { |
| 1023 if (stateIcon.getAttribute('state') === state) |
| 1024 stateIcon.removeAttribute('state'); |
| 1025 |
| 1026 stateIcon.removeEventListener('webkitAnimationEnd', onAnimationEnd); |
| 1027 }.bind(null, newState); |
| 1028 stateIcon.addEventListener('webkitAnimationEnd', onAnimationEnd); |
| 1029 |
| 1030 // Shows the icon with animation. |
| 1031 stateIcon.setAttribute('state', newState); |
1019 }.bind(this), 0); | 1032 }.bind(this), 0); |
1020 }; | 1033 }; |
1021 | 1034 |
1022 /** | 1035 /** |
1023 * Shows a text banner. | 1036 * Shows a text banner. |
1024 * | 1037 * |
1025 * @param {string} identifier String identifier. | 1038 * @param {string} identifier String identifier. |
1026 * @private | 1039 * @private |
1027 */ | 1040 */ |
1028 VideoControls.prototype.showTextBanner_ = function(identifier) { | 1041 VideoControls.prototype.showTextBanner_ = function(identifier) { |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 AudioControls.prototype.onAdvanceClick_ = function(forward) { | 1240 AudioControls.prototype.onAdvanceClick_ = function(forward) { |
1228 if (!forward && | 1241 if (!forward && |
1229 (this.getMedia().currentTime > AudioControls.TRACK_RESTART_THRESHOLD)) { | 1242 (this.getMedia().currentTime > AudioControls.TRACK_RESTART_THRESHOLD)) { |
1230 // We are far enough from the beginning of the current track. | 1243 // We are far enough from the beginning of the current track. |
1231 // Restart it instead of than skipping to the previous one. | 1244 // Restart it instead of than skipping to the previous one. |
1232 this.getMedia().currentTime = 0; | 1245 this.getMedia().currentTime = 0; |
1233 } else { | 1246 } else { |
1234 this.advanceTrack_(forward); | 1247 this.advanceTrack_(forward); |
1235 } | 1248 } |
1236 }; | 1249 }; |
OLD | NEW |