[Android] Add a best fit mode and use it as default
Sébastien Toque
git at videolan.org
Sun Mar 4 09:23:34 CET 2012
android | branch: master | Sébastien Toque <xilasz at gmail.com> | Sun Mar 4 09:20:53 2012 +0100| [dd5da98e2d804161e6b99a85f80003d1a19db01d] | committer: Sébastien Toque
Add a best fit mode and use it as default
> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=dd5da98e2d804161e6b99a85f80003d1a19db01d
---
vlc-android/res/values-fr/strings.xml | 1 +
vlc-android/res/values/strings.xml | 1 +
.../vlc/gui/video/VideoPlayerActivity.java | 24 ++++++++++++++-----
3 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/vlc-android/res/values-fr/strings.xml b/vlc-android/res/values-fr/strings.xml
index dc90896..ce532f6 100644
--- a/vlc-android/res/values-fr/strings.xml
+++ b/vlc-android/res/values-fr/strings.xml
@@ -53,6 +53,7 @@
<string name="validation">Etes-vous sûr ?</string>
<string name="locked">Verrouillé</string>
<string name="unlocked">Déverrouillé</string>
+ <string name="surface_best_fit">Ajuster au mieux</string>
<string name="surface_fit_horizontal">Ajuster horizontalement</string>
<string name="surface_fit_vertical">Ajuster verticalement</string>
<string name="surface_fill">Etirer</string>
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index ff6cbea..541132b 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -54,6 +54,7 @@
<string name="validation">Are you sure?</string>
<string name="locked">Locked</string>
<string name="unlocked">Unlocked</string>
+ <string name="surface_best_fit">Best fit</string>
<string name="surface_fit_horizontal">Fit horizontal</string>
<string name="surface_fit_vertical">Fit vertical</string>
<string name="surface_fill">Fill</string>
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 ba38e04..35c360e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -73,13 +73,14 @@ public class VideoPlayerActivity extends Activity {
private SurfaceHolder mSurfaceHolder;
private LibVLC mLibVLC;
- private static final int SURFACE_FIT_HORIZONTAL = 0;
- private static final int SURFACE_FIT_VERTICAL = 1;
- private static final int SURFACE_FILL = 2;
- private static final int SURFACE_16_9 = 3;
- private static final int SURFACE_4_3 = 4;
- private static final int SURFACE_ORIGINAL = 5;
- private int mCurrentSize = SURFACE_FIT_HORIZONTAL;
+ private static final int SURFACE_BEST_FIT = 0;
+ private static final int SURFACE_FIT_HORIZONTAL = 1;
+ private static final int SURFACE_FIT_VERTICAL = 2;
+ private static final int SURFACE_FILL = 3;
+ private static final int SURFACE_16_9 = 4;
+ private static final int SURFACE_4_3 = 5;
+ private static final int SURFACE_ORIGINAL = 6;
+ private int mCurrentSize = SURFACE_BEST_FIT;
/** Overlay */
private View mOverlayHeader;
@@ -403,6 +404,12 @@ public class VideoPlayerActivity extends Activity {
double dar = (double) dw / (double) dh;
switch (mCurrentSize) {
+ case SURFACE_BEST_FIT:
+ if (dar < ar)
+ dh = (int) (dw / ar);
+ else
+ dw = (int) (dh * ar);
+ break;
case SURFACE_FIT_HORIZONTAL:
dh = (int) (dw / ar);
break;
@@ -608,6 +615,9 @@ public class VideoPlayerActivity extends Activity {
}
changeSurfaceSize();
switch (mCurrentSize) {
+ case SURFACE_BEST_FIT:
+ showInfo(R.string.surface_best_fit, 500);
+ break;
case SURFACE_FIT_HORIZONTAL:
showInfo(R.string.surface_fit_horizontal, 500);
break;
More information about the Android
mailing list