From 51641dcc9abcc0c87d1e8fbb030d149e582558a5 Mon Sep 17 00:00:00 2001 From: Jason John Date: Thu, 16 Jun 2016 09:11:18 -0400 Subject: [PATCH] Added rewind capability to notification control ( seekTo(0) ) --- .../schabi/newpipe/player/BackgroundPlayer.java | 10 ++++++++++ .../drawable-hdpi/ic_action_av_fast_rewind.png | Bin 0 -> 535 bytes .../drawable-mdpi/ic_action_av_fast_rewind.png | Bin 0 -> 282 bytes .../drawable-xhdpi/ic_action_av_fast_rewind.png | Bin 0 -> 591 bytes .../drawable-xxhdpi/ic_action_av_fast_rewind.png | Bin 0 -> 1073 bytes .../ic_action_av_fast_rewind.png | Bin 0 -> 1529 bytes app/src/main/res/layout/player_notification.xml | 10 ++++++++++ .../res/layout/player_notification_expanded.xml | 12 ++++++++++++ 8 files changed, 32 insertions(+) create mode 100644 app/src/main/res/drawable-hdpi/ic_action_av_fast_rewind.png create mode 100644 app/src/main/res/drawable-mdpi/ic_action_av_fast_rewind.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_action_av_fast_rewind.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_action_av_fast_rewind.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_action_av_fast_rewind.png diff --git a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java index 792a35704..41bd4e1ae 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java @@ -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); diff --git a/app/src/main/res/drawable-hdpi/ic_action_av_fast_rewind.png b/app/src/main/res/drawable-hdpi/ic_action_av_fast_rewind.png new file mode 100644 index 0000000000000000000000000000000000000000..8d49992eb9a49f999c5949a13bcf438d5d00077e GIT binary patch literal 535 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezr3(Fy8ZYaSX|Demi}ymx`lE>;Bbx z83_xTIvOQ9J0xaw%;MypJ)=WnRp){kKiiv{k`y>L9Xge_X{ElZT}yt!k|l0!Wpmzb z+m)8H!f*Mzxxdcs{2n$n@bmesef2^P+hu+DRM?qBJybi}@w3o2(fb9#DzAXC$6Sg;uyANbcE}GBeQFKW6 z*QB4U@83^4$K)}KxsF*|S0|tIL3IlI4mLNV!nuqSuJEs6G(T`e{p&AAhf8bTPb^JX z;2KlI5WhWqUrODU%x&ci_gAbwplfhdO--(0ef0Gec~^9q^QyM|zQ>@l^JEdnj!lwh zIy;#aPX7J4PrmdptNR_<5Aqc(&$y4duooEL>)oex|2t#B?p&>f+zBhgRIlii=gziZ z4!mzTi*e<1$7zi#-iInNf4X{ljO#+q zoAZ^}+t^?JYhLyuZFNle&E{pNe5anA%5Z9hXmW0mLffj;A~kkgoNM_2TN-~&}&$W-b)*AVEtufg&4vnD+{qm>Ytg%|C1p` z=3|-rQviws#ew3$PYy_$07qbNX7|uCOVL#KS_4R00%u?h%*^cO1Egp^cai}l4S+4M z1BSrU2T0NQut@-t=D-!0It9J}QZ%8c8UZBrfemn|Eq80Y0f0wL6N)Jsfus>|0@gq; zKwkl@>PVV2!8!SVfQm3{1g_d2?B>(^b literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_action_av_fast_rewind.png b/app/src/main/res/drawable-xhdpi/ic_action_av_fast_rewind.png new file mode 100644 index 0000000000000000000000000000000000000000..1e804aafc8fb491b7e70aceb1671af52dcc55347 GIT binary patch literal 591 zcmV-V0E4=M=&nw; zw`%J3S3lhim9M7q_z3`^fXWF(3REtDD1wm!kph(yh!m(?0MP{^1tJA1ClD!6xd5UI zY&-=d9RMG|d($-ExeD~MvoQdYc7ZG42{;BWnx^?m1>j|8;ddhd+K+w(?ty*aCkKF+ zoi6m*0Z2Ln-hh*i<75C{cKV8&4S=LQ;1Re6j(UzK1Mspllxnj8kaP$<19t-2g~3nVZ~A_9p*TYY>2!ow2}OyMQDsa8~H7;7wUe z0eIP&@&PUYBw0(d)@Civ`ux=O4}h1Qsm@*6prq4wsIlQDC3y4y2f)itPVn}h|$pOggby%4HmrJ2kc(3Y>nOp zJngK4Fbjb8NfzS z5-V+gD4?_xO^qiMkV>qy{h@%;PBb;1P(UiN()Nb}N;}cictQcG#7f&A3MlPFQ{xE* dq!KG_|1UyG5Kv#)Vf_FA002ovPDHLkV1lc;_%Hwf literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_av_fast_rewind.png b/app/src/main/res/drawable-xxhdpi/ic_action_av_fast_rewind.png new file mode 100644 index 0000000000000000000000000000000000000000..a04b8433a11dc0fc664da62739e47b52996d30ba GIT binary patch literal 1073 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7Ro>VE*Ch;uum9_ja~*w}_)i>;7+z z8f*9i0+gARnR|JBSOj}~L>ygM1bKK|1bD&>gajQAy3{P#u%L;psnh;ojKLTGAN=dC z1S#k4-u!pQtLmx;Wt$F`oZtDqrg+t=)z#XMCRhb{UUimtyP?|SU@g!|yl;;3H_Tkikl)Dtv#%`U?Al_Wl^4`v z-nX26V>02|w@mx=i^;(Z^P;-VjDE=^q-AfJGy75O=n(4z8tsAE+oF~kD%T&kM z?k%?GqRfMpp*yA*0^RTX;3bpr+qBw$lYxG^^h{j7>C7934?H`}+%|qyJQ19IB<_^j zfirwe`VHO6VteNS6$w^rawmkXn0c3N9>dGL?O!g+G~L{^zP})&&=&xDLrW%#-G0ly5X<=6cU_ zAUfMY->&$8TkF%e&0AV(SaRM5*61@xI^7a0y!h(k@n0(^v6xI-eZ29z!>`*i-V6noqof#21u~oJnCHw7 z{&R>yBAc$y$K!8+871P-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