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 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 | 851 |
852 if (opt_stateIconParent) { | 852 if (opt_stateIconParent) { |
853 this.stateIcon_ = this.createControl( | 853 this.stateIcon_ = this.createControl( |
854 'playback-state-icon', opt_stateIconParent); | 854 'playback-state-icon', opt_stateIconParent); |
855 } | 855 } |
856 | 856 |
857 this.resumePositions_ = new TimeLimitedMap( | 857 this.resumePositions_ = new TimeLimitedMap( |
858 'VideoResumePosition', | 858 'VideoResumePosition', |
859 VideoControls.RESUME_POSITIONS_CAPACITY, | 859 VideoControls.RESUME_POSITIONS_CAPACITY, |
860 VideoControls.RESUME_POSITION_LIFETIME); | 860 VideoControls.RESUME_POSITION_LIFETIME); |
| 861 |
| 862 var video_controls = this; |
| 863 chrome.mediaPlayerPrivate.onTogglePlayState.addListener( |
| 864 function() { video_controls.togglePlayStateWithFeedback(); }); |
861 } | 865 } |
862 | 866 |
863 /** | 867 /** |
864 * Capacity of the resume position storage. | 868 * Capacity of the resume position storage. |
865 */ | 869 */ |
866 VideoControls.RESUME_POSITIONS_CAPACITY = 100; | 870 VideoControls.RESUME_POSITIONS_CAPACITY = 100; |
867 | 871 |
868 /** | 872 /** |
869 * Maximum lifetime of a stored position. | 873 * Maximum lifetime of a stored position. |
870 */ | 874 */ |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 | 1136 |
1133 this.container_.classList.add('audio-controls'); | 1137 this.container_.classList.add('audio-controls'); |
1134 | 1138 |
1135 this.advanceTrack_ = advanceTrack; | 1139 this.advanceTrack_ = advanceTrack; |
1136 | 1140 |
1137 this.initPlayButton(); | 1141 this.initPlayButton(); |
1138 this.initTimeControls(false /* no seek mark */); | 1142 this.initTimeControls(false /* no seek mark */); |
1139 /* No volume controls */ | 1143 /* No volume controls */ |
1140 this.createButton('previous', this.onAdvanceClick_.bind(this, false)); | 1144 this.createButton('previous', this.onAdvanceClick_.bind(this, false)); |
1141 this.createButton('next', this.onAdvanceClick_.bind(this, true)); | 1145 this.createButton('next', this.onAdvanceClick_.bind(this, true)); |
| 1146 |
| 1147 var audio_controls = this; |
| 1148 chrome.mediaPlayerPrivate.onNextTrack.addListener( |
| 1149 function() { audio_controls.onAdvanceClick_(true); }); |
| 1150 chrome.mediaPlayerPrivate.onPrevTrack.addListener( |
| 1151 function() { audio_controls.onAdvanceClick_(false); }); |
| 1152 chrome.mediaPlayerPrivate.onTogglePlayState.addListener( |
| 1153 function() { audio_controls.togglePlayState(); }); |
1142 } | 1154 } |
1143 | 1155 |
1144 AudioControls.prototype = { __proto__: MediaControls.prototype }; | 1156 AudioControls.prototype = { __proto__: MediaControls.prototype }; |
1145 | 1157 |
1146 /** | 1158 /** |
1147 * Media completion handler. Advances to the next track. | 1159 * Media completion handler. Advances to the next track. |
1148 */ | 1160 */ |
1149 AudioControls.prototype.onMediaComplete = function() { | 1161 AudioControls.prototype.onMediaComplete = function() { |
1150 this.advanceTrack_(true); | 1162 this.advanceTrack_(true); |
1151 }; | 1163 }; |
(...skipping 10 matching lines...) Expand all Loading... |
1162 AudioControls.prototype.onAdvanceClick_ = function(forward) { | 1174 AudioControls.prototype.onAdvanceClick_ = function(forward) { |
1163 if (!forward && | 1175 if (!forward && |
1164 (this.getMedia().currentTime > AudioControls.TRACK_RESTART_THRESHOLD)) { | 1176 (this.getMedia().currentTime > AudioControls.TRACK_RESTART_THRESHOLD)) { |
1165 // We are far enough from the beginning of the current track. | 1177 // We are far enough from the beginning of the current track. |
1166 // Restart it instead of than skipping to the previous one. | 1178 // Restart it instead of than skipping to the previous one. |
1167 this.getMedia().currentTime = 0; | 1179 this.getMedia().currentTime = 0; |
1168 } else { | 1180 } else { |
1169 this.advanceTrack_(forward); | 1181 this.advanceTrack_(forward); |
1170 } | 1182 } |
1171 }; | 1183 }; |
OLD | NEW |