LabyStudio / java-spotify-api

Spotify API written in Java to locally access the current song information
15 stars 5 forks source link

Need guidance on using java-spotify-api as a basic player. #11

Closed kRystalDevv closed 7 months ago

kRystalDevv commented 7 months ago

I am relatively new to the Spotify API and am currently attempting to integrate it into my project as a basic player. Despite reviewing the documentation, I find myself unclear on the essential steps and requirements.

I have a few specific queries regarding the integration process:

  1. How do I establish a connection and link my application API with the Spotify API?
  2. I currently have three buttons to control playback in my GUI-based project developed with Ant.

Development Environment:

If any additional information is needed to better understand my situation, Please ask, I'll provide it.

LabyStudio commented 7 months ago

Be aware that this API only accesses the Spotify application locally and uses an unofficial method. The playback control simply accesses the media API of your operating system to change or play/pause songs. If you want to control playback with the API, you can simply call:

SpotifyAPI api = SpotifyAPIFactory.createInitialized();

// Send media keys to the operating system
api.pressMediaKey(MediaKey.PLAY_PAUSE);
api.pressMediaKey(MediaKey.PREV);
api.pressMediaKey(MediaKey.NEXT);

If you want to read the current state of the Spotify player you can use the example of the README file. Depending on the operating system, different methods are used to access the data. Under Linux, the data is read from dbus-send, under macOS AppleScript is used and under Windows the data is read from memory.

kRystalDevv commented 7 months ago

thanks for giving a clearer understanding!