justinknguyen / BeatBind

A background Python Windows application for global hotkeys on Spotify.
MIT License
51 stars 7 forks source link

No delay after button press option? #11

Closed Mockordio closed 8 months ago

Mockordio commented 8 months ago

I started using this tool just recently and it works well, but one thing I noticed is that each time I press a set hotkey combination, be it pause/play, next track or volume control, there's always a very noticeable delay between the button press and the action. This is particularly... annoying when I need to lower the volume significantly and quickly (for example when a song in a playlist sound much louder than a previous one), so I start smashing the volume down combo and the delays kinda start stacking leading to a sudden significant volume drop a second or two later, after my button presses register. I'm not sure if this delay is a bug or a feature, but it would be nice to have an option to have your hotkey presses have an instant effect without any delay, if it's possible. I know BeatBind is it's own program so not comparing the two, but I've been using a similar tool called Toastify before it for years (until as it stopped working for me completely just recently) and the hotkey presses were always registering instantly with it, so I'm guessing it would be possible to implement this on BeatBind as well, right? Perhaps as a separate option? Thanks.

justinknguyen commented 8 months ago

Sorry, there's no way to reduce the delay currently. When you create the app on Spotify's website, it's in development mode and you're communicating with it remotely- that's where the delay comes from. The delay happens when you send a request and it waits for the Spotify Web API to send back a response. Not too sure if Toastify uses the Web API for it's hotkeys or not, but if so, then I think it's because they got their app approved. An approved app could allow this to be faster.

https://developer.spotify.com/documentation/web-api/concepts/quota-modes

If Toastify doesn't use it for their hotkey feature and does it locally, then there's no way to get close to it's response time. I also won't be changing this to work locally. You can find a lot of AHK scripts online that attempt to do so, but it always breaks because Spotify changes something in their desktop app.

In regards to the volume delay, I added a feature recently to change how much the volume changes as a workaround for now.

Edit: here's another repo that does it locally instead of using the API

https://github.com/mavvos/SpotifyGlobal

Mockordio commented 8 months ago

Thanks for the explanation and the links, justinknguyen. I have no further questions on this.

justinknguyen commented 8 months ago

Thanks for the explanation and the links, justinknguyen. I have no further questions on this.

Just a follow up, Toastify's hotkey feature runs locally since it worked for free and premium users. The endpoints used in this app from Spotify's Web API are locked to premium users only, for example https://developer.spotify.com/documentation/web-api/reference/start-a-users-playback

So it wouldn't be possible for Toastify to work for free users if it used the API for the hotkey feature.

I also took a quick look at the repo, and it has logic to find and get the user's Spotify's window (to send hotkeys), which I assume is what is making Toastify fail now. Never seems to be reliable doing that. Toastify is only using these endpoints from Spotify's Web API https://github.com/aleab/toastify/blob/master/ToastifyAPI/Core/ISpotifyWebAPI.cs