PlayerView


public class PlayerView extends FrameLayout implements AdViewProvider


A high level view for Player media playbacks. It displays video, subtitles and album art during playback, and displays playback controls using a PlayerControlView.

A PlayerView can be customized by setting attributes (or calling corresponding methods), or overriding drawables.

Attributes

The following attributes can be set on a PlayerView when used in a layout XML file:
  • artwork_display_mode - Whether artwork is used if available in audio streams and how it is displayed.
  • default_artwork - Default artwork to use if no artwork available in audio streams.
  • use_controller - Whether the playback controls can be shown.
  • hide_on_touch - Whether the playback controls are hidden by touch events.
  • auto_show - Whether the playback controls are automatically shown when playback starts, pauses, ends, or fails. If set to false, the playback controls can be manually operated with showController and hideController.
  • hide_during_ads - Whether the playback controls are hidden during ads. Controls are always shown during ads if they are enabled and the player is paused.
  • show_buffering - Whether the buffering spinner is displayed when the player is buffering. Valid values are never, when_playing and always.
  • resize_mode - Controls how video and album art is resized within the view. Valid values are fit, fixed_width, fixed_height, fill and zoom.
  • surface_type - The type of surface view used for video playbacks. Valid values are surface_view, texture_view, spherical_gl_surface_view, video_decoder_gl_surface_view and none. Using none is recommended for audio only applications, since creating the surface can be expensive. Using surface_view is recommended for video applications. See Choosing a surface type for more information.
    • Corresponding method: None
    • Default: surface_view
  • shutter_background_color - The background color of the exo_shutter view.
  • keep_content_on_player_reset - Whether the currently displayed video frame or media artwork is kept visible when the player is reset.
  • All attributes that can be set on PlayerControlView and DefaultTimeBar can also be set on a PlayerView, and will be propagated to the inflated .

Overriding drawables

The drawables used by PlayerControlView can be overridden by drawables with the same names defined in your application. See the PlayerControlView documentation for a list of drawables that can be overridden.

Summary

Nested types

@UnstableApi
@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = TYPE_USE)
@IntDef(value = )
public annotation PlayerView.ArtworkDisplayMode

Determines the artwork display mode.

Listener to be notified about changes of the visibility of the UI controls.

Listener invoked when the fullscreen button is clicked.

@UnstableApi
@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = TYPE_USE)
@IntDef(value = )
public annotation PlayerView.ShowBuffering

Determines when the buffering view is shown.

Constants

static final int

The artwork covers the entire space of the player view.

static final int

The artwork is fit into the player view and centered creating a letterbox style.

static final int

No artwork is shown.

static final int

The buffering view is always shown when the player is in the buffering state.

static final int

The buffering view is never shown.

static final int

The buffering view is shown when the player is in the buffering state and playWhenReady is true.

Public constructors

PlayerView(
    Context context,
    @Nullable AttributeSet attrs,
    int defStyleAttr
)

Public methods

boolean
boolean

Called to process media key events.

List<AdOverlayInfo>

Returns a list of AdOverlayInfo instances describing views that are on top of the ad view group, but that are essential for controlling playback and should be excluded from ad viewability measurements.

ViewGroup

Returns the ViewGroup on top of the player that will show any ad UI, or null if playing audio-only ads.

int

Returns the artwork display mode.

boolean

Returns whether the playback controls are automatically shown when playback starts, pauses, ends, or fails.

boolean

Returns whether the playback controls are hidden by touch events.

int

Returns the playback controls timeout.

@Nullable Drawable

Returns the default artwork to display.

@Nullable FrameLayout

Gets the overlay FrameLayout, which can be populated with UI elements to show on top of the player.

@Nullable Player

Returns the player currently set on this view, or null if no player is set.

int

Returns the ResizeMode.

@Nullable SubtitleView

Gets the SubtitleView.

boolean

This method is deprecated.

Use getArtworkDisplayMode instead.

boolean

Returns whether the playback controls can be shown.

@Nullable View

Gets the view onto which video is rendered.

void

Hides the playback controls.

boolean

Returns whether the controller is currently fully visible.

void

Should be called when the player is no longer visible to the user, if the surface_type extends GLSurfaceView.

void

Should be called when the player is visible to the user, if the surface_type extends GLSurfaceView.

boolean
boolean
void

Sets whether and how artwork is displayed if present in the media.

void

Sets the AspectRatioFrameLayout.AspectRatioListener.

void
@UnstableApi
setControllerAnimationEnabled(boolean animationEnabled)

Sets whether controller animation is enabled.

void
@UnstableApi
setControllerAutoShow(boolean controllerAutoShow)

Sets whether the playback controls are automatically shown when playback starts, pauses, ends, or fails.

void
@UnstableApi
setControllerHideDuringAds(boolean controllerHideDuringAds)

Sets whether the playback controls are hidden when ads are playing.

void
@UnstableApi
setControllerHideOnTouch(boolean controllerHideOnTouch)

Sets whether the playback controls are hidden by touch events.

void

This method is deprecated.

Use setFullscreenButtonClickListener instead.

void
@UnstableApi
setControllerShowTimeoutMs(int controllerShowTimeoutMs)

Sets the playback controls timeout.

void

This method is deprecated.

Use setControllerVisibilityListener instead.

void

Sets the ControllerVisibilityListener.

void

Sets a custom error message to be displayed by the view.

void

Sets the default artwork to display if useArtwork is true and no artwork is present in the media.

void

Sets the optional ErrorMessageProvider.

void
@UnstableApi
setExtraAdGroupMarkers(
    @Nullable long[] extraAdGroupTimesMs,
    @Nullable boolean[] extraPlayedAdGroups
)

Sets the millisecond positions of extra ad markers relative to the start of the window (or timeline, if in multi-window mode) and whether each extra ad has been played or not.

void

Sets the FullscreenButtonClickListener.

void
@UnstableApi
setKeepContentOnPlayerReset(boolean keepContentOnPlayerReset)

