Solved

How can I play more than 30 seconds of a track using Deezer API for Android

  • 5 January 2019
  • 1 reply
  • 277 views

Hello community.

I am developing an Android App using the Deezer API. This app goal is to play tracks using Deezer API.

First I was playing tracks using this code:

code:
DeezerConnect deezerConnect = DeezerConnect.forApp(getString(R.string.app_id))
.withContext(this)
.build();

TrackPlayer trackPlayer = null;
try {
trackPlayer = new TrackPlayer(getApplication(), deezerConnect, new WifiAndMobileNetworkStateChecker());
} catch (TooManyPlayersExceptions tooManyPlayersExceptions) {
tooManyPlayersExceptions.printStackTrace();
} catch (DeezerError deezerError) {
deezerError.printStackTrace();
}

long trackId = Long.parseLong(getString(R.string.track_id));
trackPlayer.playTrack(trackId);



Then, each track was played only by 30 seconds. But I need my app to play the whole track.

So I read this link. Is says:

User levels

In the territories where Deezer is already available, we manage 4 kinds of end-users.
  • Unlogged users :
Users who are not registered or logged in on the Deezer service.
Cannot add a radio/album/artist as a favorite.
Cannot create a playlist.
30s clips listening restrictions.

  • Freemium users :
Users with a free Deezer account.
Can add a radio/album/artist as a favorite.
Can create a playlist.
30s clips listening restrictions.

  • Premium users :
Users who suscribed a paid account (learn more).
Can add a radio/album/artist as a favorite.
Can create a playlist.
Unlimited listening in HQ.

  • Premium+ users :
Users who suscribed a paid account (learn more).
Can add a radio/album/artist as a favorite.
Can create a playlist.
Unlimited listening in HQ.
Mobile access.

Well, I thought: I am not performing login in my app so this put in the "Unlogged Users" shelf.

Then I implemented the login:

code:
private void login() {
// Replace with your own Application ID.
DeezerConnect deezerConnect = new DeezerConnect(this, getString(R.string.app_id));

// The set of Deezer Permissions needed by the app.
String[] permissions = new String[] {
Permissions.BASIC_ACCESS, Permissions.OFFLINE_ACCESS, Permissions.EMAIL,
Permissions.MANAGE_COMMUNITY, Permissions.MANAGE_LIBRARY, Permissions.LISTENING_HISTORY };

// The listener for authentication events.
DialogListener listener = new DialogListener() {
public void onComplete(Bundle values) {
Log.d(TAG,"Login completed!");
playTrack();
}

public void onCancel() {
Log.d(TAG,"Login cancelled!");
}

public void onException(Exception e) {
Log.d(TAG,"Login with exception: " + e.getMessage());
}
};

// Launches the authentication process
deezerConnect.authorize(this, permissions, listener);
}



Then a dialog for login opens. Okay, I logged. And I have a Deezer Premium account.

But unfortunately, the tracks don't play anymore!!

Does anyone knows why this is happening?
icon

Best answer by Flo.Deezer 8 January 2019, 16:05

Hi there, unfortunately we are not able to provide help here directly. Please find more information and help for this here: https://developers.deezer.com/support
View original

1 reply

Userlevel 7
Badge +5
Hi there, unfortunately we are not able to provide help here directly. Please find more information and help for this here: https://developers.deezer.com/support

Reply