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

Implement key controls on popup and each music service #28

Closed tekkeon closed 11 months ago

tekkeon commented 11 months ago

Overview

For once, a relatively small PR! This introduces the key controls feature on both the popup and on music service pages. This feature enables users to control pause/play, next, previous, and volume with arrow keys + space bar. This is to meet YTM+ parity and also offer better accessibility via keyboard.

Each music service has some amount of control with these keys already on their website, so each has a different configuration for which controls need to be enabled. The core logic was able to be shared between the Popup and the music service content scripts which was nice.

Finally, hooked this up to the settings toggle. It's all reactive via the store, meaning the user does not need to refresh after flipping the toggle - it just immediately takes effect.

Final change I made was to have setVolume support a relative volume change as well as key controls require relative control, otherwise the logic for the key controls would also need to be explicitly aware of application state, and this just seemed cleaner to keep that state within the controllers. Since relative volumes could result in negative values or greater than 100%, I also added a util to normalize the volume input.