Sets whether the currently displayed video frame or media artwork is kept visible when the player is reset.

void

Sets the Player to use.

void

Sets which repeat toggle modes are enabled.

void

Sets the ResizeMode.

void

Sets whether a buffering spinner is displayed when the player is in the buffering state.

void
@UnstableApi
setShowFastForwardButton(boolean showFastForwardButton)

Sets whether the fast forward button is shown.

void
@UnstableApi
setShowMultiWindowTimeBar(boolean showMultiWindowTimeBar)

This method is deprecated.

Replace multi-window time bar display by merging source windows together instead, for example using ExoPlayer's ConcatenatingMediaSource2.

void
@UnstableApi
setShowNextButton(boolean showNextButton)

Sets whether the next button is shown.

void
@UnstableApi
setShowPlayButtonIfPlaybackIsSuppressed(
    boolean showPlayButtonIfSuppressed
)

Sets whether a play button is shown if playback is suppressed.

void
@UnstableApi
setShowPreviousButton(boolean showPreviousButton)

Sets whether the previous button is shown.

void
@UnstableApi
setShowRewindButton(boolean showRewindButton)

Sets whether the rewind button is shown.

void
@UnstableApi
setShowShuffleButton(boolean showShuffleButton)

Sets whether the shuffle button is shown.

void
@UnstableApi
setShowSubtitleButton(boolean showSubtitleButton)

Sets whether the subtitle button is shown.

void
@UnstableApi
setShowVrButton(boolean showVrButton)

Sets whether the vr button is shown.

void

Sets the background color of the exo_shutter view.

void
@UnstableApi
setUseArtwork(boolean useArtwork)

This method is deprecated.

Use setArtworkDisplayMode instead.

void
setUseController(boolean useController)

Sets whether the playback controls can be shown.

void
setVisibility(int visibility)
void

Shows the playback controls.

static void
@UnstableApi
switchTargetView(
    Player player,
    @Nullable PlayerView oldPlayerView,
    @Nullable PlayerView newPlayerView
)

Switches the view targeted by a given Player.

Protected methods

void
@UnstableApi
onContentAspectRatioChanged(
    @Nullable AspectRatioFrameLayout contentFrame,
    float aspectRatio
)

Called when there's a change in the desired aspect ratio of the content frame.

Inherited Constants

From android.view.View
static final int
static final int
static final int
static final int
static final int
static final int
static final Property<ViewFloat>
static final int
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE = "creditCardExpirationDate"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = "creditCardExpirationDay"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = "creditCardExpirationMonth"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR = "creditCardExpirationYear"
static final String
static final String
AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE = "creditCardSecurityCode"
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int
static final int
static final int
static final int
static final int
static final int
static final int[]
static final int[]
static final int[]
static final int[]
static final int
static final int
static final int
static final int
static final int
static final int
static final int
GONE = 8
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
KEEP_SCREEN_ON = 67108864
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
NO_ID = -1
static final int
static final int
static final int
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int[]
static final int[]
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final String
VIEW_LOG_TAG = "View"
static final int
static final int[]
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
From android.view.ViewGroup
static final int
static final int
static final int
static final int
static final int
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

Inherited methods

From android.widget.FrameLayout
boolean
FrameLayout.LayoutParams
FrameLayout.LayoutParams
CharSequence
boolean

This method is deprecated.

boolean
void
onLayout(boolean changed, int left, int top, int right, int bottom)
void
onMeasure(int widthMeasureSpec, int heightMeasureSpec)
void
setForegroundGravity(int foregroundGravity)
void
setMeasureAllChildren(boolean measureAll)
boolean
From android.view.View
void
void
void
ViewPropertyAnimator
void
void
boolean
void
void

This method is deprecated.

void
boolean
boolean
boolean
boolean
boolean
canScrollHorizontally(int direction)
boolean
canScrollVertically(int direction)
final void
void
final void
boolean
void
void
static int
combineMeasuredStates(int curState, int newState)
int
int
int
void
WindowInsets
int
int
int
AccessibilityNodeInfo
void
void

This method is deprecated.

boolean
boolean
dispatchNestedFling(float velocityX, float velocityY, boolean consumed)
boolean
dispatchNestedPreFling(float velocityX, float velocityY)
boolean
dispatchNestedPrePerformAccessibilityAction(
    int action,
    Bundle arguments
)
boolean
dispatchNestedPreScroll(
    int dx,
    int dy,
    int[] consumed,
    int[] offsetInWindow
)
boolean
dispatchNestedScroll(
    int dxConsumed,
    int dyConsumed,
    int dxUnconsumed,
    int dyUnconsumed,
    int[] offsetInWindow
)
boolean
void
draw(Canvas canvas)
void
drawableHotspotChanged(float x, float y)
final OnBackInvokedDispatcher
final T
<T extends View> findViewById(int id)
final T
<T extends View> findViewWithTag(Object tag)
boolean

This method is deprecated.

void
forceHasOverlappingRendering(boolean hasOverlappingRendering)
void
void
generateDisplayHash(
    String hashAlgorithm,
    Rect bounds,
    Executor executor,
    DisplayHashResultCallback callback
)
static int
View.AccessibilityDelegate
int
AccessibilityNodeProvider
CharSequence
int
int
String
String
float
Animation
Matrix
IBinder
int[]
Map<IntegerInteger>
String[]
final AutofillId
int
AutofillValue
Drawable
BlendMode
ColorStateList
PorterDuff.Mode
int
final int
float
int
float
Rect
boolean
final boolean
final ContentCaptureSession
CharSequence
final Context
ContextMenu.ContextMenuInfo
final boolean
static int
getDefaultSize(int size, int measureSpec)
Display
final int[]
Bitmap

This method is deprecated.

int

This method is deprecated.

int

This method is deprecated.

