mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-01 17:58:29 +00:00
Repeat button working.
This commit is contained in:
parent
821a17eb8c
commit
13567caf8d
@ -46,8 +46,15 @@ public class PlayerControl extends Activity implements OnTrackUpdateListener {
|
||||
pauseButton.setOnClickListener(this.onPauseClick);
|
||||
ImageButton prevButton = (ImageButton)findViewById(R.id.MediaPrev);
|
||||
prevButton.setOnClickListener(this.onPrevClick);
|
||||
|
||||
ImageButton repeatButton = (ImageButton)findViewById(R.id.MediaRepeat);
|
||||
repeatButton.setOnClickListener(this.onRepeatClick);
|
||||
ImageButton shuffleButton = (ImageButton)findViewById(R.id.MediaShuffle);
|
||||
shuffleButton.setOnClickListener(this.onShuffleClick);
|
||||
|
||||
this.callbackTrackPositionsUpdateHandler.postDelayed(callbackTrackPositionsUpdateRunnable,500);
|
||||
|
||||
this.SetImages();
|
||||
}
|
||||
|
||||
private OnClickListener onNextClick = new OnClickListener() {
|
||||
@ -71,6 +78,38 @@ public class PlayerControl extends Activity implements OnTrackUpdateListener {
|
||||
startService(intent);
|
||||
}
|
||||
};
|
||||
|
||||
private void SetImages(){
|
||||
Player player = Player.GetInstance();
|
||||
ImageButton button = (ImageButton)findViewById(R.id.MediaRepeat);
|
||||
if(player.GetRepeat()){
|
||||
button.setImageDrawable(getResources().getDrawable(R.drawable.ic_repeat_on));
|
||||
}else{
|
||||
button.setImageDrawable(getResources().getDrawable(R.drawable.ic_repeat));
|
||||
}
|
||||
button = (ImageButton)findViewById(R.id.MediaShuffle);
|
||||
if(player.GetShuffle()){
|
||||
button.setImageDrawable(getResources().getDrawable(R.drawable.ic_shuffle_on));
|
||||
}else{
|
||||
button.setImageDrawable(getResources().getDrawable(R.drawable.ic_shuffle));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private OnClickListener onRepeatClick = new OnClickListener() {
|
||||
public void onClick(View v){
|
||||
Player player = Player.GetInstance();
|
||||
player.SetRepeat(!player.GetRepeat());
|
||||
PlayerControl.this.SetImages();
|
||||
}
|
||||
};
|
||||
private OnClickListener onShuffleClick = new OnClickListener() {
|
||||
public void onClick(View v){
|
||||
Player player = Player.GetInstance();
|
||||
player.SetShuffle(!player.GetShuffle());
|
||||
PlayerControl.this.SetImages();
|
||||
}
|
||||
};
|
||||
|
||||
public void OnTrackBufferUpdate(int percent) {
|
||||
this.callbackTrackPositionsUpdateHandler.post(this.callbackTrackPositionsUpdateRunnable);
|
||||
|
@ -10,7 +10,10 @@ public class Player implements TrackPlayer.OnTrackStatusListener, OnQueryResultL
|
||||
|
||||
private ArrayList<Integer> nowPlaying = new ArrayList<Integer>();
|
||||
private int position = 0;
|
||||
|
||||
private boolean repeat = false;
|
||||
private boolean shuffle = false;
|
||||
|
||||
private Library library;
|
||||
|
||||
private java.lang.Object lock = new java.lang.Object();
|
||||
@ -366,4 +369,25 @@ public class Player implements TrackPlayer.OnTrackStatusListener, OnQueryResultL
|
||||
}
|
||||
}
|
||||
|
||||
public void SetRepeat(boolean repeat){
|
||||
synchronized(this.lock){
|
||||
this.repeat = repeat;
|
||||
}
|
||||
}
|
||||
public boolean GetRepeat(){
|
||||
synchronized(this.lock){
|
||||
return this.repeat;
|
||||
}
|
||||
}
|
||||
public void SetShuffle(boolean shuffle){
|
||||
synchronized(this.lock){
|
||||
this.shuffle = shuffle;
|
||||
}
|
||||
}
|
||||
public boolean GetShuffle(){
|
||||
synchronized(this.lock){
|
||||
return this.shuffle;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user