Last active
August 7, 2020 12:45
-
-
Save bengongon97/6239dcda5c88f11b9c5569a43044df54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HwAudioStatusListener mPlayListener = new HwAudioStatusListener() { | |
@Override | |
public void onSongChange(HwAudioPlayItem hwAudioPlayItem) { | |
setSongDetails(hwAudioPlayItem); | |
if(mHwAudioPlayerManager.getOffsetTime() != -1 && mHwAudioPlayerManager.getDuration() != -1) | |
updateSeekBar(mHwAudioPlayerManager.getOffsetTime(), mHwAudioPlayerManager.getDuration()); | |
} | |
@Override | |
public void onQueueChanged(List<HwAudioPlayItem> list) { | |
if (mHwAudioPlayerManager != null && list.size() != 0 && !isReallyPlaying) { | |
mHwAudioPlayerManager.play(); | |
isReallyPlaying = true; | |
binding.playButtonImageView.setImageDrawable(getDrawable(R.drawable.btn_playback_pause_normal)); | |
} | |
} | |
@Override | |
public void onBufferProgress(int percent) { | |
} | |
@Override | |
public void onPlayProgress(final long currentPosition, long duration) { | |
updateSeekBar(currentPosition, duration); | |
} | |
@Override | |
public void onPlayCompleted(boolean isStopped) { | |
if (mHwAudioPlayerManager != null && isStopped) { | |
mHwAudioPlayerManager.playNext(); | |
} | |
isReallyPlaying = !isStopped; | |
} | |
@Override | |
public void onPlayError(int errorCode, boolean isUserForcePlay) { | |
Toast.makeText(MainActivity.this, "We cannot play this!!", Toast.LENGTH_LONG).show(); | |
} | |
@Override | |
public void onPlayStateChange(boolean isPlaying, boolean isBuffering) { | |
if(isPlaying || isBuffering){ | |
binding.playButtonImageView.setImageDrawable(getDrawable(R.drawable.btn_playback_pause_normal)); | |
isReallyPlaying = true; | |
} | |
else{ | |
binding.playButtonImageView.setImageDrawable(getDrawable(R.drawable.btn_playback_play_normal)); | |
isReallyPlaying = false; | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment