[Android] Video Player : add remaining time function

Alexandre Perraud git at videolan.org
Wed Nov 21 17:30:11 CET 2012


vlc-ports/android | branch: master | Alexandre Perraud <4leyx4ndre at gmail.com> | Wed Nov 21 17:24:01 2012 +0100| [a6cf194e0620dd6118c280b39dedf18883b0639e] | committer: Jean-Baptiste Kempf

Video Player : add remaining time function

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 vlc-android/res/layout/player.xml                     |   10 +++++++---
 .../videolan/vlc/gui/video/VideoPlayerActivity.java   |   17 ++++++++++++++++-
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/vlc-android/res/layout/player.xml b/vlc-android/res/layout/player.xml
index 8504ced..bbd8893 100644
--- a/vlc-android/res/layout/player.xml
+++ b/vlc-android/res/layout/player.xml
@@ -134,6 +134,7 @@
             android:layout_alignBottom="@+id/player_overlay_seekbar"
             android:layout_alignParentLeft="true"
             android:layout_alignTop="@+id/player_overlay_seekbar"
+            android:clickable="true"
             android:gravity="left|center_vertical"
             android:text="@string/time_0"
             android:textColor="#ffffff"
@@ -143,11 +144,12 @@
             android:id="@+id/player_overlay_seekbar"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
-            android:layout_centerHorizontal="true"
+            android:layout_toLeftOf="@+id/player_overlay_length"
+            android:layout_toRightOf="@+id/player_overlay_time"
             android:maxHeight="4dip"
             android:minHeight="4dip"
-            android:paddingLeft="60dp"
-            android:paddingRight="60dp"
+            android:paddingLeft="20dp"
+            android:paddingRight="20dp"
             android:progressDrawable="@drawable/po_seekbar"
             android:thumb="@drawable/ic_seekbar_thumb" />
 
@@ -158,6 +160,7 @@
             android:layout_alignBottom="@+id/player_overlay_seekbar"
             android:layout_alignParentRight="true"
             android:layout_alignTop="@+id/player_overlay_seekbar"
+            android:clickable="true"
             android:gravity="right|center_vertical"
             android:text="@string/time_0"
             android:textColor="#ffffff"
@@ -179,6 +182,7 @@
             android:layout_alignParentRight="true"
             android:layout_below="@+id/player_overlay_seekbar"
             android:background="@drawable/ic_size" />
+
     </RelativeLayout>
 
 </RelativeLayout>
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 5d3ea34..b92e244 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -128,6 +128,7 @@ public class VideoPlayerActivity extends Activity {
     private IPlayerControl mControls;
     private boolean mEnableWheelbar;
     private boolean mEnableBrightnessGesture;
+    private boolean mDisplayRemainingTime = false;
     private int mScreenOrientation;
     private ImageButton mAudioTrack;
     private ImageButton mSubtitle;
@@ -203,8 +204,12 @@ public class VideoPlayerActivity extends Activity {
         mSysTime = (TextView) findViewById(R.id.player_overlay_systime);
         mBattery = (TextView) findViewById(R.id.player_overlay_battery);
 
+        // Position and remaining time
         mTime = (TextView) findViewById(R.id.player_overlay_time);
+        mTime.setOnClickListener(mRemainingTimeListener);
         mLength = (TextView) findViewById(R.id.player_overlay_length);
+        mLength.setOnClickListener(mRemainingTimeListener);
+
         // the info textView is not on the overlay
         mInfo = (TextView) findViewById(R.id.player_overlay_info);
 
@@ -1044,6 +1049,14 @@ public class VideoPlayerActivity extends Activity {
         }
     };
 
+    private final OnClickListener mRemainingTimeListener = new OnClickListener() {
+        @Override
+        public void onClick(View v) {
+            mDisplayRemainingTime = !mDisplayRemainingTime;
+            showOverlay();
+        }
+    };
+
     /**
      * attach and disattach surface to the lib
      */
@@ -1156,7 +1169,9 @@ public class VideoPlayerActivity extends Activity {
         mSeekbar.setProgress(time);
         mSysTime.setText(DateFormat.format("kk:mm", System.currentTimeMillis()));
         mTime.setText(Util.millisToString(time));
-        mLength.setText(Util.millisToString(length));
+        mLength.setText(mDisplayRemainingTime
+                ? "- " + Util.millisToString(length - time)
+                : Util.millisToString(length));
         return time;
     }
 



More information about the Android mailing list