void
long
float
int
boolean
boolean
int
ArrayList<View>
getFocusables(int direction)
void
Drawable
int
BlendMode
ColorStateList
PorterDuff.Mode
boolean
getGlobalVisibleRect(Rect r, Point globalOffset)
Handler
float
float
float
float
Runnable
final boolean
final int
void
getHitRect(Rect outRect)
int
int
Drawable
Drawable
int
int
int
int
boolean
KeyEvent.DispatcherState
int
int
int
ViewGroup.LayoutParams
final int
float
int
final boolean
void
getLocationInSurface(int[] location)
void
getLocationInWindow(int[] outLocation)
void
getLocationOnScreen(int[] outLocation)
Matrix
final int
final int
final int
final int
final int
int
int
int
int
int
int
int
int
View.OnFocusChangeListener
int
ViewOutlineProvider
int
int
ViewOverlay
int
int
int
int
int
int
final ViewParent
ViewParent
float
float
PointerIcon
final List<Rect>
String[]
Resources
final boolean
final int
float
int
AttachedSurfaceControl
View
WindowInsets
float
float
float
float
float
int
int
int
int
int
int
final int
final int
int
int
final CharSequence
StateListAnimator
int
int
List<Rect>
int

This method is deprecated.

Object
int
int
CharSequence
final int
float
int
TouchDelegate
ArrayList<View>
float
String
float
float
float
long
int
int
Drawable
Drawable
int
ViewTranslationResponse
ViewTreeObserver
int
final int
int
WindowId
WindowInsetsController
int

This method is deprecated.

IBinder
int
void
float
float
float
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
static View
inflate(Context context, int resource, ViewGroup root)
void

This method is deprecated.

void
void
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean

This method is deprecated.

boolean
boolean
final boolean
final boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
final boolean
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
View
keyboardNavigationClusterSearch(View currentCluster, int direction)
final void
measure(int widthMeasureSpec, int heightMeasureSpec)
static int[]
mergeDrawableStates(int[] baseState, int[] additionalState)
void
offsetLeftAndRight(int offset)
void
offsetTopAndBottom(int offset)
void
void
WindowInsets
void
boolean
boolean
void
void
InputConnection
void
onCreateViewTranslationRequest(
    int[] supportedFormats,
    Consumer<ViewTranslationRequest> requestsCollector
)
void
onCreateVirtualViewTranslationRequests(
    long[] virtualIds,
    int[] supportedFormats,
    Consumer<ViewTranslationRequest> requestsCollector
)
void
onDisplayHint(int hint)
boolean
void
onDraw(Canvas canvas)
void
final void
boolean
void
void
void
onFocusChanged(
    boolean gainFocus,
    int direction,
    Rect previouslyFocusedRect
)
boolean
void
onHoverChanged(boolean hovered)
boolean
void
void
boolean
onKeyDown(int keyCode, KeyEvent event)
boolean
onKeyLongPress(int keyCode, KeyEvent event)
boolean
onKeyMultiple(int keyCode, int repeatCount, KeyEvent event)
boolean
onKeyPreIme(int keyCode, KeyEvent event)
boolean
onKeyShortcut(int keyCode, KeyEvent event)
boolean
onKeyUp(int keyCode, KeyEvent event)
void
onOverScrolled(
    int scrollX,
    int scrollY,
    boolean clampedX,
    boolean clampedY
)
void
onPointerCaptureChange(boolean hasCapture)
void
void
onProvideAutofillStructure(ViewStructure structure, int flags)
void
void
void
void
ContentInfo
void
void
onRtlPropertiesChanged(int layoutDirection)
Parcelable
void
onScreenStateChanged(int screenState)
void
onScrollCaptureSearch(
    Rect localVisibleRect,
    Point windowOffset,
    Consumer<ScrollCaptureTarget> targets
)
void
onScrollChanged(int l, int t, int oldl, int oldt)
boolean
onSetAlpha(int alpha)
void
onSizeChanged(int w, int h, int oldw, int oldh)
void
boolean
void
void
void
onVisibilityAggregated(boolean isVisible)
void
onVisibilityChanged(View changedView, int visibility)
void
onWindowFocusChanged(boolean hasWindowFocus)
void

This method is deprecated.

void
onWindowVisibilityChanged(int visibility)
boolean
overScrollBy(
    int deltaX,
    int deltaY,
    int scrollX,
    int scrollY,
    int scrollRangeX,
    int scrollRangeY,
    int maxOverScrollX,
    int maxOverScrollY,
    boolean isTouchEvent
)
boolean
performAccessibilityAction(int action, Bundle arguments)
boolean
performContextClick(float x, float y)
boolean
performHapticFeedback(int feedbackConstant)
boolean
ContentInfo
void
playSoundEffect(int soundConstant)
boolean
post(Runnable action)
boolean
postDelayed(Runnable action, long delayMillis)
void
void
postInvalidateDelayed(long delayMilliseconds)
void
void
void
postOnAnimationDelayed(Runnable action, long delayMillis)
void
void
boolean
void
void
void
void
void

This method is deprecated.

final boolean
void
void
boolean
final void
final T
<T extends View> requireViewById(int id)
void
static int
resolveSize(int size, int measureSpec)
static int
resolveSizeAndState(int size, int measureSpec, int childMeasuredState)
void
final void
saveAttributeDataForStyleable(
    Context context,
    int[] styleable,
    AttributeSet attrs,
    TypedArray t,
    int defStyleAttr,
    int defStyleRes
)
void
void
scheduleDrawable(Drawable who, Runnable what, long when)
void
scrollBy(int x, int y)
void
scrollTo(int x, int y)
void
sendAccessibilityEvent(int eventType)
void
void
setAccessibilityDataSensitive(int accessibilityDataSensitive)
void
void
setAccessibilityHeading(boolean isHeading)
void
void
setAccessibilityPaneTitle(CharSequence accessibilityPaneTitle)
void
void
void
setActivated(boolean activated)
void
setAllowClickWhenDisabled(boolean clickableWhenDisabled)
void
void
void
setAlpha(float alpha)
void
void
void
setAutoHandwritingEnabled(boolean enabled)
void
setAutofillHints(String[] autofillHints)
void
void
setBackground(Drawable background)
void
setBackgroundColor(int color)
void

