hicetnunc-radio
hicetnunc-radio copied to clipboard
Desktop media buttons should play/pause/mute and navigate tracks.
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');
}
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