This file contains hidden or 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
protected void onCreate(Bundle savedInstanceState) { | |
//... your other codes | |
final Drawable shuffleDrawable = getDrawable(R.drawable.menu_shuffle_normal); | |
final Drawable orderDrawable = getDrawable(R.drawable.menu_order_normal); | |
final Drawable loopItself = getDrawable(R.drawable.menu_loop_one_normal); | |
final Drawable loopPlaylist = getDrawable(R.drawable.menu_loop_normal); | |
binding.shuffleButtonImageView.setOnClickListener(new View.OnClickListener() { |
This file contains hidden or 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
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
//... your other codes | |
binding.containerLayout.setVisibility(View.GONE); | |
binding.playlistImageView.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { |
This file contains hidden or 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
@Override | |
public void onItemClick(List<HwAudioPlayItem> myPlayList, int position) { | |
if (mHwAudioPlayerManager != null && mHwAudioQueueManager != null && mHwAudioQueueManager.getAllPlaylist() != null) { | |
/* | |
* 1. Obtains a playlist using the mHwAudioQueueManager.getAllPlaylist() method. | |
* 2. Compare myPlayList with mHwAudioQueueManager. | |
*/ | |
if (mHwAudioQueueManager.getAllPlaylist() == myPlayList) { | |
//If the two playlists are the same, the user-specified song is played. | |
mHwAudioPlayerManager.play(position); |
This file contains hidden or 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
public class PlaylistAdapter extends RecyclerView.Adapter<PlaylistAdapter.PlayListView> { | |
public interface OnItemClickListener { | |
void onItemClick (List<HwAudioPlayItem> myPlayList, int position); | |
} | |
private PlaylistAdapter.OnItemClickListener onItemClickListener; | |
List<HwAudioPlayItem> myPlayList; | |
public PlaylistAdapter(List<HwAudioPlayItem> myPlayList){ |
This file contains hidden or 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
public void updateSeekBar(final long currentPosition, long duration){ | |
//seekbar | |
binding.musicSeekBar.setMax((int) (duration / 1000)); | |
if(mHwAudioPlayerManager != null){ | |
int mCurrentPosition = (int) (currentPosition / 1000); | |
binding.musicSeekBar.setProgress(mCurrentPosition); | |
setProgressText(mCurrentPosition); | |
} |
This file contains hidden or 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) { |
This file contains hidden or 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
final Drawable drawablePlay = getDrawable(R.drawable.btn_playback_play_normal); | |
final Drawable drawablePause = getDrawable(R.drawable.btn_playback_pause_normal); | |
binding.playButtonImageView.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
if(binding.playButtonImageView.getDrawable().getConstantState().equals(drawablePlay.getConstantState())){ | |
if (mHwAudioPlayerManager != null){ | |
mHwAudioPlayerManager.play(); | |
binding.playButtonImageView.setImageDrawable(getDrawable(R.drawable.btn_playback_pause_normal)); |
This file contains hidden or 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
public void addListener(HwAudioStatusListener listener) { | |
if (mHwAudioManager != null) { | |
try { | |
mHwAudioManager.addPlayerStatusListener(listener); | |
} catch (RemoteException e) { | |
Log.e("TAG", "TAG", e); | |
} | |
} else { | |
mTempListeners.add(listener); | |
} |
This file contains hidden or 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
private List<HwAudioStatusListener> mTempListeners = new CopyOnWriteArrayList<>(); //a global variable | |
private void doListenersAndNotifications(final Context context) { | |
new Handler(Looper.getMainLooper()).post(new Runnable() { | |
@Override | |
public void run() { | |
for (HwAudioStatusListener listener : mTempListeners) { | |
try { | |
mHwAudioManager.addPlayerStatusListener(listener); | |
} catch (RemoteException e) { |
This file contains hidden or 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
public List<HwAudioPlayItem> getLocalPlayList(Context context) { | |
List<HwAudioPlayItem> playItemList = new ArrayList<>(); | |
Cursor cursor = null; | |
try { | |
ContentResolver contentResolver = context.getContentResolver(); | |
if (contentResolver == null) { | |
return playItemList; | |
} | |
String selection = MediaStore.Audio.Media.IS_MUSIC + "!=0"; |
NewerOlder