当前位置: 首页>>代码示例>>Java>>正文


Java SpotifyApi类代码示例

本文整理汇总了Java中kaaes.spotify.webapi.android.SpotifyApi的典型用法代码示例。如果您正苦于以下问题:Java SpotifyApi类的具体用法?Java SpotifyApi怎么用?Java SpotifyApi使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SpotifyApi类属于kaaes.spotify.webapi.android包,在下文中一共展示了SpotifyApi类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startSpotifySession

import kaaes.spotify.webapi.android.SpotifyApi; //导入依赖的package包/类
public void startSpotifySession(final Activity activity, String accessToken, final Runnable onStarted, final Runnable onFailed) {
    // Spotify API
    SpotifyApi api = new SpotifyApi();
    api.setAccessToken(accessToken);
    mSpotifyService = api.getService();

    // Spotify Player Controller
    String clientId = getString(R.string.spotify_client_id);
    Config playerConfig = new Config(this, accessToken, clientId);
    Player player = Spotify.getPlayer(playerConfig, this, null);
    mSpotifyPlayerController = new SpotifyPlayerController(player, mSpotifyService);

    mSpotifyService.getMe(new Callback<UserPrivate>() {
        @Override
        public void success(UserPrivate user, Response response) {
            saveCurrentUser(user);
            activity.runOnUiThread(onStarted);
        }

        @Override
        public void failure(RetrofitError error) {
            activity.runOnUiThread(onFailed);
        }
    });
}
 
开发者ID:sregg,项目名称:spotify-tv,代码行数:26,代码来源:SpotifyTvApplication.java

示例2: doInBackground

import kaaes.spotify.webapi.android.SpotifyApi; //导入依赖的package包/类
@Override
protected AsyncTaskResult<List<Track>> doInBackground(Artist... params) {
    try {
        Map<String, Object> options = new HashMap<>();
        options.put(SpotifyService.COUNTRY, Locale.getDefault().getCountry());
        Tracks artistTopTracks = new SpotifyApi().getService().getArtistTopTrack(params[0].getId(), options);

        List<Track> trackList = new ArrayList<>();
        for(kaaes.spotify.webapi.android.models.Track track : artistTopTracks.tracks) {
            trackList.add(new Track(track));
        }

        return new AsyncTaskResult<>(trackList);

    } catch (RetrofitError error) {
        if(error.getResponse() == null) {
            return new AsyncTaskResult<>(new NotFoundException());
        } else {
            switch(error.getResponse().getStatus()) {
                case HttpURLConnection.HTTP_BAD_REQUEST:
                    return new AsyncTaskResult<>(new BadRequestException());
                case HttpURLConnection.HTTP_NOT_FOUND:
                    return new AsyncTaskResult<>(new NotFoundException());
                default:
                    return new AsyncTaskResult<>(error);
            }
        }
    }
}
 
开发者ID:tassioauad,项目名称:SpotifyStreamer,代码行数:30,代码来源:TrackListTopByArtistAsyncTask.java

示例3: getSpotifyService

import kaaes.spotify.webapi.android.SpotifyApi; //导入依赖的package包/类
/**
 * Return a SpotifyService object.
 * @return a SpotifyService object
 */
private SpotifyService getSpotifyService() {
    SpotifyApi spotifyApi = new SpotifyApi();

    // Most (but not all) of the Spotify Web API endpoints require authorisation.
    // The ones that require authorisation need the following step:
    //spotifyApi.setAccessToken("myAccessToken");

    return spotifyApi.getService();
}
 
开发者ID:edmundjohnson,项目名称:nd-spotify,代码行数:14,代码来源:ArtistListFragment.java

示例4: doInBackground

import kaaes.spotify.webapi.android.SpotifyApi; //导入依赖的package包/类
@Override
protected Void doInBackground(Void... strings) {
    SpotifyApi api = new SpotifyApi();
    SpotifyService service = api.getService();

    ArtistsPager results = service.searchArtists("Paul");
    List<Artist> artists = results.artists.items;
    for (int i = 0; i < artists.size(); i++) {
        Artist artist = artists.get(i);
        Log.i(LOG_TAG, i + " " + artist.name);
    }
    return null;
}
 
开发者ID:udacity,项目名称:android-web-api-sample,代码行数:14,代码来源:MainActivity.java

示例5: doInBackground

import kaaes.spotify.webapi.android.SpotifyApi; //导入依赖的package包/类
@Override
protected AsyncTaskResult<List<Artist>> doInBackground(String... params) {
    SpotifyService spotifyService = new SpotifyApi().getService();

    try {
        ArtistsPager results = spotifyService.searchArtists(params[0]);

        List<Artist> artistList = new ArrayList<>();
        for (kaaes.spotify.webapi.android.models.Artist spotifyWebApiArtist : results.artists.items) {
            artistList.add(new Artist(spotifyWebApiArtist));
        }

        return new AsyncTaskResult<>(artistList);

    } catch (RetrofitError error) {
        if(error.getResponse() == null) {
            return new AsyncTaskResult<>(new NotFoundException());
        } else {
            switch(error.getResponse().getStatus()) {
                case HttpURLConnection.HTTP_BAD_REQUEST:
                    return new AsyncTaskResult<>(new BadRequestException());
                case HttpURLConnection.HTTP_NOT_FOUND:
                    return new AsyncTaskResult<>(new NotFoundException());
                default:
                    return new AsyncTaskResult<>(error);
            }
        }
    }


}
 
开发者ID:tassioauad,项目名称:SpotifyStreamer,代码行数:32,代码来源:ArtistFindByNameAsyncTask.java

示例6: provideSpotifyApi

import kaaes.spotify.webapi.android.SpotifyApi; //导入依赖的package包/类
@Provides
@Singleton
SpotifyApi provideSpotifyApi() {
    return new SpotifyApi();
}
 
开发者ID:ZinoKader,项目名称:SpotiQ,代码行数:6,代码来源:AppModule.java


注:本文中的kaaes.spotify.webapi.android.SpotifyApi类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。