Commit dd5da98e authored by Sébastien Toque's avatar Sébastien Toque

Add a best fit mode and use it as default

parent 23d93b9a
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
<string name="validation">Etes-vous sûr ?</string> <string name="validation">Etes-vous sûr ?</string>
<string name="locked">Verrouillé</string> <string name="locked">Verrouillé</string>
<string name="unlocked">Dé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_horizontal">Ajuster horizontalement</string>
<string name="surface_fit_vertical">Ajuster verticalement</string> <string name="surface_fit_vertical">Ajuster verticalement</string>
<string name="surface_fill">Etirer</string> <string name="surface_fill">Etirer</string>
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
<string name="validation">Are you sure?</string> <string name="validation">Are you sure?</string>
<string name="locked">Locked</string> <string name="locked">Locked</string>
<string name="unlocked">Unlocked</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_horizontal">Fit horizontal</string>
<string name="surface_fit_vertical">Fit vertical</string> <string name="surface_fit_vertical">Fit vertical</string>
<string name="surface_fill">Fill</string> <string name="surface_fill">Fill</string>
......
...@@ -73,13 +73,14 @@ public class VideoPlayerActivity extends Activity { ...@@ -73,13 +73,14 @@ public class VideoPlayerActivity extends Activity {
private SurfaceHolder mSurfaceHolder; private SurfaceHolder mSurfaceHolder;
private LibVLC mLibVLC; private LibVLC mLibVLC;
private static final int SURFACE_FIT_HORIZONTAL = 0; private static final int SURFACE_BEST_FIT = 0;
private static final int SURFACE_FIT_VERTICAL = 1; private static final int SURFACE_FIT_HORIZONTAL = 1;
private static final int SURFACE_FILL = 2; private static final int SURFACE_FIT_VERTICAL = 2;
private static final int SURFACE_16_9 = 3; private static final int SURFACE_FILL = 3;
private static final int SURFACE_4_3 = 4; private static final int SURFACE_16_9 = 4;
private static final int SURFACE_ORIGINAL = 5; private static final int SURFACE_4_3 = 5;
private int mCurrentSize = SURFACE_FIT_HORIZONTAL; private static final int SURFACE_ORIGINAL = 6;
private int mCurrentSize = SURFACE_BEST_FIT;
/** Overlay */ /** Overlay */
private View mOverlayHeader; private View mOverlayHeader;
...@@ -403,6 +404,12 @@ public class VideoPlayerActivity extends Activity { ...@@ -403,6 +404,12 @@ public class VideoPlayerActivity extends Activity {
double dar = (double) dw / (double) dh; double dar = (double) dw / (double) dh;
switch (mCurrentSize) { switch (mCurrentSize) {
case SURFACE_BEST_FIT:
if (dar < ar)
dh = (int) (dw / ar);
else
dw = (int) (dh * ar);
break;
case SURFACE_FIT_HORIZONTAL: case SURFACE_FIT_HORIZONTAL:
dh = (int) (dw / ar); dh = (int) (dw / ar);
break; break;
...@@ -608,6 +615,9 @@ public class VideoPlayerActivity extends Activity { ...@@ -608,6 +615,9 @@ public class VideoPlayerActivity extends Activity {
} }
changeSurfaceSize(); changeSurfaceSize();
switch (mCurrentSize) { switch (mCurrentSize) {
case SURFACE_BEST_FIT:
showInfo(R.string.surface_best_fit, 500);
break;
case SURFACE_FIT_HORIZONTAL: case SURFACE_FIT_HORIZONTAL:
showInfo(R.string.surface_fit_horizontal, 500); showInfo(R.string.surface_fit_horizontal, 500);
break; break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment