I am playing video in Android Video view.Issue is video is not resizing as per device ratio. On big devices it stretched or in small device it is skeqzes. Is there any way to maintain ratio and fill full width like center crop.

I have checked following answers:

Resize video to fit the VideoView

Android VideoView orientation change with buffered video

But nothing works.

My code :

mBinding.videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {
                mp.setOnInfoListener(new MediaPlayer.OnInfoListener() {
                    @Override
                    public boolean onInfo(MediaPlayer mp, int what, int extra) {

                        if (what == MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START) {
                            mBinding.placeholder.setVisibility(View.GONE);

                            return true;
                        }
                        return false;
                    }
                });

                mp.setLooping(true);
            }
        });

XML :

  <VideoView
            android:id="@+id/videoView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

  </VideoView>

Related posts

Recent Viewed