Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The solution is to use <code>TextureView</code> instead of <code>VideoView</code>(<code>SurfaceView</code>).<br> <code>TextureView</code> does not make any manipulations with the content to fit it ti the screen.<br> Here is the code sample for the solution:</p> <pre><code>//store the SurfaceTexture to set surface for MediaPlayer mTextureView.setSurfaceTextureListener(new SurfaceTextureListener() { @Override public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { FullScreenActivity.this.mSurface = surface; } </code></pre> <p>.... </p> <pre><code>Surface s = new Surface(mSurface); mPlayer = mp; mp.setSurface(s); scaleVideo(mp);//&lt;-- this function scales video to run cropped </code></pre> <p>....</p> <pre><code>private void scaleVideo(MediaPlayer mPlayer) { LayoutParams videoParams = (LayoutParams) mTextureView .getLayoutParams(); DisplayMetrics dm = new DisplayMetrics(); FullScreenActivity.this.getWindowManager().getDefaultDisplay() .getMetrics(dm); final int height = dm.heightPixels; final int width = dm.widthPixels; int videoHeight = mPlayer.getVideoHeight(); int videoWidth = mPlayer.getVideoWidth(); double hRatio = 1; hRatio = (height * 1.0 / videoHeight) / (width * 1.0 / videoWidth); videoParams.x = (int) (hRatio &lt;= 1 ? 0 : Math.round((-(hRatio - 1) / 2) * width)); videoParams.y = (int) (hRatio &gt;= 1 ? 0 : Math .round((((-1 / hRatio) + 1) / 2) * height)); videoParams.width = width - videoParams.x - videoParams.x; videoParams.height = height - videoParams.y - videoParams.y; Log.e(TAG, "x:" + videoParams.x + " y:" + videoParams.y); mTextureView.setScaleX(1.00001f);//&lt;-- this line enables smoothing of the picture in TextureView. mTextureView.requestLayout(); mTextureView.invalidate(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload