Android TV Leanback Exoplayer video scaling issue

Viewed 508

I have been working on developing application for android TV. I am using Exoplayer to play the videos. I am having issues with the video ratio. I want to play the video in full screen. I have gone through the solutions in How can I scale video in ExoPlayer-V2 - Play Video In Full Screen but it will work only if we have a xml view for the exoplayer. Since we will not have a xml view for the leanback and we use "VideoSupportFragment". How cloud I change the video ratio in leanback? I tried

exoVideoPlayerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL);

exoPlayer.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);

As we will not have the ExoplayerView in leanback I was not able to use "setResizeMode" method.

How can I resize the video in Leanback Exoplayer.

1 Answers

In VideoSupportFragment you can change the video size by changing the dimensions of its SurfaceView. You may using the following snippet to change the dimensions:

    SurfaceView surfaceView = super.getSurfaceView();
    ViewGroup.LayoutParams params = surfaceView.getLayoutParams();
    params.height = myHeight;  // set your desired dimens
    params.width = myWidth;
    surfaceView.setLayoutParams(params);
Related