I'm currently working on an Android music player that can play songs from multiple web platforms. I have a problem with Deezer : when i play a music, it starts well but all the application interface starts to lag and freeze and if i pause/play the song, it starts to do like an old CD that is unreadable... (Resulting on an horrible song quality with scratches ...)
I'm using Deezer SDK for Android. You can find my code on GitHub : https://github.com/Valou3433/blade-player
I really don't understand what i'm doing wrong, as i'm just calling deezer's TrackPlayer.playTrack(),play() and pause() methods...
Thanks for your help !
Recently, I also faced a similar issue:
After spending almost half day on debugging and finding the solution,
I noticed that the callback function : onPlayerStateChange
is sometimes getting called from another thread instead of main
thread.
I added my code to execute on
main
thread, and voila, it worked.
I made following change:
deezerPlayer.addOnPlayerStateChangeListener(new OnPlayerStateChangeListener()
{
@Override
public void onPlayerStateChange(PlayerState playerState, long l)
{
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
// my code here
}
});
}
});
Hope it works for you too!