Commit dfaa4ef8 authored by John Mooring's avatar John Mooring Committed by Sébastien Toque

Added next and previous to mini player.

Signed-off-by: Sébastien Toque's avatarSébastien Toque <xilasz@gmail.com>
parent c227fb64
......@@ -36,7 +36,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title"
android:textSize="20dip"
android:textSize="16dip"
android:textColor="#ffffff"
android:singleLine="true" />
<TextView
......@@ -44,18 +44,31 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/artist"
android:textSize="16dip"
android:textSize="14dip"
android:textColor="#888888"
android:singleLine="true" />
</LinearLayout>
<ImageButton
android:id="@+id/backward"
android:src="@drawable/ic_backward"
android:background="#00ffffff"
android:scaleType="fitXY"
android:layout_width="30dip"
android:layout_height="60dip"/>
<ImageButton
android:id="@+id/play_pause"
android:src="@drawable/ic_pause"
android:background="#00ffffff"
android:scaleType="fitXY"
android:layout_width="60dip"
android:layout_height="60dip"/>
<ImageButton
android:id="@+id/forward"
android:src="@drawable/ic_forward"
android:background="#00ffffff"
android:scaleType="fitXY"
android:layout_width="30dip"
android:layout_height="60dip"
android:padding="10dip"
android:layout_marginRight="10dip" />
android:layout_marginRight="10dip"/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......@@ -28,18 +28,26 @@ public class AudioMiniPlayer extends LinearLayout implements AudioPlayer {
private TextView mTitle;
private TextView mArtist;
private ImageButton mPlayPause;
private ImageButton mForward;
private ImageButton mBackward;
private ImageView mCover;
private SeekBar mSeekbar;
// Listener for the play and pause buttons
private OnClickListener onPlayPauseClickListener = new OnClickListener() {
private OnClickListener onMediaControlClickListener = new OnClickListener() {
@Override
public void onClick(View v) {
if (mAudioPlayerControl != null) {
if (mAudioPlayerControl.isPlaying()) {
mAudioPlayerControl.pause();
} else {
mAudioPlayerControl.play();
if (v == mPlayPause) {
if (mAudioPlayerControl.isPlaying()) {
mAudioPlayerControl.pause();
} else {
mAudioPlayerControl.play();
}
} else if (v == mForward) {
mAudioPlayerControl.next();
} else if (v == mBackward) {
mAudioPlayerControl.previous();
}
}
update();
......@@ -69,7 +77,11 @@ public class AudioMiniPlayer extends LinearLayout implements AudioPlayer {
mTitle = (TextView) findViewById(R.id.title);
mArtist = (TextView) findViewById(R.id.artist);
mPlayPause = (ImageButton) findViewById(R.id.play_pause);
mPlayPause.setOnClickListener(onPlayPauseClickListener);
mForward = (ImageButton) findViewById(R.id.forward);
mBackward = (ImageButton) findViewById(R.id.backward);
mPlayPause.setOnClickListener(onMediaControlClickListener);
mForward.setOnClickListener(onMediaControlClickListener);
mBackward.setOnClickListener(onMediaControlClickListener);
mSeekbar = (SeekBar) findViewById(R.id.timeline);
this.setOnClickListener(new OnClickListener() {
......@@ -140,6 +152,14 @@ public class AudioMiniPlayer extends LinearLayout implements AudioPlayer {
} else {
mPlayPause.setImageResource(R.drawable.ic_play);
}
if (mAudioPlayerControl.hasNext())
mForward.setVisibility(ImageButton.VISIBLE);
else
mForward.setVisibility(ImageButton.INVISIBLE);
if (mAudioPlayerControl.hasPrevious())
mBackward.setVisibility(ImageButton.VISIBLE);
else
mBackward.setVisibility(ImageButton.INVISIBLE);
int time = (int) mAudioPlayerControl.getTime();
int length = (int) mAudioPlayerControl.getLength();
// Update all view elements
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment