Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: ui/file_manager/audio_player/elements/control_panel.js

Issue 1883813005: Add shortcuts to audio player. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert 'send to start when paused' for now. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/file_manager/audio_player/js/audio_player.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a07a13635f699c9e1c2f274385cfa5fc18b0e226 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,40 @@
},
/**
+ * Skips min(5 seconds, 10% of duration).
+ * @param {boolean} forward Whether to skip forward/backword.
+ */
+ smallSkip: function(forward) {
+ var millisecondsToSkip = Math.min(5000, this.duration / 10);
+ if (!forward) {
+ millisecondsToSkip *= -1;
+ }
+ this.skip_(millisecondsToSkip);
+ },
+
+ /**
+ * Skips min(10 seconds, 20% of duration).
+ * @param {boolean} forward Whether to skip forward/backword.
+ */
+ bigSkip: function(forward) {
+ 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 +304,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
« no previous file with comments | « no previous file | ui/file_manager/audio_player/js/audio_player.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698