gpt4 book ai didi

java - 从寻呼机对象访问播放列表列表

转载 作者:行者123 更新时间:2023-11-30 01:36:02 25 4
gpt4 key购买 nike

我在从网络 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

关于java - 从寻呼机对象访问播放列表列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35110025/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com