| 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 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 if (opt_fullScreenToggle) { | 979 if (opt_fullScreenToggle) { |
| 980 this.fullscreenButton_ = | 980 this.fullscreenButton_ = |
| 981 this.createButton('fullscreen', opt_fullScreenToggle); | 981 this.createButton('fullscreen', opt_fullScreenToggle); |
| 982 } | 982 } |
| 983 | 983 |
| 984 if (opt_stateIconParent) { | 984 if (opt_stateIconParent) { |
| 985 this.stateIcon_ = this.createControl( | 985 this.stateIcon_ = this.createControl( |
| 986 'playback-state-icon', opt_stateIconParent); | 986 'playback-state-icon', opt_stateIconParent); |
| 987 } | 987 } |
| 988 | 988 |
| 989 var video_controls = this; | 989 var videoControls = this; |
| 990 chrome.mediaPlayerPrivate.onTogglePlayState.addListener( | 990 chrome.mediaPlayerPrivate.onTogglePlayState.addListener( |
| 991 function() { video_controls.togglePlayStateWithFeedback(); }); | 991 function() { videoControls.togglePlayStateWithFeedback(); }); |
| 992 } | 992 } |
| 993 | 993 |
| 994 /** | 994 /** |
| 995 * No resume if we are withing this margin from the start or the end. | 995 * No resume if we are withing this margin from the start or the end. |
| 996 */ | 996 */ |
| 997 VideoControls.RESUME_MARGIN = 0.03; | 997 VideoControls.RESUME_MARGIN = 0.03; |
| 998 | 998 |
| 999 /** | 999 /** |
| 1000 * No resume for videos shorter than this. | 1000 * No resume for videos shorter than this. |
| 1001 */ | 1001 */ |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1126 this.container_.classList.add('audio-controls'); | 1126 this.container_.classList.add('audio-controls'); |
| 1127 | 1127 |
| 1128 this.advanceTrack_ = advanceTrack; | 1128 this.advanceTrack_ = advanceTrack; |
| 1129 | 1129 |
| 1130 this.initPlayButton(); | 1130 this.initPlayButton(); |
| 1131 this.initTimeControls(false /* no seek mark */); | 1131 this.initTimeControls(false /* no seek mark */); |
| 1132 /* No volume controls */ | 1132 /* No volume controls */ |
| 1133 this.createButton('previous', this.onAdvanceClick_.bind(this, false)); | 1133 this.createButton('previous', this.onAdvanceClick_.bind(this, false)); |
| 1134 this.createButton('next', this.onAdvanceClick_.bind(this, true)); | 1134 this.createButton('next', this.onAdvanceClick_.bind(this, true)); |
| 1135 | 1135 |
| 1136 var audio_controls = this; | 1136 var audioControls = this; |
| 1137 chrome.mediaPlayerPrivate.onNextTrack.addListener( | 1137 chrome.mediaPlayerPrivate.onNextTrack.addListener( |
| 1138 function() { audio_controls.onAdvanceClick_(true); }); | 1138 function() { audioControls.onAdvanceClick_(true); }); |
| 1139 chrome.mediaPlayerPrivate.onPrevTrack.addListener( | 1139 chrome.mediaPlayerPrivate.onPrevTrack.addListener( |
| 1140 function() { audio_controls.onAdvanceClick_(false); }); | 1140 function() { audioControls.onAdvanceClick_(false); }); |
| 1141 chrome.mediaPlayerPrivate.onTogglePlayState.addListener( | 1141 chrome.mediaPlayerPrivate.onTogglePlayState.addListener( |
| 1142 function() { audio_controls.togglePlayState(); }); | 1142 function() { audioControls.togglePlayState(); }); |
| 1143 } | 1143 } |
| 1144 | 1144 |
| 1145 AudioControls.prototype = { __proto__: MediaControls.prototype }; | 1145 AudioControls.prototype = { __proto__: MediaControls.prototype }; |
| 1146 | 1146 |
| 1147 /** | 1147 /** |
| 1148 * Media completion handler. Advances to the next track. | 1148 * Media completion handler. Advances to the next track. |
| 1149 */ | 1149 */ |
| 1150 AudioControls.prototype.onMediaComplete = function() { | 1150 AudioControls.prototype.onMediaComplete = function() { |
| 1151 this.advanceTrack_(true); | 1151 this.advanceTrack_(true); |
| 1152 }; | 1152 }; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1163 AudioControls.prototype.onAdvanceClick_ = function(forward) { | 1163 AudioControls.prototype.onAdvanceClick_ = function(forward) { |
| 1164 if (!forward && | 1164 if (!forward && |
| 1165 (this.getMedia().currentTime > AudioControls.TRACK_RESTART_THRESHOLD)) { | 1165 (this.getMedia().currentTime > AudioControls.TRACK_RESTART_THRESHOLD)) { |
| 1166 // We are far enough from the beginning of the current track. | 1166 // We are far enough from the beginning of the current track. |
| 1167 // Restart it instead of than skipping to the previous one. | 1167 // Restart it instead of than skipping to the previous one. |
| 1168 this.getMedia().currentTime = 0; | 1168 this.getMedia().currentTime = 0; |
| 1169 } else { | 1169 } else { |
| 1170 this.advanceTrack_(forward); | 1170 this.advanceTrack_(forward); |
| 1171 } | 1171 } |
| 1172 }; | 1172 }; |
| OLD | NEW |