[Android] Seek on left/right gesture

XilasZ xilasz at gmail.com
Sat Aug 11 10:05:07 CEST 2012


I didn't read the code yet, but from a user point of view, i think :

- vertical & horizontal gesture should not be mixed. right now, a diagonal
gesture change volume and seek at the same time, it's confusing
- we should display some hint during the gesture, so that the user know
where he's seeking
- and i think this should be optionnal. it's a great feature, but me i
prefer to use the wheel bar (which does exactly the same), to prevent
accidental seeking :p

anyway, it's a good start :)

On Fri, Aug 10, 2012 at 4:42 PM, Alexandre Perraud <git at videolan.org> wrote:

> android | branch: master | Alexandre Perraud <4leyx4ndre at gmail.com> | Fri
> Aug 10 16:27:09 2012 +0200| [ab1d7aa1fe74a784c783fa956a8ea511973e9326] |
> committer: Jean-Baptiste Kempf
>
> Seek on left/right gesture
>
> Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
>
> >
> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=ab1d7aa1fe74a784c783fa956a8ea511973e9326
> ---
>
>  .../vlc/gui/video/VideoPlayerActivity.java         |   72
> +++++++++++++-------
>  1 file changed, 48 insertions(+), 24 deletions(-)
>
> 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 51d5456..be8033c 100644
> --- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
> +++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
> @@ -59,6 +59,7 @@ import android.os.Handler;
>  import android.os.Message;
>  import android.preference.PreferenceManager;
>  import android.text.format.DateFormat;
> +import android.util.DisplayMetrics;
>  import android.util.Log;
>  import android.view.Display;
>  import android.view.MotionEvent;
> @@ -145,7 +146,7 @@ public class VideoPlayerActivity extends Activity {
>      private AudioManager mAudioManager;
>      private int mAudioMax;
>      private int mAudioDisplayRange;
> -    private float mTouchY, mVol;
> +    private float mTouchY, mTouchX, mVol;
>      private boolean mIsAudioChanged;
>      private String[] mAudioTracks;
>      private String[] mSubtitleTracks;
> @@ -644,36 +645,59 @@ public class VideoPlayerActivity extends Activity {
>                      getWindowManager().getDefaultDisplay().getWidth(),
>                      getWindowManager().getDefaultDisplay().getHeight());
>
> -        switch (event.getAction()) {
> -
> -            case MotionEvent.ACTION_DOWN:
> -                mTouchY = event.getRawY();
> -                mVol =
> mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
> -                mIsAudioChanged = false;
> -                break;
> +        float y_changed = event.getRawY() - mTouchY;
> +        float x_changed = event.getRawX() - mTouchX;
>
> -            case MotionEvent.ACTION_MOVE:
> -                float y = event.getRawY();
> +        switch (event.getAction()) {
>
> -                int delta = (int) (((mTouchY - y) / mAudioDisplayRange) *
> mAudioMax);
> +        case MotionEvent.ACTION_DOWN:
> +            // Audio
> +            mTouchY = event.getRawY();
> +            mVol =
> mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
> +            mIsAudioChanged = false;
> +            // Seek
> +            mTouchX = event.getRawX();
> +            break;
> +
> +        case MotionEvent.ACTION_MOVE:
> +            if (Math.abs(y_changed) > Math.abs(x_changed)) {
> +                // Audio
> +                int delta = -(int) ((y_changed / mAudioDisplayRange) *
> mAudioMax);
>                  int vol = (int) Math.min(Math.max(mVol + delta, 0),
> mAudioMax);
>                  if (delta != 0) {
> -
>  mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, vol,
> AudioManager.FLAG_SHOW_UI);
> +
>  mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC,
> +                            vol, AudioManager.FLAG_SHOW_UI);
>                      mIsAudioChanged = true;
>                  }
> -                break;
> -
> -            case MotionEvent.ACTION_UP:
> -                if (!mIsAudioChanged) {
> -                    if (!mShowing) {
> -                        showOverlay();
> -                    } else {
> -                        hideOverlay(true);
> -                        if(Util.isICSOrLater())
> -
>  mHandler.sendMessageDelayed(mHandler.obtainMessage(HIDE_NAV),
> OVERLAY_TIMEOUT);
> -                    }
> +            }
> +            break;
> +
> +        case MotionEvent.ACTION_UP:
> +            // Audio
> +            if (!mIsAudioChanged) {
> +                if (!mShowing) {
> +                    showOverlay();
> +                } else {
> +                    hideOverlay(true);
> +                    if (Util.isICSOrLater())
> +                        mHandler.sendMessageDelayed(
> +                                mHandler.obtainMessage(HIDE_NAV),
> +                                OVERLAY_TIMEOUT);
>                  }
> -                break;
> +            }
> +            // Seek
> +            if (Math.abs(y_changed) < Math.abs(x_changed)) {
> +                // Tools to get the screen size for the cubic progression
> +                DisplayMetrics screen = new DisplayMetrics();
> +                getWindowManager().getDefaultDisplay().getMetrics(screen);
> +
> +                // Size of the jump, 10 minutes max (600000) with a cubic
> +                // progression
> +                int jump = (int) (600000 * Math.pow(
> +                        (x_changed / screen.widthPixels), 3));
> +                mPlayerControlListener.onSeek(jump);
> +            }
> +            break;
>          }
>          return mIsAudioChanged;
>      }
>
> _______________________________________________
> Android mailing list
> Android at videolan.org
> http://mailman.videolan.org/listinfo/android
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/android/attachments/20120811/84020cfb/attachment.html>


More information about the Android mailing list