This method is deprecated.

void
void
void
void
final void
setBottom(int bottom)
void
setCameraDistance(float distance)
void
setClickable(boolean clickable)
void
setClipBounds(Rect clipBounds)
void
setClipToOutline(boolean clipToOutline)
void
void
setContentDescription(CharSequence contentDescription)
void
setContextClickable(boolean contextClickable)
void
setDefaultFocusHighlightEnabled(boolean defaultFocusHighlightEnabled)
void

This method is deprecated.

void
setDrawingCacheEnabled(boolean enabled)

This method is deprecated.

void

This method is deprecated.

void
void
setElevation(float elevation)
void
setEnabled(boolean enabled)
void
setFadingEdgeLength(int length)
void
void
setFitsSystemWindows(boolean fitSystemWindows)
void
setFocusable(boolean focusable)
void
setFocusableInTouchMode(boolean focusableInTouchMode)
void
setFocusedByDefault(boolean isFocusedByDefault)
void
setForceDarkAllowed(boolean allow)
void
setForeground(Drawable foreground)
void
void
void
void
setHandwritingBoundsOffsets(
    float offsetLeft,
    float offsetTop,
    float offsetRight,
    float offsetBottom
)
void
void
setHapticFeedbackEnabled(boolean hapticFeedbackEnabled)
void
setHasTransientState(boolean hasTransientState)
void
setHorizontalFadingEdgeEnabled(boolean horizontalFadingEdgeEnabled)
void
setHorizontalScrollBarEnabled(boolean horizontalScrollBarEnabled)
void
void
void
setHovered(boolean hovered)
void
setId(int id)
void
void
void
void
setIsCredential(boolean isCredential)
void
setIsHandwritingDelegate(boolean isHandwritingDelegate)
void
setKeepScreenOn(boolean keepScreenOn)
void
setKeyboardNavigationCluster(boolean isCluster)
void
setLabelFor(int id)
void
void
setLayerType(int layerType, Paint paint)
void
setLayoutDirection(int layoutDirection)
void
final void
setLeft(int left)
final void
setLeftTopRightBottom(int left, int top, int right, int bottom)
void
setLongClickable(boolean longClickable)
final void
setMeasuredDimension(int measuredWidth, int measuredHeight)
void
setMinimumHeight(int minHeight)
void
setMinimumWidth(int minWidth)
void
setNestedScrollingEnabled(boolean enabled)
void
setNextClusterForwardId(int nextClusterForwardId)
void
setNextFocusDownId(int nextFocusDownId)
void
setNextFocusForwardId(int nextFocusForwardId)
void
setNextFocusLeftId(int nextFocusLeftId)
void
setNextFocusRightId(int nextFocusRightId)
void
setNextFocusUpId(int nextFocusUpId)
void
void
void
void
void
void
void
void
void
void
void
void
setOnReceiveContentListener(
    String[] mimeTypes,
    OnReceiveContentListener listener
)
void
void

This method is deprecated.

void
void
void
void
void
setOverScrollMode(int overScrollMode)
void
setPadding(int left, int top, int right, int bottom)
void
setPaddingRelative(int start, int top, int end, int bottom)
void
setPivotX(float pivotX)
void
setPivotY(float pivotY)
void
final void
setPreferKeepClear(boolean preferKeepClear)
final void
void
setPressed(boolean pressed)
void
final void
setRevealOnFocusHint(boolean revealOnFocus)
final void
setRight(int right)
void
setRotation(float rotation)
void
setRotationX(float rotationX)
void
setRotationY(float rotationY)
void
setSaveEnabled(boolean enabled)
void
setSaveFromParentEnabled(boolean enabled)
void
setScaleX(float scaleX)
void
setScaleY(float scaleY)
void
setScreenReaderFocusable(boolean screenReaderFocusable)
void
setScrollBarDefaultDelayBeforeFade(
    int scrollBarDefaultDelayBeforeFade
)
void
setScrollBarFadeDuration(int scrollBarFadeDuration)
void
setScrollBarSize(int scrollBarSize)
void
setScrollBarStyle(int style)
final void
void
void
setScrollContainer(boolean isScrollContainer)
void
setScrollIndicators(int indicators)
void
setScrollX(int value)
void
setScrollY(int value)
void
setScrollbarFadingEnabled(boolean fadeScrollbars)
void
setSelected(boolean selected)
void
setSoundEffectsEnabled(boolean soundEffectsEnabled)
void
void
void
void
setSystemUiVisibility(int visibility)

This method is deprecated.

void
void
setTextAlignment(int textAlignment)
void
setTextDirection(int textDirection)
void
final void
setTop(int top)
void
void
setTransitionAlpha(float alpha)
final void
setTransitionName(String transitionName)
void
setTransitionVisibility(int visibility)
void
setTranslationX(float translationX)
void
setTranslationY(float translationY)
void
setTranslationZ(float translationZ)
void
setVerticalFadingEdgeEnabled(boolean verticalFadingEdgeEnabled)
void
setVerticalScrollBarEnabled(boolean verticalScrollBarEnabled)
void
void
void
void
void
setWillNotCacheDrawing(boolean willNotCacheDrawing)

This method is deprecated.

void
setWillNotDraw(boolean willNotDraw)
void
setX(float x)
void
setY(float y)
void
setZ(float z)
boolean
ActionMode
void
final boolean
startDrag(
    ClipData data,
    View.DragShadowBuilder shadowBuilder,
    Object myLocalState,
    int flags
)

This method is deprecated.

final boolean
startDragAndDrop(
    ClipData data,
    View.DragShadowBuilder shadowBuilder,
    Object myLocalState,
    int flags
)
boolean
void
String
void
void
void
final void
boolean
boolean

This method is deprecated.

