Add protected method to override the AspectRatioFrameLayout aspect ratio

This commit is contained in:
Mattia Iavarone 2018-12-11 22:07:40 +01:00
parent 6a6b211233
commit c819856530

View File

@ -1031,6 +1031,19 @@ public class PlayerView extends FrameLayout {
return subtitleView; 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 @Override
public boolean onTouchEvent(MotionEvent ev) { public boolean onTouchEvent(MotionEvent ev) {
if (ev.getActionMasked() != MotionEvent.ACTION_DOWN) { if (ev.getActionMasked() != MotionEvent.ACTION_DOWN) {
@ -1355,7 +1368,7 @@ public class PlayerView extends FrameLayout {
videoAspectRatio = 0; videoAspectRatio = 0;
} }
contentFrame.setAspectRatio(videoAspectRatio); onDispatchVideoAspectRatio(contentFrame, videoAspectRatio);
} }
@Override @Override