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!ia0y~yU@!n-4mJh`hH$2z?F&c4~15wnzGl3Js10{4&fH1|sBiC36& zn2sN?*pQIsUs>3DUz>Tt7vUZ3X*HjA+c0=KA7CtC`@*Cz%Ra$`?G5AZ0~wQx<}-N| z9n$?Z=_l*^_mj>sdCX$2W7gKy$>)4fox;9@&CRHAF5`qN{A(D^4;)ed`is%w(wg@Z zOA{8j#?&yxZx7#>Qnw{@TRFr16{`>E8eCOVlWSNXeSJmV6~)5 zvn`kd?;FlyT>0E_TH}iMp-Rl3uAZJ_t?akEZ02bPlXaJGAGp8g_KNv=_a9r`Wyq|$ z&@oBf9T-OXny2O-*f;IHab{z0u><{F%r9PgZn$mOS%! zFhdvf(Z)vy{P{d)F}Nq>r+vR*pq4clZ7j!7*)PD@)oSnEzjP=*x>FX+@&eixJ0mk>6(MS zLpP%KF)%PNc)I$ztaD0e0svH9Z6yEz 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 zcmeAS@N?(olHy`uVBq!ia0y~yU~m9o4mJh`hEg)~E z=jwgA$>?Fle6L}0-{Ta9xUyeevw0hq*gg>4!PZyRr_TIglkt?S%?uMtIBb~9nfufk zKWy5(>f8?I2_@Wn7}ydsdYL|KG7d|*%iv)&bM_tIZ)*QTvjrNa&)s++c6Wn{c0t&S zH4l6vy%{TR&iurv$Dk7Fz4=<2?zvxou6*Thm_B#qx!79^mRv4dvGJjrYQ^XO><3Q! z`F;2{|A~}BCc6c@9iw!1@ifLAIqi!|-=_FZxv3do+rVn6|FY`l$%%tMwlj4!UR&Hn#ZZo@l`H%aL{E!GWT zykdLqvcHMjkkfmQ)#mM*CIjwntfmGy1rcrc)s~Z zg!Qd!?>Cn==CV$CWzMifNISP)W5E_--(Gc*30`Zq{9V{^$bP0l+XkKtGW0v 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!ia0y~yU`POA4mJh`hDS5XEf^S>e|Wk$hE&A8oo(GM;waL( z|68NR8vcL)WoBjOULGG7!5$wGM;8`B9v&9~o-hL;LC1qGH48Q@Xku&Xv_BYQ@WuZJ z|GFzd%DKBY|DExwy6QpMrh_HtcYd!aUbSjX4%#4fjp3Gou%~r$wEi80v{*1ME*L}J&%Z9<& z+jJk>I_BGr_mdevT$%M(M2+{rnLdX3jgvoo5B(L$P?2@D*dmf4t&F>Z=S?P$%u&XQ zEK~M_CmBynzVH3u(j39v5)A%pD>t8C!Z70|=L7fCA(1Q%%de&V^u-VG?wzxqtSRWt?4G z+_3!G1+|#>Eoa}DOt|(f(?0!TaxlZZsBSZ(Uor`4nVyyW6%mVW{E?Mr`fx?-#_0;@ z2{Yd^)iJhvi|x56^I&D@j_HLAGj94mc*!LEHm&yGWCs7Wm!65sH=TLI@PTKCncK#% ziYJ1zkHno)J8*`NNxz|6S#0k-2LH8!)tcN1VJl|dWt+$FGH?5ri!x1jws@Hb)o`p5 zpRv8Fo=HIRAx#Q>wBoB!_U@lM zT@hbC|2dFevUVxch7~J=_t-IXtfWgG0p-4WhAN+g0{-ZAprU}m)78&qol`;+0I&+Z AdH?_b literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxxhdpi/ic_action_av_fast_rewind.png b/app/src/main/res/drawable-xxxhdpi/ic_action_av_fast_rewind.png new file mode 100644 index 0000000000000000000000000000000000000000..5a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`ov}AOgX2VJhNNxq9Ersy4%Z{1V^8m{n$IZSn^SdF#o)c=l#9kia+lXK zyBuLYke~a%j!!UI=CvNP_e)9To{MUY%V&0WWH)Z-)@7M`$(W60F+bz!WlE2lw)OvS z-*!3O4%6$Ud5$fWTcvk7)rE$Y%1IT;Ail>&#xyRz28F@3Fdm%k#Q!yW{f~Lc3<{?A7-|^z>_`{eE4_d@MbozWnc-ch0QrZ4ADyaY zbhh_Dy|L%@Mso)5aJ{8p-blIaT;1Tyc589OcLsT}Dw8!m^L&5GK9xzB`l4gUp1mJm z7e6>9+ate)(dw|1CO8o~9|-#UEMm_4|33wH)SgyM6kxa|<)&$S+bN(Q)@ zmp5zfU(CK>Ztc#JIq#XyEPYawd?NFB0`G<^eoMcsX-*JhC^`11W{J*x{S)TxYpQmn zh%l^rHS?@Wf$YV%sXaRnD&OacdT3hsbJHoKs%e{NhccI(+jA$O$h|r{V%x!!hFQ!Z zS1-3FOk*f%I=@-pe9=C}m`$fQH_le`ul;xL*2owF%;(A$E&Xo2 z#p&M|N^U7UXa4!*<9pXQ@pz|x9)?=2=!eE^4iCfQ9$#djSMfwj;rO5FuZ7Y4lai}T R85kHCJYD@<);T3K0RWe?qbUFY literal 0 HcmV?d00001 diff --git a/app/src/main/res/layout/player_notification.xml b/app/src/main/res/layout/player_notification.xml index 64311e5c6..43ac993ca 100644 --- a/app/src/main/res/layout/player_notification.xml +++ b/app/src/main/res/layout/player_notification.xml @@ -47,6 +47,16 @@ android:text="artist" /> + + + + + \ No newline at end of file