boolean
From android.view.ViewGroup
void
void
addExtraDataToAccessibilityNodeInfo(
    AccessibilityNodeInfo info,
    String extraDataKey,
    Bundle arguments
)
void
addFocusables(ArrayList<View> views, int direction, int focusableMode)
void
boolean
void
void
addView(View child)
boolean
addViewInLayout(View child, int index, ViewGroup.LayoutParams params)
void
attachLayoutAnimationParameters(
    View child,
    ViewGroup.LayoutParams params,
    int index,
    int count
)
void
attachViewToParent(View child, int index, ViewGroup.LayoutParams params)
void
boolean
void
void
childHasTransientStateChanged(
    View child,
    boolean childHasTransientState
)
void
void
void
void
void
debug(int depth)
void
void
void
detachViewsFromParent(int start, int count)
WindowInsets
boolean
void
void
dispatchCreateViewTranslationRequest(
    Map<AutofillId, long[]> viewIds,
    int[] supportedFormats,
    TranslationCapability capability,
    List<ViewTranslationRequest> requests
)
void
boolean
void
void
dispatchDrawableHotspotChanged(float x, float y)
void
void
boolean
boolean
boolean
boolean
boolean
void
dispatchPointerCaptureChanged(boolean hasCapture)
void
void
void
void
void
dispatchScrollCaptureSearch(
    Rect localVisibleRect,
    Point windowOffset,
    Consumer<ScrollCaptureTarget> targets
)
void
dispatchSetActivated(boolean activated)
void
dispatchSetPressed(boolean pressed)
void
dispatchSetSelected(boolean selected)
void
void

This method is deprecated.

void
boolean
boolean
boolean
dispatchUnhandledMove(View focused, int direction)
void
dispatchVisibilityChanged(View changedView, int visibility)
void
dispatchWindowFocusChanged(boolean hasFocus)
void
void
WindowInsets
WindowInsetsAnimation.Bounds
void

This method is deprecated.

void
boolean
drawChild(Canvas canvas, View child, long drawingTime)
void
void
View
OnBackInvokedDispatcher
void
findViewsWithText(
    ArrayList<View> outViews,
    CharSequence text,
    int flags
)
View
focusSearch(View focused, int direction)
void
boolean
View
getChildAt(int index)
int
int
getChildDrawingOrder(int childCount, int drawingPosition)
static int
getChildMeasureSpec(int spec, int padding, int childDimension)
boolean
boolean
getChildVisibleRect(View child, Rect r, Point offset)
boolean
boolean
int
View
LayoutAnimationController
Animation.AnimationListener
int
LayoutTransition
int
ViewGroupOverlay
int

This method is deprecated.

boolean
boolean
boolean
int
final void
invalidateChild(View child, Rect dirty)

This method is deprecated.

ViewParent
invalidateChildInParent(int[] location, Rect dirty)

This method is deprecated.

boolean

This method is deprecated.

boolean

This method is deprecated.

boolean
boolean

This method is deprecated.

boolean
boolean
boolean
void
final void
layout(int l, int t, int r, int b)
void
measureChild(
    View child,
    int parentWidthMeasureSpec,
    int parentHeightMeasureSpec
)
void
measureChildWithMargins(
    View child,
    int parentWidthMeasureSpec,
    int widthUsed,
    int parentHeightMeasureSpec,
    int heightUsed
)
void
measureChildren(int widthMeasureSpec, int heightMeasureSpec)
void
notifySubtreeAccessibilityStateChanged(
    View child,
    View source,
    int changeType
)
final void
final void
void
int[]
onCreateDrawableState(int extraSpace)
void
void
boolean
boolean
boolean
onNestedFling(
    View target,
    float velocityX,
    float velocityY,
    boolean consumed
)
boolean
onNestedPreFling(View target, float velocityX, float velocityY)
boolean
onNestedPrePerformAccessibilityAction(
    View target,
    int action,
    Bundle args
)
void
onNestedPreScroll(View target, int dx, int dy, int[] consumed)
void
onNestedScroll(
    View target,
    int dxConsumed,
    int dyConsumed,
    int dxUnconsumed,
    int dyUnconsumed
)
void
onNestedScrollAccepted(View child, View target, int axes)
boolean
onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect)
boolean
PointerIcon
onResolvePointerIcon(MotionEvent event, int pointerIndex)
boolean
onStartNestedScroll(View child, View target, int nestedScrollAxes)
void
void
void
void
void
void
void
removeDetachedView(View child, boolean animate)
void
void
removeViewAt(int index)
void
void
removeViews(int start, int count)
void
removeViewsInLayout(int start, int count)
void
requestChildFocus(View child, View focused)
boolean
requestChildRectangleOnScreen(
    View child,
    Rect rectangle,
    boolean immediate
)
void
requestDisallowInterceptTouchEvent(boolean disallowIntercept)
boolean
requestFocus(int direction, Rect previouslyFocusedRect)
boolean
void
boolean
void
void
setAddStatesFromChildren(boolean addsStates)
void

This method is deprecated.

void
setAnimationCacheEnabled(boolean enabled)

This method is deprecated.

void

This method is deprecated.

void
void

This method is deprecated.

void
setClipChildren(boolean clipChildren)
void
setClipToPadding(boolean clipToPadding)
void
setDescendantFocusability(int focusability)
void
void
void
setLayoutMode(int layoutMode)
void
void
void
void
setPersistentDrawingCache(int drawingCacheToKeep)

This method is deprecated.

void
void
setTouchscreenBlocksFocus(boolean touchscreenBlocksFocus)
void
setTransitionGroup(boolean isTransitionGroup)
void
boolean
ActionMode
startActionModeForChild(
    View originalView,
    ActionMode.Callback callback
)
void
void
void
suppressLayout(boolean suppress)
void

Constants

ARTWORK_DISPLAY_MODE_FILL

@UnstableApi
public static final int ARTWORK_DISPLAY_MODE_FILL = 2

The artwork covers the entire space of the player view. If the aspect ratio of the image is different than the player view some areas of the image are cropped.

ARTWORK_DISPLAY_MODE_FIT

