[Android] VideoPlayerActivity: add the speed label

Edward Wang git at videolan.org
Sun Sep 9 03:43:39 CEST 2012


vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Sat Sep  8 21:37:13 2012 -0400| [d69a10a478306100417594923dcaa7ff321bfc94] | committer: Edward Wang

VideoPlayerActivity: add the speed label

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

 vlc-android/res/layout/player.xml                  |   15 ++++++++++++++
 .../vlc/gui/video/VideoPlayerActivity.java         |   21 ++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/vlc-android/res/layout/player.xml b/vlc-android/res/layout/player.xml
index bc45ab8..cc0586a 100644
--- a/vlc-android/res/layout/player.xml
+++ b/vlc-android/res/layout/player.xml
@@ -215,6 +215,21 @@
                     android:text="@string/lock_rotation"
                     android:textSize="18dip" />
             </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:gravity="center_vertical"
+                android:orientation="horizontal" >
+
+                <TextView
+                    android:id="@+id/player_overlay_speed"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="1.00x"
+                    android:textSize="22dip"
+                    android:clickable="true" />
+            </LinearLayout>
         </LinearLayout>
     </org.videolan.vlc.widget.SlidingPanel>
 
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 3a494d1..3659ba1 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -35,6 +35,7 @@ import org.videolan.vlc.R;
 import org.videolan.vlc.Util;
 import org.videolan.vlc.WeakHandler;
 import org.videolan.vlc.gui.PreferencesActivity;
+import org.videolan.vlc.gui.SpeedSelectorDialog;
 import org.videolan.vlc.gui.audio.AudioPlayerActivity;
 import org.videolan.vlc.interfaces.IPlayerControl;
 import org.videolan.vlc.interfaces.OnPlayerControlListener;
@@ -46,6 +47,7 @@ import android.annotation.TargetApi;
 import android.app.Activity;
 import android.content.BroadcastReceiver;
 import android.content.Context;
+import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.SharedPreferences;
@@ -134,6 +136,7 @@ public class VideoPlayerActivity extends Activity {
     private Spinner mSubtitles;
     private ImageButton mLock;
     private ImageButton mSize;
+    private TextView mSpeedLabel;
 
     /**
      * For uninterrupted switching between audio and video mode
@@ -258,6 +261,9 @@ public class VideoPlayerActivity extends Activity {
         mSize = (ImageButton) findViewById(R.id.player_overlay_size);
         mSize.setOnClickListener(mSizeListener);
 
+        mSpeedLabel = (TextView) findViewById(R.id.player_overlay_speed);
+        mSpeedLabel.setOnClickListener(mSpeedLabelListener);
+
         mSurface = (SurfaceView) findViewById(R.id.player_surface);
         mSurfaceHolder = mSurface.getHolder();
         mSurfaceHolder.setFormat(PixelFormat.RGBX_8888);
@@ -961,6 +967,21 @@ public class VideoPlayerActivity extends Activity {
         }
     };
 
+    private final OnClickListener mSpeedLabelListener = new OnClickListener() {
+        @Override
+        public void onClick(View v) {
+            SpeedSelectorDialog d = new SpeedSelectorDialog(VideoPlayerActivity.this);
+            d.setOnDismissListener(new DialogInterface.OnDismissListener() {
+
+                @Override
+                public void onDismiss(DialogInterface dialog) {
+                    mSpeedLabel.setText(String.format(java.util.Locale.US, "%.2fx", LibVLC.getExistingInstance().getRate()));
+                }
+            });
+            d.show();
+        }
+    };
+
     /**
      * attach and disattach surface to the lib
      */



More information about the Android mailing list