From 51641dcc9abcc0c87d1e8fbb030d149e582558a5 Mon Sep 17 00:00:00 2001 From: Jason John <jaytj95@gmail.com> 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?qBJyb<B5(+Ac6e12CU^&_7z}S3v zGV?(pHnkOZ7(Htbuo>i}@w<Lk&y=!Y*E{=WXGY9YhDmCT!U^0z($m~4r6*ot&S5%! zz+yu}ntx?s?|p6N315VFu&330+HJ$&>3o2(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{lj<vGi?y{Mu9Zc3;zJ1{Sp4%(t=iPs7b(bNt>O#+q zoAZ^}+t^?JYhLyuZFNle&E{pNe5anA%5Z9hXmW0mLffj;A~kkgoNM<Q!`+_lGR%DS R&k7jf44$rjF6*2UngHVg=ZXLT literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_action_av_fast_rewind.png b/app/src/main/res/drawable-mdpi/ic_action_av_fast_rewind.png new file mode 100644 index 0000000000000000000000000000000000000000..e280bd470ace00930a78343dea224d9a7bdbb01b GIT binary patch literal 282 zcmV+#0p<RQP)<h;3K|Lk000e1NJLTq001BW001Be1^@s6b9#F80002tNkl<ZSV!%a zF$w}P5JlfuSl9@HM-VKmwAM>_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_<h7QiJkgi%fFA@m^fJwp#9&m!_5@~z^oKe0)hu<NF7 gy#i1iC=L_{Uf@Z3Awre#$^ZZW07*qoM6N<$f>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-V0<iswP)<h;3K|Lk000e1NJLTq002M$002M;1^@s6s%dfF0006ONkl<ZcwX(8 zJxT;Y5JumCMutWPMke0CNDu@A15cr#s2D3AK)r-lGVm52;*)||8Hb&n>E4=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<CCjs!X zv#QRx1CVqJyZ{DaXpI8!vNKj>-2g~3nVZ~A_9p*TYY>2!ow2}OyMQDsa8~H7;7wUe z0eIP&@&PUYBw0(d)@Civ`ux=O4}h1Qsm@*6prq4wsIlQDC3y4y2f)itPVn}h<QgDp z2RH{l0UK*`mI1hIhoW`uWKERWDNsFt1vxM2dfCa5VO9!s9eEWmFFQF9l54;+CtmH# z%T5Xi7Xaq49bj&N2ZupuZ97vTxB=+Y2Aluw9<c5x>|$pOggby%4HmrJ2kc(3Y>nOp zJngK4Fbjb8<LkW+_c}$L4<bDXHY(ToB-Sa8^*)OB)KKTM_*gsI*6*`*fo%np>NfzS 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{UUi<spzu$SrGY`A%t1$<lY=3N z{m7?@G~wQrHQ4<3z};1=-j(mqx-l~@%6l?{u{B!_^S7|jt@$(7-d*?U$}AfOV{g-a zZ0neBH{MTX{BUK~UlBFl184de<~L6M@ICZbAVWpg)nbcChO{#73Z6HaJTgZaE3!=4 z51wQ^G5NmtgG+M+cS|t%udUpCehI^jo172aPlrUZG%UZC_Sc84Vdmab!f*RF0(ER% zyZZ^lr%Cy`{#$atE<4Yzejs?YxAIFFNe1KFoOc-JG2h-LW&_k0)^B&se=38)<`U(v zoEF!&KiJ1$vz6`3BmM(tF1>mtyP?|SU@g!|yl;;3H_Tkikl)Dtv#%`U?Al_Wl^4`v z-nX26V>02|w@mx=i^;(Z^P;-VjDE=^q-A<m@>fJGy75O=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<aWgb++u}XZ#_Nsa&O;OeU z|6z{vqEw|NMIC;9+Qa^tAwoCe$DY&-ui4#U2jh-OHqBzKx+hbaHI?DvHp%p~mlu<& z_Em3t{w{s<dA(@Cyr^!c0_K3(3)Vk7yJH)>{^zP})&&=&xDLrW%#-G0ly5X<=6cU_ zAUfMY->&$8TkF%e&0AV(SaRM5*61@xI^7a0y!h(k@n0(^v6xI-eZ29z!>`*<U+^w4 zQ`wnWnwcWRko8Q3W4g7CwgivE!mDgf^BQJpuACNp;QO>i-V6noqof#21u~oJnCHw7 z{&R>yB<iz+j~e4yCfj)NFITd@Sw=Ecek~IDF-t!6T$b*%hGR(wd{?it&Sa20B=&&0 zKvmq1iy?olWXnnB6}{JAihk8Ua4O=z{DKQWV}FXz+O{ox^{QQ$x9y7f^7+q!^pdqp pnKrCg8NA1ip<^Xo@(3vR)iYH2Boy#RuLBhY44$rjF6*2UngFm0y?Ouu 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..5a9fa3de07de4602439970b8c39ce973e033009a GIT binary patch literal 1529 zcmchX`BRf;5XYbQ&4F^1q$1%aB2_s=AjEJOj3EM!f+%39M2w9H%9SWp3q}&85JxOJ zC@m6!3Xv(73RFUcB#s9+2mud>Ac$y$K!8+871P-NpfjERu)8y#+2`3~cE0DsLW4{U ztqcJGCOd*@d-aj`#a5v8{(=9YP5@A{9kgu`r(;w?pDJXeS(cPTXM}O+X1Fjfw$T8^ zY*z%$47&&G6~TaU?0{Vi3<KVSL=XaWdHhV>>o)$!QroxP{e+j?n^nHtl<dlDx28rU z+<UmCOQFm)s*y<#FpjYR2z)V5%q8(4%x;Q8Vl4xL_4wpb6DD}L3ez}?b_e4t1;eKh z7GMtfP<0P7=ADMeKfDBJ$`*+8G5J4#9`A_3(xF}`!`1vk#?6xlw)ak3;~jcXb_V{S z*1+z7t9eE!ib5pUqxBR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<w+H`@^Nf(! zJ4wq7O0RR9QiZc{muTV)tL<nj)8zI*s7O<Nj%f~3ACI3YcP-h}M#`y96CXAMmG29? z9oe>hs@UA7`)fyy_m2@d+PV(Uw1WDgNJMH+vx0d%C_N$S?)`R;V~B`B`H##3keb<B zzln510x{}3>-k0Nc5^?E4E>f{tZ`2OLr9Mj-;UO<g&(q<H(hWmi~9glhwyI^+KIW@ z?J>B6)I4Lrb&eh*pebYYnAd&a|B|PFBaS+F+1s<E-LmR?y`+O3+e2x!RA%Pim$RcO 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" /> </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" diff --git a/app/src/main/res/layout/player_notification_expanded.xml b/app/src/main/res/layout/player_notification_expanded.xml index cd0ac924f..5a8b3a9d3 100644 --- a/app/src/main/res/layout/player_notification_expanded.xml +++ b/app/src/main/res/layout/player_notification_expanded.xml @@ -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> \ No newline at end of file