[Android] Seek gesture : show jump info during gesture + show target time
Sébastien Toque
git at videolan.org
Tue Aug 14 22:59:00 CEST 2012
vlc-ports/android | branch: master | Sébastien Toque <xilasz at gmail.com> | Tue Aug 14 22:14:29 2012 +0200| [87305412f40cbf65bb474b3d51f5c6467bb82b36] | committer: Sébastien Toque
Seek gesture : show jump info during gesture + show target time
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=87305412f40cbf65bb474b3d51f5c6467bb82b36
---
.../vlc/gui/video/VideoPlayerActivity.java | 50 ++++++++++++--------
1 file changed, 30 insertions(+), 20 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 feb4f49..1017ec6 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -649,6 +649,7 @@ public class VideoPlayerActivity extends Activity {
float x_changed = event.getRawX() - mTouchX;
// coef is the gradient's move to determine a neutral zone
float coef = Math.abs (y_changed / x_changed);
+ float gesturesize = ((x_changed / screen.xdpi) * 2.54f);
switch (event.getAction()) {
@@ -673,6 +674,8 @@ public class VideoPlayerActivity extends Activity {
mIsAudioChanged = true;
}
}
+ // Seek
+ evalTouchSeek(coef, gesturesize, false);
break;
case MotionEvent.ACTION_UP:
@@ -690,31 +693,38 @@ public class VideoPlayerActivity extends Activity {
}
// Seek
- float gesturesize = ((x_changed / screen.xdpi) * 2.54f);
- // No seek action if coef > 0.5 and gesturesize < 1cm
- if (coef < 0.5 && Math.abs(gesturesize) > 1) {
+ evalTouchSeek(coef, gesturesize, true);
+ break;
+ }
+ return mIsAudioChanged;
+ }
- long length = mLibVLC.getLength();
- long time = mLibVLC.getTime();
+ private void evalTouchSeek(float coef, float gesturesize, boolean seek) {
+ // No seek action if coef > 0.5 and gesturesize < 1cm
+ if (coef > 0.5 || Math.abs(gesturesize) < 1)
+ return;
- // Size of the jump, 10 minutes max (600000), with a bi-cubic progression, for a 8cm gesture
- int jump = (int) (Math.signum(gesturesize) * ((600000 * Math.pow((gesturesize / 8), 4)) + 3000));
+ long length = mLibVLC.getLength();
+ long time = mLibVLC.getTime();
- // Adjust the jump
- if ((jump > 0) && ((time + jump) > length))
- jump = (int) (length - time);
- if ((jump < 0) && ((time + jump) < 0))
- jump = (int) -time;
+ // Size of the jump, 10 minutes max (600000), with a bi-cubic progression, for a 8cm gesture
+ int jump = (int) (Math.signum(gesturesize) * ((600000 * Math.pow((gesturesize / 8), 4)) + 3000));
- //Jump !
- mPlayerControlListener.onSeek(jump);
+ // Adjust the jump
+ if ((jump > 0) && ((time + jump) > length))
+ jump = (int) (length - time);
+ if ((jump < 0) && ((time + jump) < 0))
+ jump = (int) -time;
- //Show the jump's size
- showInfo(String.format("%s%s", jump >= 0 ? "+" : "", Util.millisToString(jump)), 1000);
- }
- break;
- }
- return mIsAudioChanged;
+ //Jump !
+ if (seek)
+ mPlayerControlListener.onSeekTo(time + jump);
+
+ //Show the jump's size
+ showInfo(String.format("%s%s (%s)",
+ jump >= 0 ? "+" : "",
+ Util.millisToString(jump),
+ Util.millisToString(time + jump)), 1000);
}
/**
More information about the Android
mailing list