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) {
break;
case 'U+0056': // 'v'
case 'MediaPlayPause':
this.slideMode_.startSlideshow(SlideMode.SLIDESHOW_INTERVAL_FIRST, event);
break;
......
......@@ -608,7 +608,10 @@ SlideMode.prototype.getNextSelectedIndex_ = function(direction) {
* @param {string} keyID Key identifier.
*/
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) {
if (this.isSlideshowOn_()) {
switch (keyID) {
case 'U+001B': // Escape exits the slideshow.
case 'MediaStop':
this.stopSlideshow_(event);
break;
case 'U+0020': // Space pauses/resumes the slideshow.
case 'MediaPlayPause':
this.toggleSlideshowPause_();
break;
......@@ -818,6 +823,8 @@ SlideMode.prototype.onKeyDown = function(event) {
case 'Down':
case 'Left':
case 'Right':
case 'MediaNextTrack':
case 'MediaPreviousTrack':
this.advanceWithKeyboard(keyID);
break;
}
......@@ -854,6 +861,8 @@ SlideMode.prototype.onKeyDown = function(event) {
case 'Down':
case 'Left':
case 'Right':
case 'MediaNextTrack':
case 'MediaPreviousTrack':
this.advanceWithKeyboard(keyID);
break;
......
......@@ -237,10 +237,12 @@ cr.define('cr.ui', function() {
this.getFirstIndex() : this.getIndexBelow(leadIndex);
break;
case 'Left':
case 'MediaPreviousTrack':
newIndex = leadIndex == -1 ?
this.getLastIndex() : this.getIndexBefore(leadIndex);
break;
case 'Right':
case 'MediaNextTrack':
newIndex = leadIndex == -1 ?
this.getFirstIndex() : this.getIndexAfter(leadIndex);
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