You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using your library in a project and I would like to add the possibilty to switch from spotify account. What I would like to achieve is to logout/shutdown the current spotify session and start a new one with another account. I have tried all the logout/shutdown/destroy methods of JahSpotifyService and the jahspotify instance, but never manage to do this.
I adjusted the test application to try this:
public static void main(String[] args) {
// Determine the tempfolder and make sure it exists.
File temp = new File(new File(Main.class.getResource("Main.class").getFile()).getParentFile(), "temp");
temp.mkdirs();
// Start JahSpotify
JahSpotifyService.initialize(temp);
JahSpotifyService.getInstance().getJahSpotify().addConnectionListener(new AbstractConnectionListener() {
@Override
public void initialized(final boolean initialized) {
if (initialized)
JahSpotifyService.getInstance().getJahSpotify().login(uname1, password1, null, false);
}
@Override
public void loggedIn(final boolean success) {
if (success) {
System.out.println("Logged in as "+JahSpotifyService.getInstance().getJahSpotify().getUser().getUserName());
}
}
@Override
public void playlistsLoaded(final boolean contents) {
System.out.println("Found "+PlaylistContainer.getPlaylists().size()+" playlists");
}
public void loggedOut() {
System.out.println("Logged out from spotify");
}
});
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}
// Shutdown, logout, ... from spotify
JahSpotifyService.getInstance().shutdown();
// Login with a new user when typing y (after logout)
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String result = null;
try {
while(true) {
System.out.println("Switch user? (y or n)");
result = in.readLine();
if(result.equals("y")) {
JahSpotifyService.getInstance().getJahSpotify().login(uname2, password2, null, false);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
This results in:
feb 23, 2015 6:37:29 PM jahspotify.impl.NativeLogger error
SEVERE: [jahspotify::Java_jahspotify_impl_JahSpotifyImpl_retrieveUser] Retrieving user
feb 23, 2015 6:37:29 PM jahspotify.impl.NativeLogger error
SEVERE: [jahspotify::Java_jahspotify_impl_JahSpotifyImpl_retrieveUser] User is loaded
Logged in as 124884048
Found 64 playlists
Switch user? (y or n)
Logged out from spotify
feb 23, 2015 6:37:34 PM jahspotify.impl.NativeLogger info
INFO: [callbacks::signalLoggedOut] Logout signalled
y
Switch user? (y or n)
Logged in as 124884048
y
Switch user? (y or n)
Logged in as 124884048
Note that the user ID is always the same. Also the playlists of the second account are never loaded.
Do you know how this can be done?
Thanks for publishing this library and thanks in advance for your help.
Kind regards,
Johan
The text was updated successfully, but these errors were encountered:
Hello nvdweem,
I'm using your library in a project and I would like to add the possibilty to switch from spotify account. What I would like to achieve is to logout/shutdown the current spotify session and start a new one with another account. I have tried all the logout/shutdown/destroy methods of JahSpotifyService and the jahspotify instance, but never manage to do this.
I adjusted the test application to try this:
This results in:
Note that the user ID is always the same. Also the playlists of the second account are never loaded.
Do you know how this can be done?
Thanks for publishing this library and thanks in advance for your help.
Kind regards,
Johan
The text was updated successfully, but these errors were encountered: