I didn't read the code yet, but from a user point of view, i think :<br><br>- vertical & horizontal gesture should not be mixed. right now, a diagonal gesture change volume and seek at the same time, it's confusing<br>
- we should display some hint during the gesture, so that the user know where he's seeking<br>- 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<br>
<br>anyway, it's a good start :)<br><br><div class="gmail_quote">On Fri, Aug 10, 2012 at 4:42 PM, Alexandre Perraud <span dir="ltr"><<a href="mailto:git@videolan.org" target="_blank">git@videolan.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">android | branch: master | Alexandre Perraud <<a href="mailto:4leyx4ndre@gmail.com">4leyx4ndre@gmail.com</a>> | Fri Aug 10 16:27:09 2012 +0200| [ab1d7aa1fe74a784c783fa956a8ea511973e9326] | committer: Jean-Baptiste Kempf<br>
<br>
Seek on left/right gesture<br>
<br>
Signed-off-by: Jean-Baptiste Kempf <<a href="mailto:jb@videolan.org">jb@videolan.org</a>><br>
<br>
> <a href="http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=ab1d7aa1fe74a784c783fa956a8ea511973e9326" target="_blank">http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=ab1d7aa1fe74a784c783fa956a8ea511973e9326</a><br>
---<br>
<br>
.../vlc/gui/video/VideoPlayerActivity.java | 72 +++++++++++++-------<br>
1 file changed, 48 insertions(+), 24 deletions(-)<br>
<br>
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java<br>
index 51d5456..be8033c 100644<br>
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java<br>
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java<br>
@@ -59,6 +59,7 @@ import android.os.Handler;<br>
import android.os.Message;<br>
import android.preference.PreferenceManager;<br>
import android.text.format.DateFormat;<br>
+import android.util.DisplayMetrics;<br>
import android.util.Log;<br>
import android.view.Display;<br>
import android.view.MotionEvent;<br>
@@ -145,7 +146,7 @@ public class VideoPlayerActivity extends Activity {<br>
private AudioManager mAudioManager;<br>
private int mAudioMax;<br>
private int mAudioDisplayRange;<br>
- private float mTouchY, mVol;<br>
+ private float mTouchY, mTouchX, mVol;<br>
private boolean mIsAudioChanged;<br>
private String[] mAudioTracks;<br>
private String[] mSubtitleTracks;<br>
@@ -644,36 +645,59 @@ public class VideoPlayerActivity extends Activity {<br>
getWindowManager().getDefaultDisplay().getWidth(),<br>
getWindowManager().getDefaultDisplay().getHeight());<br>
<br>
- switch (event.getAction()) {<br>
-<br>
- case MotionEvent.ACTION_DOWN:<br>
- mTouchY = event.getRawY();<br>
- mVol = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);<br>
- mIsAudioChanged = false;<br>
- break;<br>
+ float y_changed = event.getRawY() - mTouchY;<br>
+ float x_changed = event.getRawX() - mTouchX;<br>
<br>
- case MotionEvent.ACTION_MOVE:<br>
- float y = event.getRawY();<br>
+ switch (event.getAction()) {<br>
<br>
- int delta = (int) (((mTouchY - y) / mAudioDisplayRange) * mAudioMax);<br>
+ case MotionEvent.ACTION_DOWN:<br>
+ // Audio<br>
+ mTouchY = event.getRawY();<br>
+ mVol = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);<br>
+ mIsAudioChanged = false;<br>
+ // Seek<br>
+ mTouchX = event.getRawX();<br>
+ break;<br>
+<br>
+ case MotionEvent.ACTION_MOVE:<br>
+ if (Math.abs(y_changed) > Math.abs(x_changed)) {<br>
+ // Audio<br>
+ int delta = -(int) ((y_changed / mAudioDisplayRange) * mAudioMax);<br>
int vol = (int) Math.min(Math.max(mVol + delta, 0), mAudioMax);<br>
if (delta != 0) {<br>
- mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, vol, AudioManager.FLAG_SHOW_UI);<br>
+ mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC,<br>
+ vol, AudioManager.FLAG_SHOW_UI);<br>
mIsAudioChanged = true;<br>
}<br>
- break;<br>
-<br>
- case MotionEvent.ACTION_UP:<br>
- if (!mIsAudioChanged) {<br>
- if (!mShowing) {<br>
- showOverlay();<br>
- } else {<br>
- hideOverlay(true);<br>
- if(Util.isICSOrLater())<br>
- mHandler.sendMessageDelayed(mHandler.obtainMessage(HIDE_NAV), OVERLAY_TIMEOUT);<br>
- }<br>
+ }<br>
+ break;<br>
+<br>
+ case MotionEvent.ACTION_UP:<br>
+ // Audio<br>
+ if (!mIsAudioChanged) {<br>
+ if (!mShowing) {<br>
+ showOverlay();<br>
+ } else {<br>
+ hideOverlay(true);<br>
+ if (Util.isICSOrLater())<br>
+ mHandler.sendMessageDelayed(<br>
+ mHandler.obtainMessage(HIDE_NAV),<br>
+ OVERLAY_TIMEOUT);<br>
}<br>
- break;<br>
+ }<br>
+ // Seek<br>
+ if (Math.abs(y_changed) < Math.abs(x_changed)) {<br>
+ // Tools to get the screen size for the cubic progression<br>
+ DisplayMetrics screen = new DisplayMetrics();<br>
+ getWindowManager().getDefaultDisplay().getMetrics(screen);<br>
+<br>
+ // Size of the jump, 10 minutes max (600000) with a cubic<br>
+ // progression<br>
+ int jump = (int) (600000 * Math.pow(<br>
+ (x_changed / screen.widthPixels), 3));<br>
+ mPlayerControlListener.onSeek(jump);<br>
+ }<br>
+ break;<br>
}<br>
return mIsAudioChanged;<br>
}<br>
<br>
_______________________________________________<br>
Android mailing list<br>
<a href="mailto:Android@videolan.org">Android@videolan.org</a><br>
<a href="http://mailman.videolan.org/listinfo/android" target="_blank">http://mailman.videolan.org/listinfo/android</a><br>
</blockquote></div><br>