Commit 8ec6cf15 by olly Committed by Oliver Woodman

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
parent 7277df35
......@@ -307,7 +307,11 @@ public final class LeanbackPlayerAdapter extends PlayerAdapter implements Runnab
@Override
public void onVideoSizeChanged(
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
......
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 sign in to comment