mirror of
https://github.com/androidx/media.git
synced 2025-05-04 14:10:40 +08:00
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:
parent
6788a830da
commit
acb84396d5
@ -308,7 +308,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
|
||||
|
Loading…
x
Reference in New Issue
Block a user