@UnstableApi
public static final int ARTWORK_DISPLAY_MODE_FIT = 1

The artwork is fit into the player view and centered creating a letterbox style.

ARTWORK_DISPLAY_MODE_OFF

@UnstableApi
public static final int ARTWORK_DISPLAY_MODE_OFF = 0

No artwork is shown.

SHOW_BUFFERING_ALWAYS

@UnstableApi
public static final int SHOW_BUFFERING_ALWAYS = 2

The buffering view is always shown when the player is in the buffering state.

SHOW_BUFFERING_NEVER

@UnstableApi
public static final int SHOW_BUFFERING_NEVER = 0

The buffering view is never shown.

SHOW_BUFFERING_WHEN_PLAYING

@UnstableApi
public static final int SHOW_BUFFERING_WHEN_PLAYING = 1

The buffering view is shown when the player is in the buffering state and playWhenReady is true.

Public fields

artworkDisplayMode

@PlayerView.ArtworkDisplayMode
public int artworkDisplayMode

controllerAutoShow

public boolean controllerAutoShow

controllerHideOnTouch

public boolean controllerHideOnTouch

controllerShowTimeoutMs

public int controllerShowTimeoutMs

defaultArtwork

public @Nullable Drawable defaultArtwork

overlayFrameLayout

public final @Nullable FrameLayout overlayFrameLayout

player

public @Nullable Player player

subtitleView

public final @Nullable SubtitleView subtitleView

useController

public boolean useController

Public constructors

PlayerView

public PlayerView(Context context)

PlayerView

public PlayerView(Context context, @Nullable AttributeSet attrs)

PlayerView

public PlayerView(
    Context context,
    @Nullable AttributeSet attrs,
    int defStyleAttr
)

Public methods

dispatchKeyEvent

public boolean dispatchKeyEvent(KeyEvent event)

dispatchMediaKeyEvent

@UnstableApi
public boolean dispatchMediaKeyEvent(KeyEvent event)

Called to process media key events. Any KeyEvent can be passed but only media key events will be handled. Does nothing if playback controls are disabled.

Parameters
KeyEvent event

A key event.

Returns
boolean

Whether the key event was handled.

getAdOverlayInfos

public List<AdOverlayInfogetAdOverlayInfos()

Returns a list of AdOverlayInfo instances describing views that are on top of the ad view group, but that are essential for controlling playback and should be excluded from ad viewability measurements.

Each view must be either a fully transparent overlay (for capturing touch events), or a small piece of transient UI that is essential to the user experience of playback (such as a button to pause/resume playback or a transient full-screen or cast button). For more information see the documentation for your ads loader.

getAdViewGroup

public ViewGroup getAdViewGroup()

Returns the ViewGroup on top of the player that will show any ad UI, or null if playing audio-only ads. Any views on top of the returned view group must be described by AdOverlayInfos returned by getAdOverlayInfos, for accurate viewability measurement.

getArtworkDisplayMode

@UnstableApi
@PlayerView.ArtworkDisplayMode
public int getArtworkDisplayMode()

Returns the artwork display mode.

getControllerAutoShow

@UnstableApi
public boolean getControllerAutoShow()

Returns whether the playback controls are automatically shown when playback starts, pauses, ends, or fails. If set to false, the playback controls can be manually operated with showController and hideController.

getControllerHideOnTouch

@UnstableApi
public boolean getControllerHideOnTouch()

Returns whether the playback controls are hidden by touch events.

getControllerShowTimeoutMs

@UnstableApi
public int getControllerShowTimeoutMs()

Returns the playback controls timeout. The playback controls are automatically hidden after this duration of time has elapsed without user input and with playback or buffering in progress.

Returns
int

The timeout in milliseconds. A non-positive value will cause the controller to remain visible indefinitely.

getDefaultArtwork

@UnstableApi
public @Nullable Drawable getDefaultArtwork()

Returns the default artwork to display.

getOverlayFrameLayout

@UnstableApi
public @Nullable FrameLayout getOverlayFrameLayout()

Gets the overlay FrameLayout, which can be populated with UI elements to show on top of the player.

Returns
@Nullable FrameLayout

The overlay FrameLayout, or null if the layout has been customized and the overlay is not present.

getPlayer

public @Nullable Player getPlayer()

Returns the player currently set on this view, or null if no player is set.

getResizeMode

@UnstableApi
@AspectRatioFrameLayout.ResizeMode
public int getResizeMode()

Returns the ResizeMode.

getSubtitleView

@UnstableApi
public @Nullable SubtitleView getSubtitleView()

Gets the SubtitleView.

Returns
@Nullable SubtitleView

The SubtitleView, or null if the layout has been customized and the subtitle view is not present.

getUseArtwork

@UnstableApi
public boolean getUseArtwork()

getUseController

public boolean getUseController()

Returns whether the playback controls can be shown.

getVideoSurfaceView

@UnstableApi
public @Nullable View getVideoSurfaceView()

Gets the view onto which video is rendered. This is a:

  • SurfaceView by default, or if the surface_type attribute is set to surface_view.
  • TextureView if surface_type is texture_view.
  • SphericalGLSurfaceView if surface_type is spherical_gl_surface_view.
  • VideoDecoderGLSurfaceView if surface_type is video_decoder_gl_surface_view.
  • null if surface_type is none.
Returns
@Nullable View

The SurfaceView, TextureView, SphericalGLSurfaceView, VideoDecoderGLSurfaceView or null.

hideController

@UnstableApi
public void hideController()

Hides the playback controls. Does nothing if playback controls are disabled.

isControllerFullyVisible

@UnstableApi
public boolean isControllerFullyVisible()

Returns whether the controller is currently fully visible.

onPause

public void onPause()

Should be called when the player is no longer visible to the user, if the surface_type extends GLSurfaceView. It is the counterpart to onResume.

This method should typically be called in Activity.onStop(), or Activity.onPause() for API versions <= 23.

onResume

public void onResume()

Should be called when the player is visible to the user, if the surface_type extends GLSurfaceView. It is the counterpart to onPause.

