[Android] Audio player: display the current time position in the mini player

Adrien Maglo git at videolan.org
Tue Jan 28 11:10:50 CET 2014


vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Tue Jan 28 11:10:42 2014 +0100| [ef4fbeede22f3620fd03a34df3c2b6b4250f5033] | committer: Adrien Maglo

Audio player: display the current time position in the mini player

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

 vlc-android/res/layout/audio_player.xml                 |   12 ++++++++++++
 vlc-android/src/org/videolan/vlc/gui/MainActivity.java  |    4 ++--
 .../src/org/videolan/vlc/widget/AudioMiniPlayer.java    |   15 ++++++++++++---
 3 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/vlc-android/res/layout/audio_player.xml b/vlc-android/res/layout/audio_player.xml
index 18c13b9..7094139 100644
--- a/vlc-android/res/layout/audio_player.xml
+++ b/vlc-android/res/layout/audio_player.xml
@@ -55,6 +55,18 @@
             android:scaleType="fitXY"
             android:src="@drawable/dots_dark" />
 
+        <TextView
+            android:id="@+id/header_time"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center|left"
+            android:layout_marginRight="15dp"
+            android:layout_weight="0"
+            android:clickable="true"
+            android:text="@string/time_0"
+            android:textColor="?attr/darkorange"
+            android:textSize="18sp" />
+
         <ImageButton
             android:id="@+id/header_play_pause"
             android:layout_width="40dp"
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index a7fdafa..034b503 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -807,7 +807,7 @@ public class MainActivity extends SherlockFragmentActivity {
 
             @Override
             public void onPanelOpened() {
-                mAudioPlayer.setHeaderVisibilities(false, false, true, true);
+                mAudioPlayer.setHeaderVisibilities(false, false, true, true, true);
             }
 
             @Override
@@ -815,7 +815,7 @@ public class MainActivity extends SherlockFragmentActivity {
 
             @Override
             public void onPanelClosed() {
-                mAudioPlayer.setHeaderVisibilities(true, true, false, false);
+                mAudioPlayer.setHeaderVisibilities(true, true, false, false, false);
             }
 
     };
diff --git a/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java b/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java
index be61578..5b6a474 100644
--- a/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java
@@ -70,6 +70,7 @@ public class AudioMiniPlayer extends Fragment implements IAudioPlayer {
     private AudioMediaSwitcher mAudioMediaSwitcher;
     private AnimatedCoverView mBigCover;
     private TextView mTime;
+    private TextView mHeaderTime;
     private TextView mLength;
     private ImageButton mPlayPause;
     private ImageButton mHeaderPlayPause;
@@ -94,6 +95,7 @@ public class AudioMiniPlayer extends Fragment implements IAudioPlayer {
     private boolean mPlaylistSwitchVisible;
     private boolean mHeaderPlayPauseVisible;
     private boolean mProgressBarVisible;
+    private boolean mHeaderTimeVisible;
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
@@ -115,6 +117,7 @@ public class AudioMiniPlayer extends Fragment implements IAudioPlayer {
 
         mBigCover = (AnimatedCoverView) v.findViewById(R.id.big_cover);
         mTime = (TextView) v.findViewById(R.id.time);
+        mHeaderTime = (TextView) v.findViewById(R.id.header_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);
@@ -138,6 +141,7 @@ public class AudioMiniPlayer extends Fragment implements IAudioPlayer {
         mPlaylistSwitchVisible = false;
         mHeaderPlayPauseVisible = true;
         mProgressBarVisible = true;
+        mHeaderTimeVisible = true;
         restoreHedaderButtonVisibilities();
 
         mTime.setOnClickListener(new View.OnClickListener() {
@@ -350,6 +354,7 @@ public class AudioMiniPlayer extends Fragment implements IAudioPlayer {
         int time = mAudioController.getTime();
         int length = mAudioController.getLength();
         mTime.setText(Util.millisToString(mShowRemainingTime ? time-length : time));
+        mHeaderTime.setText(Util.millisToString(time));
         mLength.setText(Util.millisToString(length));
         mTimeline.setMax(length);
         mTimeline.setProgress(time);
@@ -400,8 +405,8 @@ public class AudioMiniPlayer extends Fragment implements IAudioPlayer {
         public void onProgressChanged(SeekBar sb, int prog, boolean fromUser) {
             if (fromUser) {
                 mAudioController.setTime(prog);
-                mTime.setText(Util.millisToString(mShowRemainingTime ? prog-mAudioController.getLength() : prog))
-            ;
+                mTime.setText(Util.millisToString(mShowRemainingTime ? prog-mAudioController.getLength() : prog));
+                mHeaderTime.setText(Util.millisToString(prog));
         }
     }
     };
@@ -473,11 +478,13 @@ public class AudioMiniPlayer extends Fragment implements IAudioPlayer {
      * @param headerPlayPauseVisible
      */
     public void setHeaderVisibilities(boolean advFuncVisible, boolean playlistSwitchVisible,
-                                      boolean headerPlayPauseVisible, boolean progressBarVisible) {
+                                      boolean headerPlayPauseVisible, boolean progressBarVisible,
+                                      boolean headerTimeVisible) {
         mAdvFuncVisible = advFuncVisible;
         mPlaylistSwitchVisible = playlistSwitchVisible;
         mHeaderPlayPauseVisible = headerPlayPauseVisible;
         mProgressBarVisible = progressBarVisible;
+        mHeaderTimeVisible = headerTimeVisible;
         restoreHedaderButtonVisibilities();
     }
 
@@ -486,12 +493,14 @@ public class AudioMiniPlayer extends Fragment implements IAudioPlayer {
         mPlaylistSwitch.setVisibility(mPlaylistSwitchVisible ? ImageButton.VISIBLE : ImageButton.GONE);
         mHeaderPlayPause.setVisibility(mHeaderPlayPauseVisible ? ImageButton.VISIBLE : ImageButton.GONE);
         mProgressBar.setVisibility(mProgressBarVisible ? ProgressBar.VISIBLE : ProgressBar.GONE);
+        mHeaderTime.setVisibility(mHeaderTimeVisible ? TextView.VISIBLE : TextView.GONE);
     }
 
     private void hideHedaderButtons() {
         mAdvFunc.setVisibility(ImageButton.GONE);
         mPlaylistSwitch.setVisibility(ImageButton.GONE);
         mHeaderPlayPause.setVisibility(ImageButton.GONE);
+        mHeaderTime.setVisibility(TextView.GONE);
     }
 
     private final AudioMediaSwitcherListener mAudioMediaSwitcherListener = new AudioMediaSwitcherListener() {



More information about the Android mailing list