• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SpotifyApi类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PooledDataSourceFactory类代码示例发布时间:2022-05-22
下一篇:
Java Header类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap