Gallery: Add support for Media Keys

BUG=393346
R=yoshiki@chromium.org
R=bauerb@chromium.org
TEST=Manually tested with external USB keyboard
Signed-off-by: default avatarEduardo Lima (Etrunko) <eduardo.lima@intel.com>

Review URL: https://codereview.chromium.org/385263005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282954 0039d316-1c4b-4281-b951-d872f2087c98
parent ab5364ca
...@@ -690,6 +690,7 @@ Gallery.prototype.onKeyDown_ = function(event) { ...@@ -690,6 +690,7 @@ Gallery.prototype.onKeyDown_ = function(event) {
break; break;
case 'U+0056': // 'v' case 'U+0056': // 'v'
case 'MediaPlayPause':
this.slideMode_.startSlideshow(SlideMode.SLIDESHOW_INTERVAL_FIRST, event); this.slideMode_.startSlideshow(SlideMode.SLIDESHOW_INTERVAL_FIRST, event);
break; break;
......
...@@ -608,7 +608,10 @@ SlideMode.prototype.getNextSelectedIndex_ = function(direction) { ...@@ -608,7 +608,10 @@ SlideMode.prototype.getNextSelectedIndex_ = function(direction) {
* @param {string} keyID Key identifier. * @param {string} keyID Key identifier.
*/ */
SlideMode.prototype.advanceWithKeyboard = function(keyID) { SlideMode.prototype.advanceWithKeyboard = function(keyID) {
this.advanceManually(keyID === 'Up' || keyID === 'Left' ? -1 : 1); var prev = (keyID === 'Up' ||
keyID === 'Left' ||
keyID === 'MediaPreviousTrack');
this.advanceManually(prev ? -1 : 1);
}; };
/** /**
...@@ -807,10 +810,12 @@ SlideMode.prototype.onKeyDown = function(event) { ...@@ -807,10 +810,12 @@ SlideMode.prototype.onKeyDown = function(event) {
if (this.isSlideshowOn_()) { if (this.isSlideshowOn_()) {
switch (keyID) { switch (keyID) {
case 'U+001B': // Escape exits the slideshow. case 'U+001B': // Escape exits the slideshow.
case 'MediaStop':
this.stopSlideshow_(event); this.stopSlideshow_(event);
break; break;
case 'U+0020': // Space pauses/resumes the slideshow. case 'U+0020': // Space pauses/resumes the slideshow.
case 'MediaPlayPause':
this.toggleSlideshowPause_(); this.toggleSlideshowPause_();
break; break;
...@@ -818,6 +823,8 @@ SlideMode.prototype.onKeyDown = function(event) { ...@@ -818,6 +823,8 @@ SlideMode.prototype.onKeyDown = function(event) {
case 'Down': case 'Down':
case 'Left': case 'Left':
case 'Right': case 'Right':
case 'MediaNextTrack':
case 'MediaPreviousTrack':
this.advanceWithKeyboard(keyID); this.advanceWithKeyboard(keyID);
break; break;
} }
...@@ -854,6 +861,8 @@ SlideMode.prototype.onKeyDown = function(event) { ...@@ -854,6 +861,8 @@ SlideMode.prototype.onKeyDown = function(event) {
case 'Down': case 'Down':
case 'Left': case 'Left':
case 'Right': case 'Right':
case 'MediaNextTrack':
case 'MediaPreviousTrack':
this.advanceWithKeyboard(keyID); this.advanceWithKeyboard(keyID);
break; break;
......
...@@ -237,10 +237,12 @@ cr.define('cr.ui', function() { ...@@ -237,10 +237,12 @@ cr.define('cr.ui', function() {
this.getFirstIndex() : this.getIndexBelow(leadIndex); this.getFirstIndex() : this.getIndexBelow(leadIndex);
break; break;
case 'Left': case 'Left':
case 'MediaPreviousTrack':
newIndex = leadIndex == -1 ? newIndex = leadIndex == -1 ?
this.getLastIndex() : this.getIndexBefore(leadIndex); this.getLastIndex() : this.getIndexBefore(leadIndex);
break; break;
case 'Right': case 'Right':
case 'MediaNextTrack':
newIndex = leadIndex == -1 ? newIndex = leadIndex == -1 ?
this.getFirstIndex() : this.getIndexAfter(leadIndex); this.getFirstIndex() : this.getIndexAfter(leadIndex);
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment