从寻呼机对象访问播放列表列表
Accessing list of playlists from Pager object
我在从网络访问播放列表列表时遇到一些问题 api。我真的很想使用 getMyPlaylists
但它似乎不是我可以使用的选项所以目前我正在尝试这个:
api.setAccessToken(response.getAccessToken());
SpotifyService spotify = api.getService();
final UserPrivate me = spotify.getMe();
Pager<PlaylistSimple> test = spotify.getPlaylists(me.id);
但是,如何访问测试对象的信息?或者更好的是,我该如何更改它以便我可以使用 getMyPlaylists
来代替?
谢谢
This is how you do it..
SpotifyApi api = new SpotifyApi();
api.setAccessToken(token);
SpotifyService spotify = api.getService();
spotify.getPlaylists("USERID", new Callback<Pager<Playlist>>() {
@Override
public void success(Pager<Playlist> playlistPager, Response response) {
Log.d("TEST", "Got the playlists");
List<Playlist> playlists = playlistPager.items;
for (Playlist p : playlists) {
Log.e("TEST", p.name + " - " + p.id);
}
}
@Override
public void failure(RetrofitError error) {
Log.e("TEST", "Could not get playlists");
}
});
Once you know the playlist ID, you can then fetch the tracks of the playlist with something like this :
spotify.getPlaylistTracks("USERID","PLAYLISTID", new Callback<Pager<PlaylistTrack>>() {
@Override
public void success(Pager<PlaylistTrack> playlistTrackPager, Response response) {
Log.e("TEST", "GOT the tracks in playlist");
List<PlaylistTrack> items = playlistTrackPager.items;
for( PlaylistTrack pt : items){
Log.e("TEST", pt.track.name + " - " + pt.track.id);
}
}
@Override
public void failure(RetrofitError error) {
Log.e("TEST", "Could not get playlist tracks");
}
});
coutesy lunai
https://github.com/spotify/android-sdk/issues/79
我在从网络访问播放列表列表时遇到一些问题 api。我真的很想使用 getMyPlaylists
但它似乎不是我可以使用的选项所以目前我正在尝试这个:
api.setAccessToken(response.getAccessToken());
SpotifyService spotify = api.getService();
final UserPrivate me = spotify.getMe();
Pager<PlaylistSimple> test = spotify.getPlaylists(me.id);
但是,如何访问测试对象的信息?或者更好的是,我该如何更改它以便我可以使用 getMyPlaylists
来代替?
谢谢
This is how you do it..
SpotifyApi api = new SpotifyApi();
api.setAccessToken(token);
SpotifyService spotify = api.getService();
spotify.getPlaylists("USERID", new Callback<Pager<Playlist>>() {
@Override
public void success(Pager<Playlist> playlistPager, Response response) {
Log.d("TEST", "Got the playlists");
List<Playlist> playlists = playlistPager.items;
for (Playlist p : playlists) {
Log.e("TEST", p.name + " - " + p.id);
}
}
@Override
public void failure(RetrofitError error) {
Log.e("TEST", "Could not get playlists");
}
});
Once you know the playlist ID, you can then fetch the tracks of the playlist with something like this :
spotify.getPlaylistTracks("USERID","PLAYLISTID", new Callback<Pager<PlaylistTrack>>() {
@Override
public void success(Pager<PlaylistTrack> playlistTrackPager, Response response) {
Log.e("TEST", "GOT the tracks in playlist");
List<PlaylistTrack> items = playlistTrackPager.items;
for( PlaylistTrack pt : items){
Log.e("TEST", pt.track.name + " - " + pt.track.id);
}
}
@Override
public void failure(RetrofitError error) {
Log.e("TEST", "Could not get playlist tracks");
}
});
coutesy lunai
https://github.com/spotify/android-sdk/issues/79