From c819856530d394a2352a68e7ce92e8a83a8d7071 Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Tue, 11 Dec 2018 22:07:40 +0100 Subject: [PATCH] Add protected method to override the AspectRatioFrameLayout aspect ratio --- .../google/android/exoplayer2/ui/PlayerView.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java index 41ddd3c7eb..d64f5aa61b 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java @@ -1031,6 +1031,19 @@ public class PlayerView extends FrameLayout { return subtitleView; } + /** + * Called to notify the {@link AspectRatioFrameLayout} of the new video aspect ratio. + * The default implementation will simply forward the aspect ratio to + * {@link AspectRatioFrameLayout#setAspectRatio(float)}. Subclasses can override this + * method, for example, to apply aspect ratio constraints. + * + * @param aspectRatioFrameLayout the video surface view container + * @param widthHeightRatio the computed aspect ratio + */ + protected void onDispatchVideoAspectRatio(@NonNull AspectRatioFrameLayout aspectRatioFrameLayout, float widthHeightRatio) { + aspectRatioFrameLayout.setAspectRatio(widthHeightRatio); + } + @Override public boolean onTouchEvent(MotionEvent ev) { if (ev.getActionMasked() != MotionEvent.ACTION_DOWN) { @@ -1355,7 +1368,7 @@ public class PlayerView extends FrameLayout { videoAspectRatio = 0; } - contentFrame.setAspectRatio(videoAspectRatio); + onDispatchVideoAspectRatio(contentFrame, videoAspectRatio); } @Override