This method should typically be called in Activity.onStart(), or Activity.onResume() for API versions <= 23.

onTrackballEvent

public boolean onTrackballEvent(MotionEvent ev)

performClick

public boolean performClick()

setArtworkDisplayMode

@UnstableApi
public void setArtworkDisplayMode(
    @PlayerView.ArtworkDisplayMode int artworkDisplayMode
)

Sets whether and how artwork is displayed if present in the media.

setAspectRatioListener

@UnstableApi
public void setAspectRatioListener(
    @Nullable AspectRatioFrameLayout.AspectRatioListener listener
)

Sets the AspectRatioFrameLayout.AspectRatioListener.

Parameters
@Nullable AspectRatioFrameLayout.AspectRatioListener listener

The listener to be notified about aspect ratios changes of the video content or the content frame.

setControllerAnimationEnabled

@UnstableApi
public void setControllerAnimationEnabled(boolean animationEnabled)

Sets whether controller animation is enabled.

setControllerAutoShow

@UnstableApi
public void setControllerAutoShow(boolean controllerAutoShow)

Sets whether the playback controls are automatically shown when playback starts, pauses, ends, or fails. If set to false, the playback controls can be manually operated with showController and hideController.

Parameters
boolean controllerAutoShow

Whether the playback controls are allowed to show automatically.

setControllerHideDuringAds

@UnstableApi
public void setControllerHideDuringAds(boolean controllerHideDuringAds)

Sets whether the playback controls are hidden when ads are playing. Controls are always shown during ads if they are enabled and the player is paused.

Parameters
boolean controllerHideDuringAds

Whether the playback controls are hidden when ads are playing.

setControllerHideOnTouch

@UnstableApi
public void setControllerHideOnTouch(boolean controllerHideOnTouch)

Sets whether the playback controls are hidden by touch events.

Parameters
boolean controllerHideOnTouch

Whether the playback controls are hidden by touch events.

setControllerOnFullScreenModeChangedListener

@UnstableApi
public void setControllerOnFullScreenModeChangedListener(
    @Nullable PlayerControlView.OnFullScreenModeChangedListener listener
)

Sets the PlayerControlView.OnFullScreenModeChangedListener.

Clears any listener set by setFullscreenButtonClickListener.

Parameters
@Nullable PlayerControlView.OnFullScreenModeChangedListener listener

The listener to be notified when the fullscreen button is clicked, or null to remove the current listener and hide the fullscreen button.

setControllerShowTimeoutMs

@UnstableApi
public void setControllerShowTimeoutMs(int controllerShowTimeoutMs)

Sets the playback controls timeout. The playback controls are automatically hidden after this duration of time has elapsed without user input and with playback or buffering in progress.

Parameters
int controllerShowTimeoutMs

The timeout in milliseconds. A non-positive value will cause the controller to remain visible indefinitely.

setControllerVisibilityListener

@UnstableApi
public void setControllerVisibilityListener(
    @Nullable PlayerControlView.VisibilityListener listener
)

Sets the PlayerControlView.VisibilityListener.

If listener is non-null then any listener set by setControllerVisibilityListener is removed.

setControllerVisibilityListener

public void setControllerVisibilityListener(
    @Nullable PlayerView.ControllerVisibilityListener listener
)

Sets the ControllerVisibilityListener.

If listener is non-null then any listener set by setControllerVisibilityListener is removed.

Parameters
@Nullable PlayerView.ControllerVisibilityListener listener

The listener to be notified about visibility changes, or null to remove the current listener.

setCustomErrorMessage

@UnstableApi
public void setCustomErrorMessage(@Nullable CharSequence message)

Sets a custom error message to be displayed by the view. The error message will be displayed permanently, unless it is cleared by passing null to this method.

Parameters
@Nullable CharSequence message

The message to display, or null to clear a previously set message.

setDefaultArtwork

@UnstableApi
public void setDefaultArtwork(@Nullable Drawable defaultArtwork)

Sets the default artwork to display if useArtwork is true and no artwork is present in the media.

Parameters
@Nullable Drawable defaultArtwork

the default artwork to display

setErrorMessageProvider

public void setErrorMessageProvider(
    @Nullable ErrorMessageProvider<PlaybackException> errorMessageProvider
)

Sets the optional ErrorMessageProvider.

Parameters
@Nullable ErrorMessageProvider<PlaybackException> errorMessageProvider

The error message provider.

setExtraAdGroupMarkers

@UnstableApi
public void setExtraAdGroupMarkers(
    @Nullable long[] extraAdGroupTimesMs,
    @Nullable boolean[] extraPlayedAdGroups
)

Sets the millisecond positions of extra ad markers relative to the start of the window (or timeline, if in multi-window mode) and whether each extra ad has been played or not. The markers are shown in addition to any ad markers for ads in the player's timeline.

Parameters
@Nullable long[] extraAdGroupTimesMs

The millisecond timestamps of the extra ad markers to show, or null to show no extra ad markers.

@Nullable boolean[] extraPlayedAdGroups

Whether each ad has been played, or null to show no extra ad markers.

setFullscreenButtonClickListener

public void setFullscreenButtonClickListener(
    @Nullable PlayerView.FullscreenButtonClickListener listener
)

Sets the FullscreenButtonClickListener.

Clears any listener set by setControllerOnFullScreenModeChangedListener.

Parameters
@Nullable PlayerView.FullscreenButtonClickListener listener

The listener to be notified when the fullscreen button is clicked, or null to remove the current listener and hide the fullscreen button.

setKeepContentOnPlayerReset

@UnstableApi
public void setKeepContentOnPlayerReset(boolean keepContentOnPlayerReset)

Sets whether the currently displayed video frame or media artwork is kept visible when the player is reset. A player reset is defined to mean the player being re-prepared with different media, the player transitioning to unprepared media or an empty list of media items, or the player being replaced or cleared by calling setPlayer.

If enabled, the currently displayed video frame or media artwork will be kept visible until the player set on the view has been successfully prepared with new media and loaded enough of it to have determined the available tracks. Hence enabling this option allows transitioning from playing one piece of media to another, or from using one player instance to another, without clearing the view's content.

If disabled, the currently displayed video frame or media artwork will be hidden as soon as the player is reset. Note that the video frame is hidden by making exo_shutter visible. Hence the video frame will not be hidden if using a custom layout that omits this view.

Parameters
boolean keepContentOnPlayerReset

Whether the currently displayed video frame or media artwork is kept visible when the player is reset.

setPlayer

public void setPlayer(@Nullable Player player)

Sets the Player to use.

To transition a Player from targeting one view to another, it's recommended to use switchTargetView rather than this method. If you do wish to use this method directly, be sure to attach the player to the new view before calling setPlayer(null) to detach it from the old one. This ordering is significantly more efficient and may allow for more seamless transitions.

Parameters
@Nullable Player player

The Player to use, or null to detach the current player. Only players which are accessed on the main thread are supported ( player.getApplicationLooper() == Looper.getMainLooper()).

setRepeatToggleModes

@UnstableApi
public void setRepeatToggleModes(
    @RepeatModeUtil.RepeatToggleModes int repeatToggleModes
)

Sets which repeat toggle modes are enabled.

Parameters
@RepeatModeUtil.RepeatToggleModes int repeatToggleModes

A set of RepeatModeUtil.RepeatToggleModes.

setResizeMode

@UnstableApi
public void setResizeMode(@AspectRatioFrameLayout.ResizeMode int resizeMode)

Sets the ResizeMode.

Parameters
@AspectRatioFrameLayout.ResizeMode int resizeMode

The ResizeMode.

setShowBuffering

@UnstableApi
public void setShowBuffering(@PlayerView.ShowBuffering int showBuffering)

Sets whether a buffering spinner is displayed when the player is in the buffering state. The buffering spinner is not displayed by default.

Parameters
@PlayerView.ShowBuffering int showBuffering

The mode that defines when the buffering spinner is displayed. One of SHOW_BUFFERING_NEVER, SHOW_BUFFERING_WHEN_PLAYING and SHOW_BUFFERING_ALWAYS.

setShowFastForwardButton

@UnstableApi
public void setShowFastForwardButton(boolean showFastForwardButton)

Sets whether the fast forward button is shown.

Parameters
boolean showFastForwardButton

Whether the fast forward button is shown.

setShowMultiWindowTimeBar

@UnstableApi
public void setShowMultiWindowTimeBar(boolean showMultiWindowTimeBar)

setShowNextButton

@UnstableApi
public void setShowNextButton(boolean showNextButton)

Sets whether the next button is shown.

Parameters
boolean showNextButton

Whether the next button is shown.

setShowPlayButtonIfPlaybackIsSuppressed

@UnstableApi
public void setShowPlayButtonIfPlaybackIsSuppressed(
    boolean showPlayButtonIfSuppressed
)

Sets whether a play button is shown if playback is suppressed.

The default is true.

Parameters
boolean showPlayButtonIfSuppressed

Whether to show a play button if playback is suppressed.

setShowPreviousButton

@UnstableApi
public void setShowPreviousButton(boolean showPreviousButton)

Sets whether the previous button is shown.

Parameters
boolean showPreviousButton

Whether the previous button is shown.

setShowRewindButton

@UnstableApi
public void setShowRewindButton(boolean showRewindButton)

Sets whether the rewind button is shown.

Parameters
boolean showRewindButton

Whether the rewind button is shown.

setShowShuffleButton

@UnstableApi
public void setShowShuffleButton(boolean showShuffleButton)

Sets whether the shuffle button is shown.

Parameters
boolean showShuffleButton

Whether the shuffle button is shown.

setShowSubtitleButton

@UnstableApi
public void setShowSubtitleButton(boolean showSubtitleButton)

Sets whether the subtitle button is shown.

Parameters
boolean showSubtitleButton

Whether the subtitle button is shown.

setShowVrButton

@UnstableApi
public void setShowVrButton(boolean showVrButton)

Sets whether the vr button is shown.

Parameters
boolean showVrButton

Whether the vr button is shown.

setShutterBackgroundColor

@UnstableApi
public void setShutterBackgroundColor(@ColorInt int color)

Sets the background color of the exo_shutter view.

Parameters
@ColorInt int color

The background color.

setUseArtwork

@UnstableApi
public void setUseArtwork(boolean useArtwork)

setUseController

public void setUseController(boolean useController)

Sets whether the playback controls can be shown. If set to false the playback controls are never visible and are disconnected from the player.

This call will update whether the view is clickable. After the call, the view will be clickable if playback controls can be shown or if the view has a registered click listener.

Parameters
boolean useController

Whether the playback controls can be shown.

setVisibility

public void setVisibility(int visibility)

showController

@UnstableApi
public void showController()

Shows the playback controls. Does nothing if playback controls are disabled.

The playback controls are automatically hidden during playback after {getControllerShowTimeoutMs}. They are shown indefinitely when playback has not started yet, is paused, has ended or failed.

switchTargetView

@UnstableApi
public static void switchTargetView(
    Player player,
    @Nullable PlayerView oldPlayerView,
    @Nullable PlayerView newPlayerView
)

Switches the view targeted by a given Player.

Parameters
Player player

The player whose target view is being switched.

@Nullable PlayerView oldPlayerView

The old view to detach from the player.

@Nullable PlayerView newPlayerView

The new view to attach to the player.

Protected methods

onContentAspectRatioChanged

@UnstableApi
protected void onContentAspectRatioChanged(
    @Nullable AspectRatioFrameLayout contentFrame,
    float aspectRatio
)

Called when there's a change in the desired aspect ratio of the content frame. The default implementation sets the aspect ratio of the content frame to the specified value.

Parameters
@Nullable AspectRatioFrameLayout contentFrame

The content frame, or null.

float aspectRatio

The aspect ratio to apply.