labystudio / java-spotify-api Goto Github PK
View Code? Open in Web Editor NEWSpotify API written in Java to locally access the current song information
Spotify API written in Java to locally access the current song information
Apparently since the latest Spotify update (again), the API seems broken and does not work properly anymore.
I'm not getting any errors inside of LabyMod.
I sent @PrincessAkira a message about this, so that a fix will be worked on.
Tested with Spotify version:
Spotify für Windows (64 Bit)
1.2.21.1104.g42cf0a50
After using most of the documentation code:
Main.java:
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
SpotifyController controller = new SpotifyController("http://192.168.188.74/api/custom?name=Spotify");
controller.register();
}
}
SpotifyController.java
import de.labystudio.spotifyapi.SpotifyAPI;
import de.labystudio.spotifyapi.SpotifyAPIFactory;
import de.labystudio.spotifyapi.SpotifyListener;
import de.labystudio.spotifyapi.model.Track;
public class SpotifyController
{
private SpotifyAPI spotify;
Httpcontroller httpcontroller;
SpotifyController(String url)
{
spotify = SpotifyAPIFactory.create();
httpcontroller = new Httpcontroller("http://192.168.188.74/api/custom?name=Spotify");
}
public void register()
{
spotify.registerListener(new SpotifyListener()
{
@Override
public void onConnect() {
System.out.println("Connected to Spotify!");
}
@Override
public void onTrackChanged(Track track) {
System.out.println("Track changed:" + track);
}
@Override
public void onPositionChanged(int position) {
/*if (!spotify.hasTrack()) {
return;
}
int length =spotify.getTrack().getLength();
float percentage = 100.0F / length * position;
System.out.printf(
"Position changed: %s of %s (%d%%)\n",
formatDuration(position),
formatDuration(length),
(int) percentage
);*/
System.out.println("Position change: " + position);
}
@Override
public void onPlayBackChanged(boolean isPlaying) {
System.out.println(isPlaying ? "Song started playing" : "Song stopped playing");
}
@Override
public void onSync() {
}
@Override
public void onDisconnect(Exception exception) {
System.out.println("Disconnected: " + exception.getMessage());
spotify.stop();
}
});
spotify.initialize();
}
}
Ive noticed it never prints "Song stopped playing" and "Position change" during songs, it only prints position change after skipping a song. Am I missing something or is this a bug?
When using, i can observe an invalid track id.
This will cause the following error
java.lang.NullPointerException: Cannot read field "id" because "openTrack" is null
at de.labystudio.spotifyapi.open.OpenSpotifyAPI.requestOpenTrack(OpenSpotifyAPI.java:247)
at de.labystudio.spotifyapi.platform.windows.WinSpotifyAPI.onTick(WinSpotifyAPI.java:75)
at de.labystudio.spotifyapi.platform.AbstractTickSpotifyAPI.onInternalTick(AbstractTickSpotifyAPI.java:69)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
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:
Development Environment:
If any additional information is needed to better understand my situation, Please ask, I'll provide it.
Caused by: java.lang.ClassNotFoundException: de.labystudio.spotifyapi.SpotifyListener
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:560)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:211)
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:189)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:556)
Caused by: java.lang.NullPointerException
... 16 more
Caused by: java.lang.ClassNotFoundException: de.labystudio.spotifyapi.SpotifyListener
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 44 more
coremods are present:
Caused by: java.lang.NullPointerException
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:182)
... 46 more
Apparently since the latest Spotify update, the API seems broken and does not work properly anymore.
I'm not getting any errors inside of LabyMod.
So I'm currently trying to get in contact with @PrincessAkira again to help out investigating, so we can maybe find the error, the reason for the error and then provide a fix for it in form as a PR.
Tested with Spotify version:
Spotify für Windows (64 Bit)
1.2.20.1216.ge7a7b92f
Other then a few months ago I cant get it to work now.
Did it break with a recent update?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.