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