Index: ui/file_manager/audio_player/elements/control_panel.js |
diff --git a/ui/file_manager/audio_player/elements/control_panel.js b/ui/file_manager/audio_player/elements/control_panel.js |
index 98c4374c6fb0dd9856a7818aa6896a07584ed3ed..582cf6279cc7fca6a066e23ab9414d21612be54d 100644 |
--- a/ui/file_manager/audio_player/elements/control_panel.js |
+++ b/ui/file_manager/audio_player/elements/control_panel.js |
@@ -139,10 +139,6 @@ |
if (!this.dragging) |
this.dragging = true; |
}.bind(this)); |
- timeSlider.addEventListener('keydown', |
- this.onProgressKeyDownOrKeyPress_.bind(this)); |
- timeSlider.addEventListener('keypress', |
- this.onProgressKeyDownOrKeyPress_.bind(this)); |
// Update volume on user inputs for volume slider. |
// During a drag operation, the volume should be updated immediately. |
@@ -190,6 +186,48 @@ |
}, |
/** |
+ * Skips min(5 seconds, 10% of duration) or sends to start/end when paused. |
+ * @param {boolean} forward Whether to skip forward/backword. |
+ */ |
+ smallSkip: function(forward) { |
+ if (!this.playing) { |
+ this.time = forward ? this.duration : 0; |
+ return; |
+ } |
+ var millisecondsToSkip = Math.min(5000, this.duration / 10); |
+ if (!forward) { |
+ millisecondsToSkip *= -1; |
+ } |
+ this.skip_(millisecondsToSkip); |
+ }, |
+ |
+ /** |
+ * Skips min(10 seconds, 20% of duration) or sends to start/end when paused. |
+ * @param {boolean} forward Whether to skip forward/backword. |
+ */ |
+ bigSkip: function(forward) { |
+ if (!this.playing) { |
+ this.time = forward ? this.duration : 0; |
+ return; |
+ } |
+ var millisecondsToSkip = Math.min(10000, this.duration / 5); |
+ if (!forward) { |
+ millisecondsToSkip *= -1; |
+ } |
+ this.skip_(millisecondsToSkip); |
+ }, |
+ |
+ /** |
+ * Skips forward/backword. |
+ * @param {number} sec Seconds to skip. Set negative value to skip backword. |
+ * @private |
+ */ |
+ skip_: function(millis) { |
+ if (this.duration > 0) |
+ this.time = Math.max(Math.min(this.time + millis, this.duration), 0); |
+ }, |
+ |
+ /** |
* Converts the time into human friendly string. |
* @param {number} time Time to be converted. |
* @return {string} String representation of the given time |
@@ -274,29 +312,5 @@ |
this.volume !== 0 ? ariaLabels.mute : ariaLabels.unmute); |
this.$.volumeSlider.setAttribute('aria-label', ariaLabels.volumeSlider); |
}, |
- |
- /** |
- * Handles arrow keys on time slider to skip forward/backword. |
- * @param {!Event} event |
- * @private |
- */ |
- onProgressKeyDownOrKeyPress_: function(event) { |
- if (event.code !== 'ArrowRight' && event.code !== 'ArrowLeft' && |
- event.code !== 'ArrowUp' && event.code !== 'ArrowDown') { |
- return; |
- } |
- |
- event.preventDefault(); |
- |
- if (this.duration > 0) { |
- // Skip 5 seconds or 10% of duration, whichever is smaller. |
- var millisecondsToSkip = Math.min(5000, this.duration / 10); |
- if (event.code === 'ArrowRight' || event.code === 'ArrowUp') { |
- this.time = Math.min(this.time + millisecondsToSkip, this.duration); |
- } else { |
- this.time = Math.max(this.time - millisecondsToSkip, 0); |
- } |
- } |
- } |
}); |
})(); // Anonymous closure |