SynQApp / Extension

Your music companion for the web, with a portable mini player and the ability to listen to any music link on your preferred service!
https://www.synqapp.io
Apache License 2.0
24 stars 2 forks source link

[FEATURE] Support for global keybindings/hotkeys #57

Open arjittw opened 3 months ago

arjittw commented 3 months ago

Like this extension but built in

Hotkeys that can be customized in browser settings that will allow to easily play/pause and next/prev track

image

tekkeon commented 3 months ago

Thanks for the suggestion! Seems like a great addition. If anyone is interested in taking on development of this feature, feel free to comment!

arjittw commented 3 months ago

I think adding this to manifest

"commands": {
      "play-pause": {
        "suggested_key": {
          "default": "Ctrl+Shift+Space"
        },
        "description": "Play/Pause"
      },
      "next": {
        "suggested_key": {
          "default": "Ctrl+Shift+Right"
        },
        "description": "Next"
      },
      "previous": {
        "suggested_key": {
          "default": "Ctrl+Shift+Left"
        },
        "description": "Previous"
      }
    }

and adding this should work

chrome.commands.onCommand.addListener(command => {
  switch (command) {
    case 'play-pause':
      sendToContent({
        name: MusicControllerMessage.PLAY_PAUSE
      })
      break;
    case 'next':
      sendToContent({
        name: MusicControllerMessage.NEXT
      })
      break;
    case 'previous':
      sendToContent({
        name: MusicControllerMessage.PREVIOUS
      })
      break;
  }
});
tekkeon commented 3 months ago

That seems like a reasonable quick solution! Do you want to give it a try and send a PR? We'd also want to have a button on the settings page that sends the user to the extension configuration page where those key controls can be configured.