Commit e6329e3c authored by Michael Merg's avatar Michael Merg
Browse files

update the video overlay

* new icons
* add two new buttons (lock screen and change surface ratio)
* only the lock screen button is working by now.
parent 7b3eadf0
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>vlc-android</name>
<name>VLC</name>
<comment></comment>
<projects>
</projects>
......
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size
android:width="25dip"
android:height="25dip" />
<stroke
android:color="#cccccc"
android:width="6dip" />
<solid
android:color="#ffffff" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="80dip">
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="4dip"
android:maxHeight="4dip"
android:id="@+id/player_overlay_seekbar"
android:progressDrawable="@drawable/po_seekbar"
android:thumb="@drawable/po_seekbar_thumb"
android:paddingLeft="10dip"
android:paddingRight="10dip"/>
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:paddingTop="24dip">
android:layout_width="match_parent">
<TextView
android:id="@+id/player_overlay_time"
android:layout_width="0dip"
......@@ -26,6 +16,39 @@
android:text="0:00"
android:textColor="#ffffff"
android:paddingLeft="10dip"/>
<TextView
android:id="@+id/player_overlay_length"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="15dip"
android:text="0:00"
android:gravity="right"
android:textColor="#ffffff"
android:paddingRight="10dip"/>
</LinearLayout>
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="4dip"
android:maxHeight="4dip"
android:id="@+id/player_overlay_seekbar"
android:progressDrawable="@drawable/po_seekbar"
android:thumb="@drawable/ic_seekbar_thumb"
android:paddingTop="5dip"
android:paddingBottom="5dip"
android:paddingLeft="10dip"
android:paddingRight="10dip"/>
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<ImageButton
android:id="@+id/player_overlay_size"
android:background="@drawable/ic_size"
android:layout_height="50dip"
android:layout_width="50dip"
android:paddingRight="10dip"/>
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
......@@ -33,19 +56,15 @@
android:gravity="center_horizontal">
<ImageButton
android:id="@+id/player_overlay_play"
android:background="@android:drawable/ic_media_pause"
android:background="@drawable/ic_pause"
android:layout_width="50dip"
android:layout_height="50dip"/>
</LinearLayout>
<TextView
android:id="@+id/player_overlay_length"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="15dip"
android:text="0:00"
android:gravity="right"
android:textColor="#ffffff"
<ImageButton
android:id="@+id/player_overlay_lock"
android:background="@drawable/ic_lock"
android:layout_height="50dip"
android:layout_width="50dip"
android:paddingRight="10dip"/>
</LinearLayout>
</FrameLayout>
\ No newline at end of file
</LinearLayout>
\ No newline at end of file
......@@ -11,16 +11,18 @@ import android.os.Message;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.util.Log;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.WindowManager;
import android.view.SurfaceHolder.Callback;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.SeekBar;
......@@ -37,7 +39,7 @@ public class PlayerActivity extends Activity {
private Context mContext;
/** Overlay */
private FrameLayout mOverlay;
private LinearLayout mOverlay;
private LinearLayout mDecor;
private View mSpacer;
private static final int OVERLAY_TIMEOUT = 4000;
......@@ -50,6 +52,7 @@ public class PlayerActivity extends Activity {
private TextView mTime;
private TextView mLength;
private ImageButton mPause;
private ImageButton mLock;
// size of the video
private int mHeight;
......@@ -77,7 +80,7 @@ public class PlayerActivity extends Activity {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
mOverlay = (FrameLayout)inflater.inflate(R.layout.player_overlay, null);
mOverlay = (LinearLayout)inflater.inflate(R.layout.player_overlay, null);
mTime = (TextView) mOverlay.findViewById(R.id.player_overlay_time);
mLength = (TextView) mOverlay.findViewById(R.id.player_overlay_length);
......@@ -85,6 +88,9 @@ public class PlayerActivity extends Activity {
mPause = (ImageButton) mOverlay.findViewById(R.id.player_overlay_play);
mPause.setOnClickListener(mPauseListener);
mLock = (ImageButton) mOverlay.findViewById(R.id.player_overlay_lock);
mLock.setOnClickListener(mLockListener);
mSurface = (SurfaceView) findViewById(R.id.player_surface);
mSurfaceHolder = mSurface.getHolder();
mSurfaceHolder.setKeepScreenOn(true);
......@@ -104,7 +110,7 @@ public class PlayerActivity extends Activity {
mLibVLC.setEventManager(em);
/* debug */
lockScreen();
// lockScreen();
}
......@@ -149,16 +155,36 @@ public class PlayerActivity extends Activity {
mHandler.sendMessage(msg);
}
/**
* Lock screen rotation
*/
private void lockScreen() {
// FIXME: create button on overlay to lock the screen (or perhaps the menu button?!)
//int orientation = getWindowManager().getDefaultDisplay().getOrientation();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
switch (display.getRotation()) {
case Surface.ROTATION_0:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
break;
case Surface.ROTATION_90:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
break;
case Surface.ROTATION_270:
// FIXME: API Level 9+ (not tested on a device with API Level < 9)
setRequestedOrientation(8); // SCREEN_ORIENTATION_REVERSE_LANDSCAPE
break;
}
}
/**
* Remove screen lock
*/
private void unlockScreen() {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}
/**
* Handle libvlc asynchronous events
*/
......@@ -182,6 +208,7 @@ public class PlayerActivity extends Activity {
Log.e(TAG, "Event not handled");
break;
}
updateOverlayPausePlay();
}
};
......@@ -250,23 +277,15 @@ public class PlayerActivity extends Activity {
* handle changes of the seekbar (slicer)
*/
private OnSeekBarChangeListener mSeekListener = new OnSeekBarChangeListener() {
boolean wasPlaying;
public void onStartTrackingTouch(SeekBar seekBar) {
mDragging = true;
showOverlay(3600000);
if (mLibVLC.isPlaying()) {
wasPlaying = true;
pause();
}
}
public void onStopTrackingTouch(SeekBar seekBar) {
mDragging = false;
showOverlay();
if (wasPlaying) {
play();
}
}
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
......@@ -289,6 +308,23 @@ public class PlayerActivity extends Activity {
showOverlay();
}
};
/**
*
*/
private OnClickListener mLockListener = new OnClickListener() {
boolean isLocked = false;
public void onClick(View v) {
if (isLocked) {
unlockScreen();
isLocked = false;
} else {
lockScreen();
isLocked = true;
}
}
};
/**
......@@ -321,7 +357,6 @@ public class PlayerActivity extends Activity {
private void showOverlay(int timeout) {
mHandler.sendEmptyMessage(SHOW_PROGRESS);
if (!mShowing) {
Log.i(TAG, "add View!");
mShowing = true;
mDecor.addView(mOverlay);
}
......@@ -330,6 +365,7 @@ public class PlayerActivity extends Activity {
mHandler.removeMessages(FADE_OUT);
mHandler.sendMessageDelayed(msg, timeout);
}
updateOverlayPausePlay();
}
......@@ -346,33 +382,27 @@ public class PlayerActivity extends Activity {
}
/*
private void updateOverlayPausePlay() {
if (mLibVLC == null) {
return;
}
Log.i(TAG, "update play/pause button. Playing: " + mLibVLC.isPlaying());
if (mLibVLC.isPlaying()) {
mPause.setBackgroundResource(android.R.drawable.ic_media_pause);
mPause.setBackgroundResource(R.drawable.ic_pause);
} else {
mPause.setBackgroundResource(android.R.drawable.ic_media_play);
mPause.setBackgroundResource(R.drawable.ic_play);
}
}
*/
/**
* play or pause the media
*/
private void doPausePlay() {
// FIXME: the libVLC is to slow to use updateOverlayPausePlay()
if (mLibVLC.isPlaying()) {
pause();
mPause.setBackgroundResource(android.R.drawable.ic_media_play);
} else {
play();
mPause.setBackgroundResource(android.R.drawable.ic_media_pause);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment