@Override public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) { if (DEBUG) { Log.d(TAG, "onVideoSizeChanged() called with: width / height = [" + width + " / " + height + " = " + (((float) width) / height) + "], unappliedRotationDegrees = [" + unappliedRotationDegrees + "], pixelWidthHeightRatio = [" + pixelWidthHeightRatio + "]"); } aspectRatioFrameLayout.setAspectRatio(((float) width) / height); }
@SuppressWarnings("ResourceType") private static void setResizeModeRaw(AspectRatioFrameLayout aspectRatioFrame, int resizeMode) { aspectRatioFrame.setResizeMode(resizeMode); }
/** Returns the {@link ResizeMode}. */ public @ResizeMode int getResizeMode() { Assertions.checkState(contentFrame != null); return contentFrame.getResizeMode(); }
int width = getMeasuredWidth(); int height = getMeasuredHeight(); float viewAspectRatio = (float) width / height; float aspectDeformation = videoAspectRatio / viewAspectRatio - 1;
contentFrame.addView(surfaceView, 0); } else { surfaceView = null;
/** * Set the {@link AspectRatioFrameLayout.AspectRatioListener}. * * @param listener The listener to be notified about aspect ratios changes of the video content or * the content frame. */ public void setAspectRatioListener(AspectRatioFrameLayout.AspectRatioListener listener) { Assertions.checkState(contentFrame != null); contentFrame.setAspectRatioListener(listener); }
: new SurfaceView(context); surfaceView.setLayoutParams(params); contentFrame.addView(surfaceView, 0); } else { surfaceView = null;
/** * Set the {@link AspectRatioFrameLayout.AspectRatioListener}. * * @param listener The listener to be notified about aspect ratios changes of the video content or * the content frame. */ public void setAspectRatioListener(AspectRatioFrameLayout.AspectRatioListener listener) { Assertions.checkState(contentFrame != null); contentFrame.setAspectRatioListener(listener); }
/** * Called when there's a change in the aspect ratio of the content being displayed. The default * implementation sets the aspect ratio of the content frame to that of the content, unless the * content view is a {@link SphericalSurfaceView} in which case the frame's aspect ratio is * cleared. * * @param contentAspectRatio The aspect ratio of the content. * @param contentFrame The content frame, or {@code null}. * @param contentView The view that holds the content being displayed, or {@code null}. */ protected void onContentAspectRatioChanged( float contentAspectRatio, @Nullable AspectRatioFrameLayout contentFrame, @Nullable View contentView) { if (contentFrame != null) { contentFrame.setAspectRatio( contentView instanceof SphericalSurfaceView ? 0 : contentAspectRatio); } }
/** * Sets the {@link ResizeMode}. * * @param resizeMode The {@link ResizeMode}. */ public void setResizeMode(@ResizeMode int resizeMode) { Assertions.checkState(contentFrame != null); contentFrame.setResizeMode(resizeMode); }
resizeView.setText(PlayerHelper.resizeTypeOf(context, aspectRatioFrameLayout.getResizeMode()));
: new SurfaceView(context); surfaceView.setLayoutParams(params); contentFrame.addView(surfaceView, 0); } else { surfaceView = null;
@Override public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) { if (contentFrame != null) { float aspectRatio = height == 0 ? 1 : (width * pixelWidthHeightRatio) / height; contentFrame.setAspectRatio(aspectRatio); } }
protected void setResizeMode(@AspectRatioFrameLayout.ResizeMode final int resizeMode) { getAspectRatioFrameLayout().setResizeMode(resizeMode); getResizeView().setText(PlayerHelper.resizeTypeOf(context, resizeMode)); }
private void onResizeClicked() { if (getAspectRatioFrameLayout() != null) { final int currentResizeMode = getAspectRatioFrameLayout().getResizeMode(); final int newResizeMode = nextResizeMode(currentResizeMode); setResizeMode(newResizeMode); } }
@Override public void onNewAspectRatio(float aspectRatio) { videoFrame.setAspectRatio(aspectRatio); }
@SuppressWarnings("ResourceType") private static void setResizeModeRaw(AspectRatioFrameLayout aspectRatioFrame, int resizeMode) { aspectRatioFrame.setResizeMode(resizeMode); }
/** * Returns the resize mode. */ public @ResizeMode int getResizeMode() { Assertions.checkState(contentFrame != null); return contentFrame.getResizeMode(); }
private boolean setArtworkFromBitmap(Bitmap bitmap) { if (bitmap != null) { int bitmapWidth = bitmap.getWidth(); int bitmapHeight = bitmap.getHeight(); if (bitmapWidth > 0 && bitmapHeight > 0) { if (contentFrame != null) { contentFrame.setAspectRatio((float) bitmapWidth / bitmapHeight); } artworkView.setImageBitmap(bitmap); artworkView.setVisibility(VISIBLE); return true; } } return false; }
@SuppressWarnings("ResourceType") private static void setResizeModeRaw(AspectRatioFrameLayout aspectRatioFrame, int resizeMode) { aspectRatioFrame.setResizeMode(resizeMode); }