[Android] Audio player: add a play pause button to the header

Adrien Maglo git at videolan.org
Wed Jan 15 16:53:29 CET 2014


vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Wed Jan 15 16:51:40 2014 +0100| [cfeac8cc97ed4b23d01ed8558c92aa30d5c94e46] | committer: Adrien Maglo

Audio player: add a play pause button to the header

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=cfeac8cc97ed4b23d01ed8558c92aa30d5c94e46
---

 vlc-android/res/layout/audio_player.xml            |   21 +++++++++++++++++---
 .../org/videolan/vlc/widget/AudioMiniPlayer.java   |   12 +++++++++++
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/vlc-android/res/layout/audio_player.xml b/vlc-android/res/layout/audio_player.xml
index 23b470a..5aef619 100644
--- a/vlc-android/res/layout/audio_player.xml
+++ b/vlc-android/res/layout/audio_player.xml
@@ -31,15 +31,30 @@
 
         <ImageButton
             android:id="@+id/adv_function"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
+            android:layout_width="40dp"
+            android:layout_height="40dp"
             android:layout_gravity="center"
             android:layout_weight="0"
             android:background="#00000000"
             android:focusable="true"
-            android:padding="10dip"
             android:scaleType="fitXY"
             android:src="@drawable/dots_dark" />
+
+        <ImageButton
+            android:id="@+id/header_play_pause"
+            android:layout_width="40dp"
+            android:layout_height="40dp"
+            android:layout_gravity="center"
+            android:background="#00000000"
+            android:contentDescription="@string/pause"
+            android:focusable="true"
+            android:scaleType="fitXY"
+            android:src="@drawable/ic_pause" />
+
+        <View
+            android:layout_width="10dp"
+            android:layout_height="match_parent" />
+
     </LinearLayout>
 
 	<ViewSwitcher
diff --git a/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java b/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java
index d359cd1..1171a75 100644
--- a/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java
@@ -63,6 +63,7 @@ public class AudioMiniPlayer extends Fragment implements IAudioPlayer {
     private TextView mTime;
     private TextView mLength;
     private ImageButton mPlayPause;
+    private ImageButton mHeaderPlayPause;
     private ImageButton mStop;
     private ImageButton mNext;
     private ImageButton mPrevious;
@@ -100,6 +101,7 @@ public class AudioMiniPlayer extends Fragment implements IAudioPlayer {
         mTime = (TextView) v.findViewById(R.id.time);
         mLength = (TextView) v.findViewById(R.id.length);
         mPlayPause = (ImageButton) v.findViewById(R.id.play_pause);
+        mHeaderPlayPause = (ImageButton) v.findViewById(R.id.header_play_pause);
         mStop = (ImageButton) v.findViewById(R.id.stop);
         mNext = (ImageButton) v.findViewById(R.id.next);
         mPrevious = (ImageButton) v.findViewById(R.id.previous);
@@ -128,6 +130,12 @@ public class AudioMiniPlayer extends Fragment implements IAudioPlayer {
                 onPlayPauseClick(v);
             }
         });
+        mHeaderPlayPause.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                onPlayPauseClick(v);
+            }
+        });
         mStop.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
@@ -237,9 +245,13 @@ public class AudioMiniPlayer extends Fragment implements IAudioPlayer {
         if (mAudioController.isPlaying()) {
             mPlayPause.setImageResource(R.drawable.ic_pause);
             mPlayPause.setContentDescription(getString(R.string.pause));
+            mHeaderPlayPause.setImageResource(R.drawable.ic_pause);
+            mHeaderPlayPause.setContentDescription(getString(R.string.pause));
         } else {
             mPlayPause.setImageResource(R.drawable.ic_play);
             mPlayPause.setContentDescription(getString(R.string.play));
+            mHeaderPlayPause.setImageResource(R.drawable.ic_play);
+            mHeaderPlayPause.setContentDescription(getString(R.string.play));
         }
         if (mAudioController.isShuffling()) {
             mShuffle.setImageResource(R.drawable.ic_shuffle_glow);



More information about the Android mailing list