[Android] Audio player: add a progress bar to the mini player

Adrien Maglo git at videolan.org
Fri Jan 17 16:46:05 CET 2014


vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Fri Jan 17 16:37:03 2014 +0100| [dc14f86332221594b32c82d0b2c8c723fdd2c45a] | committer: Adrien Maglo

Audio player: add a progress bar to the mini player

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

 vlc-android/res/drawable/progress_mini_player.xml      |   16 ++++++++++++++++
 vlc-android/res/layout/audio_player.xml                |   14 ++++++++++++++
 .../src/org/videolan/vlc/widget/AudioMiniPlayer.java   |    6 ++++++
 3 files changed, 36 insertions(+)

diff --git a/vlc-android/res/drawable/progress_mini_player.xml b/vlc-android/res/drawable/progress_mini_player.xml
new file mode 100644
index 0000000..54d39de
--- /dev/null
+++ b/vlc-android/res/drawable/progress_mini_player.xml
@@ -0,0 +1,16 @@
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item android:id="@android:id/background">
+        <shape>
+            <solid android:color="#00000000" />
+        </shape>
+    </item>
+    <item android:id="@android:id/progress">
+        <clip>
+            <shape>
+                <solid android:color="@color/darkorange" />
+            </shape>
+        </clip>
+    </item>
+
+</layer-list>
\ No newline at end of file
diff --git a/vlc-android/res/layout/audio_player.xml b/vlc-android/res/layout/audio_player.xml
index 79ae9a6..06a5a0e 100644
--- a/vlc-android/res/layout/audio_player.xml
+++ b/vlc-android/res/layout/audio_player.xml
@@ -5,6 +5,20 @@
     android:background="?attr/background_player"
     android:orientation="vertical" >
 
+    <ProgressBar
+        android:id="@+id/progressBar"
+        style="@android:style/Widget.ProgressBar.Horizontal"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:layout_weight="0"
+        android:focusable="false"
+        android:indeterminate="false"
+        android:maxHeight="2dip"
+        android:minHeight="2dip"
+        android:paddingLeft="0px"
+        android:paddingRight="0px"
+        android:progressDrawable="@drawable/progress_mini_player" />
+
     <LinearLayout
         android:id="@+id/header"
         android:layout_width="fill_parent"
diff --git a/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java b/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java
index 4f85f55..8421057 100644
--- a/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java
@@ -49,6 +49,7 @@ import android.view.ViewGroup;
 import android.widget.AdapterView;
 import android.widget.ImageButton;
 import android.widget.ListView;
+import android.widget.ProgressBar;
 import android.widget.SeekBar;
 import android.widget.TextView;
 import android.widget.ViewSwitcher;
@@ -58,6 +59,7 @@ import android.widget.SeekBar.OnSeekBarChangeListener;
 public class AudioMiniPlayer extends Fragment implements IAudioPlayer {
     public static final String TAG = "VLC/AudioMiniPlayer";
 
+    private ProgressBar mProgressBar;
     private AudioMediaSwitcher mAudioMediaSwitcher;
     private AnimatedCoverView mBigCover;
     private TextView mTime;
@@ -98,6 +100,8 @@ public class AudioMiniPlayer extends Fragment implements IAudioPlayer {
     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
         View v = inflater.inflate(R.layout.audio_player, container, false);
 
+        mProgressBar = (ProgressBar) v.findViewById(R.id.progressBar);
+
         mAudioMediaSwitcher = (AudioMediaSwitcher) v.findViewById(R.id.audio_media_switcher);
         mAudioMediaSwitcher.setAudioMediaSwitcherListener(mAudioMediaSwitcherListener);
 
@@ -298,6 +302,8 @@ public class AudioMiniPlayer extends Fragment implements IAudioPlayer {
         mLength.setText(Util.millisToString(length));
         mTimeline.setMax(length);
         mTimeline.setProgress(time);
+        mProgressBar.setMax(length);
+        mProgressBar.setProgress(time);
     }
 
     private void updateList() {



More information about the Android mailing list