hicetnunc-radio icon indicating copy to clipboard operation
hicetnunc-radio copied to clipboard

Desktop media buttons should play/pause/mute and navigate tracks.

Open OrderAndCh4oS opened this issue 3 years ago • 1 comments

Implement something like this

function onKeyDown(event) {
  if (event.code === 'MediaPlayPause') alert('Play/Pause');
  if (event.code === 'MediaStop') alert('Stop');
  if (event.code === 'MediaTrackPrevious') alert('Previous Track');
  if (event.code === 'MediaTrackNext') alert('Next Track');    
  if (event.code === 'VolumeUp') alert('Volume Up');
  if (event.code === 'VolumeDown') alert('Volume Down');
  if (event.code === 'VolumeMute') alert('Volume Mute');
}

OrderAndCh4oS avatar Jun 09 '21 07:06 OrderAndCh4oS

On macbook, if the "Use F1, F2, etc. keys as standard" option is unticked in Keyboard preferences, then the media keys are not triggering the onKeyDown event. However, the play/pause (F8) key is working once a track is playing. (but the play/pause icon would not update)

If the option is unticked, there are other problems on F7

If someone knows how to handle the mac media keys (prev, play/pause, next), that would help

lauzaki avatar Jul 05 '21 12:07 lauzaki