15 changed files with 371 additions and 76 deletions
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 7.7 KiB |
@ -0,0 +1,27 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:layout_width="fill_parent" |
|||
android:layout_height="wrap_content" |
|||
android:gravity="center" > |
|||
|
|||
<ImageButton |
|||
android:id="@+id/player_overlay_backward" |
|||
android:layout_width="50dip" |
|||
android:layout_height="50dip" |
|||
android:background="@drawable/ic_backward" /> |
|||
|
|||
<ImageButton |
|||
android:id="@+id/player_overlay_play" |
|||
android:layout_width="50dip" |
|||
android:layout_height="50dip" |
|||
android:layout_marginLeft="15dp" |
|||
android:layout_marginRight="15dp" |
|||
android:background="@drawable/ic_pause" /> |
|||
|
|||
<ImageButton |
|||
android:id="@+id/player_overlay_forward" |
|||
android:layout_width="50dip" |
|||
android:layout_height="50dip" |
|||
android:background="@drawable/ic_forward" /> |
|||
|
|||
</LinearLayout> |
|||
@ -0,0 +1,12 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<SeekBar xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:id="@+id/player_overlay_wheelbar" |
|||
android:layout_width="fill_parent" |
|||
android:layout_height="wrap_content" |
|||
android:clickable="false" |
|||
android:focusable="false" |
|||
android:maxHeight="5dp" |
|||
android:minHeight="5dp" |
|||
android:progressDrawable="@drawable/wheel_background" |
|||
android:thumb="@drawable/wheel_pause" |
|||
android:thumbOffset="0px" /> |
|||
@ -0,0 +1,28 @@ |
|||
/***************************************************************************** |
|||
* IPlayerControl.java |
|||
***************************************************************************** |
|||
* Copyright © 2011-2012 VLC authors and VideoLAN |
|||
* |
|||
* This program is free software; you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation; either version 2 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, write to the Free Software |
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
|||
*****************************************************************************/ |
|||
|
|||
package org.videolan.vlc.interfaces; |
|||
|
|||
|
|||
public interface IPlayerControl { |
|||
void setState(boolean isPlaying); |
|||
|
|||
void setOnPlayerControlListener(OnPlayerControlListener listener); |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
/***************************************************************************** |
|||
* OnPlayerControlListener.java |
|||
***************************************************************************** |
|||
* Copyright © 2012 VLC authors and VideoLAN |
|||
* |
|||
* This program is free software; you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation; either version 2 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, write to the Free Software |
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
|||
*****************************************************************************/ |
|||
|
|||
package org.videolan.vlc.interfaces; |
|||
|
|||
public interface OnPlayerControlListener { |
|||
public abstract void onPlayPause(); |
|||
|
|||
public abstract long onWheelStart(); |
|||
|
|||
public abstract void onSeek(int delta); |
|||
|
|||
public abstract void onSeekTo(long position); |
|||
|
|||
public abstract void onShowInfo(String info); |
|||
} |
|||
@ -0,0 +1,88 @@ |
|||
/***************************************************************************** |
|||
* PlayerControlClassic.java |
|||
***************************************************************************** |
|||
* Copyright © 2012 VLC authors and VideoLAN |
|||
* |
|||
* This program is free software; you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation; either version 2 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, write to the Free Software |
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
|||
*****************************************************************************/ |
|||
|
|||
package org.videolan.vlc.widget; |
|||
|
|||
import org.videolan.vlc.R; |
|||
import org.videolan.vlc.interfaces.IPlayerControl; |
|||
import org.videolan.vlc.interfaces.OnPlayerControlListener; |
|||
|
|||
import android.content.Context; |
|||
import android.view.LayoutInflater; |
|||
import android.view.View; |
|||
import android.widget.ImageButton; |
|||
import android.widget.LinearLayout; |
|||
|
|||
public class PlayerControlClassic extends LinearLayout implements IPlayerControl { |
|||
|
|||
private ImageButton mBackward; |
|||
private ImageButton mPlayPause; |
|||
private ImageButton mForward; |
|||
private OnPlayerControlListener listener = null; |
|||
|
|||
public PlayerControlClassic(Context context) { |
|||
super(context); |
|||
|
|||
LayoutInflater.from(context).inflate(R.layout.player_contol_classic, this, true); |
|||
|
|||
mBackward = (ImageButton) findViewById(R.id.player_overlay_backward); |
|||
mBackward.setOnClickListener(mBackwardListener); |
|||
mPlayPause = (ImageButton) findViewById(R.id.player_overlay_play); |
|||
mPlayPause.setOnClickListener(mPlayPauseListener); |
|||
mForward = (ImageButton) findViewById(R.id.player_overlay_forward); |
|||
mForward.setOnClickListener(mForwardListener); |
|||
} |
|||
|
|||
private OnClickListener mBackwardListener = new OnClickListener() { |
|||
@Override |
|||
public void onClick(View v) { |
|||
if (listener != null) |
|||
listener.onSeek(-10000); |
|||
} |
|||
}; |
|||
private OnClickListener mPlayPauseListener = new OnClickListener() { |
|||
@Override |
|||
public void onClick(View v) { |
|||
if (listener != null) |
|||
listener.onPlayPause(); |
|||
} |
|||
}; |
|||
private OnClickListener mForwardListener = new OnClickListener() { |
|||
@Override |
|||
public void onClick(View v) { |
|||
if (listener != null) |
|||
listener.onSeek(10000); |
|||
} |
|||
}; |
|||
|
|||
@Override |
|||
public void setState(boolean isPlaying) { |
|||
if (isPlaying) { |
|||
mPlayPause.setBackgroundResource(R.drawable.ic_pause); |
|||
} else { |
|||
mPlayPause.setBackgroundResource(R.drawable.ic_play); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void setOnPlayerControlListener(OnPlayerControlListener listener) { |
|||
this.listener = listener; |
|||
} |
|||
} |
|||
@ -0,0 +1,111 @@ |
|||
/***************************************************************************** |
|||
* PlayerControlWheel.java |
|||
***************************************************************************** |
|||
* Copyright © 2012 VLC authors and VideoLAN |
|||
* |
|||
* This program is free software; you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation; either version 2 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, write to the Free Software |
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
|||
*****************************************************************************/ |
|||
|
|||
package org.videolan.vlc.widget; |
|||
|
|||
import org.videolan.vlc.R; |
|||
import org.videolan.vlc.Util; |
|||
import org.videolan.vlc.interfaces.IPlayerControl; |
|||
import org.videolan.vlc.interfaces.OnPlayerControlListener; |
|||
|
|||
import android.content.Context; |
|||
import android.view.LayoutInflater; |
|||
import android.widget.LinearLayout; |
|||
import android.widget.SeekBar; |
|||
import android.widget.SeekBar.OnSeekBarChangeListener; |
|||
|
|||
public class PlayerControlWheel extends LinearLayout implements IPlayerControl { |
|||
|
|||
private SeekBar mWheel; |
|||
private OnPlayerControlListener listener = null; |
|||
|
|||
private static final int WHEEL_DEAD_ZONE = 7; |
|||
private static final int WHEEL_RANGE = 60; |
|||
private int mMiddle = 0; |
|||
private long mPosition = 0; |
|||
private long mSeekTo = -1; |
|||
|
|||
public PlayerControlWheel(Context context) { |
|||
super(context); |
|||
|
|||
LayoutInflater.from(context).inflate(R.layout.player_contol_wheel, this, true); |
|||
|
|||
mWheel = (SeekBar) findViewById(R.id.player_overlay_wheelbar); |
|||
mWheel.setMax((WHEEL_DEAD_ZONE + WHEEL_RANGE) * 2); |
|||
mMiddle = WHEEL_DEAD_ZONE + WHEEL_RANGE; |
|||
mWheel.setProgress(mMiddle); |
|||
mWheel.setOnSeekBarChangeListener(mWheelListener); |
|||
} |
|||
|
|||
private OnSeekBarChangeListener mWheelListener = new OnSeekBarChangeListener() { |
|||
@Override |
|||
public void onStartTrackingTouch(SeekBar seekBar) { |
|||
mPosition = listener != null ? listener.onWheelStart() : 0; |
|||
mSeekTo = -1; |
|||
} |
|||
|
|||
@Override |
|||
public void onStopTrackingTouch(SeekBar seekBar) { |
|||
if (listener != null) { |
|||
// if in dead zone, pause/unpause
|
|||
if (mSeekTo < 0) |
|||
listener.onPlayPause(); |
|||
else |
|||
listener.onSeekTo(mSeekTo); |
|||
listener.onShowInfo(null); |
|||
} |
|||
seekBar.setProgress(mMiddle); |
|||
} |
|||
|
|||
@Override |
|||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { |
|||
if (!fromUser) |
|||
return; |
|||
int delta = progress - mMiddle; |
|||
if (Math.abs(delta) >= WHEEL_DEAD_ZONE) { |
|||
delta -= Math.signum(delta) * WHEEL_DEAD_ZONE; |
|||
mSeekTo = Math.max(0, mPosition + delta * 1000); |
|||
} |
|||
else |
|||
delta = 0; |
|||
if (mSeekTo >= 0 && listener != null) |
|||
listener.onShowInfo(String.format("%s%ds (%s)", delta >= 0 ? "+" : "", delta, Util.millisToString(mSeekTo))); |
|||
} |
|||
}; |
|||
|
|||
@Override |
|||
public void setState(boolean isPlaying) { |
|||
if (isPlaying) { |
|||
mWheel.setThumb(getResources().getDrawable(R.drawable.wheel_pause)); |
|||
} else { |
|||
mWheel.setThumb(getResources().getDrawable(R.drawable.wheel_play)); |
|||
} |
|||
mWheel.setThumbOffset(0); |
|||
|
|||
//force a refresh
|
|||
mWheel.layout(mWheel.getLeft() - 1, mWheel.getTop(), mWheel.getRight(), mWheel.getBottom()); |
|||
mWheel.layout(mWheel.getLeft() + 1, mWheel.getTop(), mWheel.getRight(), mWheel.getBottom()); |
|||
} |
|||
|
|||
@Override |
|||
public void setOnPlayerControlListener(OnPlayerControlListener listener) { |
|||
this.listener = listener; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue