Added rewind capability to notification control ( seekTo(0) )
This commit is contained in:
parent
54c32b9fe2
commit
51641dcc9a
|
@ -54,6 +54,7 @@ public class BackgroundPlayer extends Service /*implements MediaPlayer.OnPrepare
|
||||||
private static final String TAG = BackgroundPlayer.class.toString();
|
private static final String TAG = BackgroundPlayer.class.toString();
|
||||||
private static final String ACTION_STOP = TAG + ".STOP";
|
private static final String ACTION_STOP = TAG + ".STOP";
|
||||||
private static final String ACTION_PLAYPAUSE = TAG + ".PLAYPAUSE";
|
private static final String ACTION_PLAYPAUSE = TAG + ".PLAYPAUSE";
|
||||||
|
private static final String ACTION_REWIND = TAG + ".REWIND";
|
||||||
|
|
||||||
// Extra intent arguments
|
// Extra intent arguments
|
||||||
public static final String TITLE = "title";
|
public static final String TITLE = "title";
|
||||||
|
@ -179,6 +180,7 @@ public class BackgroundPlayer extends Service /*implements MediaPlayer.OnPrepare
|
||||||
filter.setPriority(Integer.MAX_VALUE);
|
filter.setPriority(Integer.MAX_VALUE);
|
||||||
filter.addAction(ACTION_PLAYPAUSE);
|
filter.addAction(ACTION_PLAYPAUSE);
|
||||||
filter.addAction(ACTION_STOP);
|
filter.addAction(ACTION_STOP);
|
||||||
|
filter.addAction(ACTION_REWIND);
|
||||||
registerReceiver(broadcastReceiver, filter);
|
registerReceiver(broadcastReceiver, filter);
|
||||||
|
|
||||||
note = buildNotification();
|
note = buildNotification();
|
||||||
|
@ -228,6 +230,10 @@ public class BackgroundPlayer extends Service /*implements MediaPlayer.OnPrepare
|
||||||
noteMgr.notify(noteID, note);
|
noteMgr.notify(noteID, note);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(action.equals(ACTION_REWIND)) {
|
||||||
|
mediaPlayer.seekTo(0);
|
||||||
|
// noteMgr.notify(noteID, note);
|
||||||
|
}
|
||||||
else if(action.equals(ACTION_STOP)) {
|
else if(action.equals(ACTION_STOP)) {
|
||||||
//this auto-releases CPU lock
|
//this auto-releases CPU lock
|
||||||
mediaPlayer.stop();
|
mediaPlayer.stop();
|
||||||
|
@ -275,6 +281,8 @@ public class BackgroundPlayer extends Service /*implements MediaPlayer.OnPrepare
|
||||||
new Intent(ACTION_PLAYPAUSE), PendingIntent.FLAG_UPDATE_CURRENT);
|
new Intent(ACTION_PLAYPAUSE), PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
PendingIntent stopPI = PendingIntent.getBroadcast(owner, noteID,
|
PendingIntent stopPI = PendingIntent.getBroadcast(owner, noteID,
|
||||||
new Intent(ACTION_STOP), PendingIntent.FLAG_UPDATE_CURRENT);
|
new Intent(ACTION_STOP), PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
PendingIntent rewindPI = PendingIntent.getBroadcast(owner, noteID,
|
||||||
|
new Intent(ACTION_REWIND), PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
/*
|
/*
|
||||||
NotificationCompat.Action pauseButton = new NotificationCompat.Action.Builder
|
NotificationCompat.Action pauseButton = new NotificationCompat.Action.Builder
|
||||||
(R.drawable.ic_pause_white_24dp, "Pause", playPI).build();
|
(R.drawable.ic_pause_white_24dp, "Pause", playPI).build();
|
||||||
|
@ -311,6 +319,7 @@ public class BackgroundPlayer extends Service /*implements MediaPlayer.OnPrepare
|
||||||
view.setTextViewText(R.id.notificationArtist, channelName);
|
view.setTextViewText(R.id.notificationArtist, channelName);
|
||||||
view.setOnClickPendingIntent(R.id.notificationStop, stopPI);
|
view.setOnClickPendingIntent(R.id.notificationStop, stopPI);
|
||||||
view.setOnClickPendingIntent(R.id.notificationPlayPause, playPI);
|
view.setOnClickPendingIntent(R.id.notificationPlayPause, playPI);
|
||||||
|
view.setOnClickPendingIntent(R.id.notificationRewind, rewindPI);
|
||||||
view.setOnClickPendingIntent(R.id.notificationContent, openDetailView);
|
view.setOnClickPendingIntent(R.id.notificationContent, openDetailView);
|
||||||
|
|
||||||
//possibly found the expandedView problem,
|
//possibly found the expandedView problem,
|
||||||
|
@ -322,6 +331,7 @@ public class BackgroundPlayer extends Service /*implements MediaPlayer.OnPrepare
|
||||||
expandedView.setTextViewText(R.id.notificationArtist, channelName);
|
expandedView.setTextViewText(R.id.notificationArtist, channelName);
|
||||||
expandedView.setOnClickPendingIntent(R.id.notificationStop, stopPI);
|
expandedView.setOnClickPendingIntent(R.id.notificationStop, stopPI);
|
||||||
expandedView.setOnClickPendingIntent(R.id.notificationPlayPause, playPI);
|
expandedView.setOnClickPendingIntent(R.id.notificationPlayPause, playPI);
|
||||||
|
expandedView.setOnClickPendingIntent(R.id.notificationRewind, rewindPI);
|
||||||
expandedView.setOnClickPendingIntent(R.id.notificationContent, openDetailView);
|
expandedView.setOnClickPendingIntent(R.id.notificationContent, openDetailView);
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 535 B |
Binary file not shown.
After Width: | Height: | Size: 282 B |
Binary file not shown.
After Width: | Height: | Size: 591 B |
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
|
@ -47,6 +47,16 @@
|
||||||
android:text="artist" />
|
android:text="artist" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/notificationRewind"
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:layout_margin="5dp"
|
||||||
|
android:background="#00ffffff"
|
||||||
|
android:clickable="true"
|
||||||
|
android:scaleType="fitXY"
|
||||||
|
android:src="@drawable/ic_action_av_fast_rewind" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/notificationPlayPause"
|
android:id="@+id/notificationPlayPause"
|
||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
android:scaleType="fitXY"
|
android:scaleType="fitXY"
|
||||||
android:src="@drawable/ic_close_white_24dp" />
|
android:src="@drawable/ic_close_white_24dp" />
|
||||||
|
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/notificationButtons"
|
android:id="@+id/notificationButtons"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -72,6 +73,17 @@
|
||||||
android:src="@drawable/ic_pause_white_24dp"
|
android:src="@drawable/ic_pause_white_24dp"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_centerHorizontal="true" />
|
android:layout_centerHorizontal="true" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/notificationRewind"
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:background="#00ffffff"
|
||||||
|
android:clickable="true"
|
||||||
|
android:scaleType="fitXY"
|
||||||
|
android:src="@drawable/ic_action_av_fast_rewind"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_alignParentLeft="true" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
Loading…
Reference in New Issue