shinedou wrote: 
> 
> I just noticed the "Keyboard shortcuts" setting is not available in
> lms-material-app. Is this a limitation of the android app or is it
> something that can be activated somehow? My use case is lms-material-app
> on an AndroidTV (NVidia Shield) to view the now playing screen on the
> tv. If keyboards shortcuts were available I could play/pause or skip to
> next song with a remote programmed to send the keyboard shortcuts.

I -might- enable the playback shortcuts for mobile and desktop, but for
now if you create a file named "custom.js" within a "material-skin"
sub-folder of your LMS's "prefs" folder with the following contents,
then it should work:


Code:
--------------------
    
  if (IS_MOBILE) { // desktop already catches  these shortcuts, so dont want 
them handled twice!
  var playerIsPlaying = false;
  Mousetrap.addKeycodes({ // Codes from 
https://github.com/wesbos/keycodes/blob/gh-pages/scripts.js
  174: 'decvol',
  175: 'incvol',
  182: 'decvolfirefox',
  183: 'incvolfirefox'
  })
  // 'bind' keys that we are interested in
  bindKey('up', 'alt', true);
  bindKey('down', 'alt', true);
  bindKey('space');
  bindKey('decvol', undefined, true);
  bindKey('incvol', undefined, true);
  bindKey('decvolfirefox', undefined, true);
  bindKey('incvolfirefox', undefined, true);
  bindKey('left', 'alt', true);
  bindKey('right', 'alt', true);
  
  // Act on keys being pressed
  bus.$on('keyboard', function(key, modifier) {
  // Ignore shortcurt if there is no player or we have a menu/dialog open
  if (!store.state.player || store.state.visibleMenus.size>0 || 
(store.state.openDialogs.length>0 && 
store.state.openDialogs[0]!='info-dialog'))  {
  return;
  }
  var command = undefined;
  if (undefined==modifier) {
  if (key=='space') {
  command=[playerIsPlaying ? 'pause' : 'play'];
  } else if (key=='incvol' || key=='incvolfirefox') {
  bus.$emit('adjustVolume', true);
  } else if (key=='decvol' || key=='decvolfirefox') {
  bus.$emit('adjustVolume', false);
  }
  } else if ('alt'==modifier) {
  if (key=='up') {
  bus.$emit('adjustVolume', true);
  } else if (key=='down') {
  bus.$emit('adjustVolume', false);
  } else if (key=='left') {
  command=['button', 'jump_rew'];
  } else if (key=='right') {
  command=['playlist', 'index', '+1'];
  }
  }
  
  if (command) {
  lmsCommand(store.state.player.id, command).then(({data}) => {
  bus.$emit('updatePlayer', store.state.player.id);
  });
  }
  });
  
  // Need to keep trak of whether current player is playing or not, so know 
when to play and when to pause
  bus.$on('playerStatus', function(playerStatus) {
  playerIsPlaying = playerStatus.isplaying;
  });
  }
  
--------------------



*Material debug:* 1. Launch via http: //SERVER:9000/material/?debug=json
(Use http: //SERVER:9000/material/?debug=json,cometd to also see update
messages, e.g. play queue) 2. Open browser's developer tools 3. Open
console tab in developer tools 4. REQ/RESP messages sent to/from LMS
will be logged here.
------------------------------------------------------------------------
cpd73's Profile: http://forums.slimdevices.com/member.php?userid=66686
View this thread: http://forums.slimdevices.com/showthread.php?t=109624

_______________________________________________
plugins mailing list
plugins@lists.slimdevices.com
http://lists.slimdevices.com/mailman/listinfo/plugins

Reply via email to