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

Java Spotify类代码示例

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

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



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

示例1: onAuthenticationComplete

import com.spotify.sdk.android.player.Spotify; //导入依赖的package包/类
private void onAuthenticationComplete(AuthenticationResponse authResponse, String clientID) {
  Log.d("DEBUG", "Got authentication token");
  if (mPlayer == null) {
    Config playerConfig = new Config(this, authResponse.getAccessToken(), clientID);
    mPlayer = Spotify.getPlayer(playerConfig, this, new SpotifyPlayer.InitializationObserver() {
      @Override
      public void onInitialized(SpotifyPlayer player) {
        Log.d("DEBUG", "-- Player initialized --");
        mPlayer
            .setConnectivityStatus(mOperationCallback, getNetworkConnectivity(MainActivity.this));
        mPlayer.addNotificationCallback(MainActivity.this);
        mPlayer.addConnectionStateCallback(MainActivity.this);
      }

      @Override
      public void onError(Throwable error) {
        Log.d("DEBUG", "Error in initialization: " + error.getMessage());
      }
    });
  } else {
    mPlayer.login(authResponse.getAccessToken());
  }
}
 
开发者ID:tkrworks,项目名称:JinsMemeBRIDGE-Android,代码行数:24,代码来源:MainActivity.java


示例2: initializePlayer

import com.spotify.sdk.android.player.Spotify; //导入依赖的package包/类
private void initializePlayer() {
    SharedPreferences prefsAppData = getSharedPreferences(getString(R.string.sharedpreferences_global), Context.MODE_PRIVATE);
    if (prefsAppData.getInt(getString(R.string.responseType), -1) == AuthenticationResponse.Type.TOKEN.ordinal()) {

        Config config = new Config(
                this,
                prefsAppData.getString(getString(R.string.spotifyAccessToken_value), null),
                prefsAppData.getString(getString(R.string.clientId), null)
        );
        spotifyPlayer = Spotify.getPlayer(config, this, new Player.InitializationObserver() {
            @Override
            public void onInitialized(Player player) {
                player.addConnectionStateCallback(MainActivity.connectionStateCallback);
                player.addPlayerNotificationCallback(TracksActivity.this);
            }

            @Override
            public void onError(Throwable throwable) {
                Log.e("PLAYER", "ERROR: " + throwable.getMessage());
            }
        });

    }
}
 
开发者ID:sharaquss,项目名称:Betterfy,代码行数:25,代码来源:TracksActivity.java


示例3: startPlayer

import com.spotify.sdk.android.player.Spotify; //导入依赖的package包/类
/***
 * @param context
 * @param token                      : Spotify token needed to use the api
 * @param observer                   : used to know when player is ready
 * @param playerNotificationCallback
 * @param connectionStateCallback
 */
public static void startPlayer(final Context context, String token, final Player.InitializationObserver observer, @Nullable final PlayerNotificationCallback playerNotificationCallback, @Nullable final ConnectionStateCallback connectionStateCallback) {
    SpotifyPlayerManager.context = context;
    Config playerConfig = new Config(context, token, SpotifyManager.API_KEY);
    setConnectionStateCallback(connectionStateCallback);
    setPlayerNotificationCallback(playerNotificationCallback);
    Spotify.getPlayer(playerConfig, context, new Player.InitializationObserver() {
        @Override
        public void onInitialized(Player pl) {
            player = pl;
            if (connectionStateCallback != null)
                player.addConnectionStateCallback(SpotifyManager.connectionStateCallback);
            if (playerNotificationCallback != null)
                player.addPlayerNotificationCallback(SpotifyManager.playerNotificationCallback);
            observer.onInitialized(player);
        }

        @Override
        public void onError(Throwable throwable) {
            Log.e(SpotifyManager.class.getSimpleName(), "Could not initialize player: " + throwable.getMessage());
            observer.onError(throwable);

        }
    });
}
 
开发者ID:joxad,项目名称:android-easy-spotify,代码行数:32,代码来源:SpotifyPlayerManager.java


示例4: startSpotifySession

import com.spotify.sdk.android.player.Spotify; //导入依赖的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


示例5: onDestroy

import com.spotify.sdk.android.player.Spotify; //导入依赖的package包/类
@Override
protected void onDestroy() {
    Spotify.destroyPlayer(this);
    super.onDestroy();
}
 
开发者ID:sharaquss,项目名称:Betterfy,代码行数:6,代码来源:TracksActivity.java


示例6: destroy

import com.spotify.sdk.android.player.Spotify; //导入依赖的package包/类
/***
 * Destroy the SpotifyPlayer
 */
public static void destroy() {
    Spotify.destroyPlayer(context);
}
 
开发者ID:joxad,项目名称:android-easy-spotify,代码行数:7,代码来源:SpotifyPlayerManager.java


示例7: initPlayer

import com.spotify.sdk.android.player.Spotify; //导入依赖的package包/类
private Single<Boolean> initPlayer() {
    return Single.create(subscriber -> {

        playerConfig = new Config(SpotiqHostService.this,
            spotifyCommunicatorService.getAuthenticator().getAccessToken(),
            BuildConfig.SPOTIFY_CLIENT_ID);
        playerConfig.useCache(false);

        spotifyPlayer = Spotify.getPlayer(playerConfig, SpotiqHostService.this, new SpotifyPlayer.InitializationObserver() {
            @Override
            public void onInitialized(SpotifyPlayer player) {
                spotifyPlayer.addConnectionStateCallback(SpotiqHostService.this);
                spotifyPlayer.addNotificationCallback(SpotiqHostService.this);
                spotifyPlayer.setPlaybackBitrate(new Player.OperationCallback() {
                    @Override
                    public void onSuccess() {
                        subscriber.onSuccess(true);
                        Log.d(LogTag.LOG_HOST_SERVICE, "Set Spotify Player custom playback bitrate successfully");
                        sendPlayingStatusBroadcast(false); //make sure all listeners are up to sync with an inititally paused status
                        mediaSessionHandler.setSessionActive();
                    }

                    @Override
                    public void onError(Error error) {
                        subscriber.onError(new PlayerInitializationException(error.name()));
                        Log.d(LogTag.LOG_HOST_SERVICE, "Failed to set Spotify Player playback bitrate. Cause: " + error.toString());

                    }
                }, PlaybackBitrate.BITRATE_HIGH);

            }

            @Override
            public void onError(Throwable throwable) {
                subscriber.onError(throwable);
                Log.d(LogTag.LOG_HOST_SERVICE, "Could not initialize Spotify Player: " + throwable.getMessage());
                stopSelf();
            }

        });
    });
}
 
开发者ID:ZinoKader,项目名称:SpotiQ,代码行数:43,代码来源:SpotiqHostService.java


示例8: terminate

import com.spotify.sdk.android.player.Spotify; //导入依赖的package包/类
public void terminate() {
    mediaSessionController.stopNowPlayingSession();
    Spotify.destroyPlayer(mPlayer);
}
 
开发者ID:sregg,项目名称:spotify-tv,代码行数:5,代码来源:SpotifyPlayerController.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java MutableBeanMetadata类代码示例发布时间:2022-05-22
下一篇:
Java PGPPublicKeyRingCollection类代码示例发布时间: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