[Android] Preview: add a button to start playback

Sébastien Toque git at videolan.org
Fri Apr 6 20:34:31 CEST 2012


android | branch: master | Sébastien Toque <xilasz at gmail.com> | Fri Apr  6 20:31:23 2012 +0200| [e1e93688181fc2f75f574e644b6028dbb7770185] | committer: Sébastien Toque

Preview: add a button to start playback

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

 vlc-android/res/layout/media_info.xml              |   10 ++++++++++
 .../videolan/vlc/gui/video/MediaInfoActivity.java  |   13 +++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/vlc-android/res/layout/media_info.xml b/vlc-android/res/layout/media_info.xml
index 42234b2..24abf82 100644
--- a/vlc-android/res/layout/media_info.xml
+++ b/vlc-android/res/layout/media_info.xml
@@ -41,6 +41,16 @@
             android:layout_gravity="center"
             android:scaleType="fitCenter" />
 
+        <ImageButton
+            android:id="@+id/play"
+            android:layout_width="50dip"
+            android:layout_height="50dip"
+            android:layout_gravity="bottom|left"
+            android:layout_margin="10dip"
+            android:background="@drawable/ic_play"
+            android:onClick="onPlayClick"
+            android:visibility="invisible" />
+
         <TextView
             android:id="@+id/length"
             android:layout_width="wrap_content"
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoActivity.java
index 4835a72..05021ea 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoActivity.java
@@ -31,11 +31,14 @@ import org.videolan.vlc.TrackInfo;
 import org.videolan.vlc.Util;
 
 import android.app.ListActivity;
+import android.content.Intent;
 import android.graphics.Bitmap;
 import android.graphics.Bitmap.Config;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
+import android.view.View;
+import android.widget.ImageButton;
 import android.widget.ImageView;
 import android.widget.TextView;
 
@@ -43,6 +46,7 @@ public class MediaInfoActivity extends ListActivity {
     public final static String TAG = "VLC/MediaInfoActivity";
     private Media mItem;
     private Bitmap mImage;
+    private ImageButton mPlayButton;
     private TrackInfo[] mTracks;
     private MediaInfoAdapter mAdapter;
     private final static int NEW_IMAGE = 0;
@@ -65,12 +69,20 @@ public class MediaInfoActivity extends ListActivity {
         TextView lengthView = (TextView) findViewById(R.id.length);
         lengthView.setText(Util.millisToString(mItem.getLength()));
 
+        mPlayButton = (ImageButton) findViewById(R.id.play);
+
         mAdapter = new MediaInfoAdapter(MediaInfoActivity.this, R.layout.audio_browser_playlist);
         setListAdapter(mAdapter);
 
         new Thread(mLoadImage).start();
     }
 
+    public void onPlayClick(View v) {
+        Intent intent = new Intent(this, VideoPlayerActivity.class);
+        intent.putExtra("itemLocation", mItem.getLocation());
+        startActivity(intent);
+    }
+
     Runnable mLoadImage = new Runnable() {
         @Override
         public void run() {
@@ -110,6 +122,7 @@ public class MediaInfoActivity extends ListActivity {
                 case NEW_IMAGE:
                     ImageView imageView = (ImageView) MediaInfoActivity.this.findViewById(R.id.image);
                     imageView.setImageBitmap(mImage);
+                    mPlayButton.setVisibility(View.VISIBLE);
                     break;
                 case NEW_TEXT:
                     for (TrackInfo track : mTracks) {



More information about the Android mailing list