Fix incorrect anamorphic handling in Leanback extension

The leanback library doesn't know about non-square pixels. So if
we're playing content that uses non-square pixels, we need to adjust
the video dimensions that we provide to leanback such that it
renders the video with the correct aspect ratio.

PiperOrigin-RevId: 277042560
This commit is contained in:
olly 2019-10-28 12:18:49 +00:00 committed by Oliver Woodman
parent 6788a830da
commit acb84396d5

View File

@ -308,7 +308,11 @@ public final class LeanbackPlayerAdapter extends PlayerAdapter implements Runnab
@Override @Override
public void onVideoSizeChanged( public void onVideoSizeChanged(
int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) { int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
getCallback().onVideoSizeChanged(LeanbackPlayerAdapter.this, width, height); // There's no way to pass pixelWidthHeightRatio to leanback, so we scale the width that we
// pass to take it into account. This is necessary to ensure that leanback uses the correct
// aspect ratio when playing content with non-square pixels.
int scaledWidth = Math.round(width * pixelWidthHeightRatio);
getCallback().onVideoSizeChanged(LeanbackPlayerAdapter.this, scaledWidth, height);
} }
@Override @Override