1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-24 00:50:32 +00:00

Merge pull request #316 from jaytj95/master

Added rewind capability to notification control
This commit is contained in:
Christian Schabesberger 2016-09-12 00:57:53 +02:00 committed by GitHub
commit 4bba84af8a
8 changed files with 32 additions and 0 deletions

View File

@ -54,6 +54,7 @@ public class BackgroundPlayer extends Service /*implements MediaPlayer.OnPrepare
private static final String TAG = BackgroundPlayer.class.toString();
private static final String ACTION_STOP = TAG + ".STOP";
private static final String ACTION_PLAYPAUSE = TAG + ".PLAYPAUSE";
private static final String ACTION_REWIND = TAG + ".REWIND";
// Extra intent arguments
public static final String TITLE = "title";
@ -179,6 +180,7 @@ public class BackgroundPlayer extends Service /*implements MediaPlayer.OnPrepare
filter.setPriority(Integer.MAX_VALUE);
filter.addAction(ACTION_PLAYPAUSE);
filter.addAction(ACTION_STOP);
filter.addAction(ACTION_REWIND);
registerReceiver(broadcastReceiver, filter);
note = buildNotification();
@ -228,6 +230,10 @@ public class BackgroundPlayer extends Service /*implements MediaPlayer.OnPrepare
noteMgr.notify(noteID, note);
}
}
else if(action.equals(ACTION_REWIND)) {
mediaPlayer.seekTo(0);
// noteMgr.notify(noteID, note);
}
else if(action.equals(ACTION_STOP)) {
//this auto-releases CPU lock
mediaPlayer.stop();
@ -275,6 +281,8 @@ public class BackgroundPlayer extends Service /*implements MediaPlayer.OnPrepare
new Intent(ACTION_PLAYPAUSE), PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent stopPI = PendingIntent.getBroadcast(owner, noteID,
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
(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.setOnClickPendingIntent(R.id.notificationStop, stopPI);
view.setOnClickPendingIntent(R.id.notificationPlayPause, playPI);
view.setOnClickPendingIntent(R.id.notificationRewind, rewindPI);
view.setOnClickPendingIntent(R.id.notificationContent, openDetailView);
//possibly found the expandedView problem,
@ -322,6 +331,7 @@ public class BackgroundPlayer extends Service /*implements MediaPlayer.OnPrepare
expandedView.setTextViewText(R.id.notificationArtist, channelName);
expandedView.setOnClickPendingIntent(R.id.notificationStop, stopPI);
expandedView.setOnClickPendingIntent(R.id.notificationPlayPause, playPI);
expandedView.setOnClickPendingIntent(R.id.notificationRewind, rewindPI);
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

View File

@ -47,6 +47,16 @@
android:text="artist" />
</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
android:id="@+id/notificationPlayPause"
android:layout_width="40dp"

View File

@ -53,6 +53,7 @@
android:scaleType="fitXY"
android:src="@drawable/ic_close_white_24dp" />
<RelativeLayout
android:id="@+id/notificationButtons"
android:layout_width="match_parent"
@ -72,6 +73,17 @@
android:src="@drawable/ic_pause_white_24dp"
android:layout_alignParentTop="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>