PlayerView


class PlayerView : FrameLayout, 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 = )
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 = )
annotation PlayerView.ShowBuffering

Determines when the buffering view is shown.

Constants

const Int

The artwork covers the entire space of the player view.

const Int

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

const Int

No artwork is shown.

const Int

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

const Int

The buffering view is never shown.

const Int

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

Public constructors

PlayerView(context: Context!)
PlayerView(context: Context!, attrs: AttributeSet?)
PlayerView(context: Context!, attrs: AttributeSet?, defStyleAttr: Int)

Public functions

Boolean
Boolean

Called to process media key events.

(Mutable)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 ResizeMode.

Boolean

This function is deprecated.

Use getArtworkDisplayMode instead.

View?

Gets the view onto which video is rendered.

Unit

Hides the playback controls.

Boolean

Returns whether the controller is currently fully visible.

Unit

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

Unit

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

Boolean
Boolean
Unit

Sets the AspectRatioFrameLayout.AspectRatioListener.

Unit

Sets whether controller animation is enabled.

Unit

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

Unit

This function is deprecated.

Use setFullscreenButtonClickListener instead.

Unit

This function is deprecated.

Use setControllerVisibilityListener instead.

Unit

Sets the ControllerVisibilityListener.

Unit

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

Unit

Sets the optional ErrorMessageProvider.

Unit
@UnstableApi
setExtraAdGroupMarkers(
    extraAdGroupTimesMs: LongArray?,
    extraPlayedAdGroups: BooleanArray?
)

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.

Unit

Sets the FullscreenButtonClickListener.

Unit
@UnstableApi
setKeepContentOnPlayerReset(keepContentOnPlayerReset: Boolean)

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

Unit

Sets which repeat toggle modes are enabled.

Unit

Sets the ResizeMode.

Unit

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

Unit

Sets whether the fast forward button is shown.

Unit

This function is deprecated.

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

Unit

Sets whether the next button is shown.

Unit
@UnstableApi
setShowPlayButtonIfPlaybackIsSuppressed(
    showPlayButtonIfSuppressed: Boolean
)

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

Unit

Sets whether the previous button is shown.

Unit

Sets whether the rewind button is shown.

Unit

Sets whether the shuffle button is shown.

Unit

Sets whether the subtitle button is shown.

Unit

Sets whether the vr button is shown.

Unit

Sets the background color of the exo_shutter view.

Unit

This function is deprecated.

Use setArtworkDisplayMode instead.

Unit
setVisibility(visibility: Int)
Unit

Shows the playback controls.

java-static Unit
@UnstableApi
switchTargetView(
    player: Player!,
    oldPlayerView: PlayerView?,
    newPlayerView: PlayerView?
)

Switches the view targeted by a given Player.

Protected functions

Unit
@UnstableApi
onContentAspectRatioChanged(
    contentFrame: AspectRatioFrameLayout?,
    aspectRatio: Float
)

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

Inherited Constants

From android.view.View
const Int
const Int
const Int
const Int
const Int
const Int
const Property<View!, Float!>!
const Int
const String!
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE = "creditCardExpirationDate"
const String!
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = "creditCardExpirationDay"
const String!
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = "creditCardExpirationMonth"
const String!
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR = "creditCardExpirationYear"
const String!
const String!
AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE = "creditCardSecurityCode"
const String!
const String!
const String!
const String!
const String!
const String!
const String!
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const Int
const Int
const Int
const Int
const Int
const Int
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const Int
const Int
const Int
const Int
const Int
const Int
const Int
GONE = 8
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
KEEP_SCREEN_ON = 67108864
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
NO_ID = -1
const Int
const Int
const Int
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const Property<View!, Float!>!
const Property<View!, Float!>!
const Property<View!, Float!>!
const Property<View!, Float!>!
const Property<View!, Float!>!
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const IntArray<Int>!
const IntArray<Int>!
const Int
const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Property<View!, Float!>!
const Property<View!, Float!>!
const Property<View!, Float!>!
const String!
VIEW_LOG_TAG = "View"
const Int
const IntArray<Int>!
const Property<View!, Float!>!
const Property<View!, Float!>!
const Property<View!, Float!>!
From android.view.ViewGroup
const Int
const Int
const Int
const Int
const Int
const Int
const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

Inherited functions

From android.widget.FrameLayout
From android.view.View
Unit
Unit
Unit
ViewPropertyAnimator!
Unit
Unit
Boolean
Unit
Unit

This function is deprecated.

Unit
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Unit
Unit
Unit
Boolean
Unit
Unit
java-static Int
combineMeasuredStates(curState: Int, newState: Int)
Int
Int
Int
Unit
WindowInsets!
computeSystemWindowInsets(in: WindowInsets!, outLocalInsets: Rect!)
Int
Int
Int
AccessibilityNodeInfo!
Unit
Unit

This function is deprecated.

Boolean
Boolean
dispatchNestedFling(velocityX: Float, velocityY: Float, consumed: Boolean)
Boolean
dispatchNestedPreFling(velocityX: Float, velocityY: Float)
Boolean
dispatchNestedPrePerformAccessibilityAction(
    action: Int,
    arguments: Bundle!
)
Boolean
dispatchNestedPreScroll(
    dx: Int,
    dy: Int,
    consumed: IntArray!,
    offsetInWindow: IntArray!
)
Boolean
dispatchNestedScroll(
    dxConsumed: Int,
    dyConsumed: Int,
    dxUnconsumed: Int,
    dyUnconsumed: Int,
    offsetInWindow: IntArray!
)
Boolean
Unit
draw(canvas: Canvas!)
Unit
OnBackInvokedDispatcher!
T!
<T : View?> findViewById(id: Int)
T!
<T : View?> findViewWithTag(tag: Any!)
Boolean

This function is deprecated.

Unit
forceHasOverlappingRendering(hasOverlappingRendering: Boolean)
Unit
Unit
generateDisplayHash(
    hashAlgorithm: String!,
    bounds: Rect!,
    executor: Executor!,
    callback: DisplayHashResultCallback!
)
java-static Int
View.AccessibilityDelegate!
Int
AccessibilityNodeProvider!
CharSequence!
Int
Int
String!
String!
Float
Animation!
Matrix!
IBinder!
IntArray<Int>!
(Mutable)Map<Int!, Int!>!
Array<String!>!
AutofillId!
Int
AutofillValue!
Drawable!
BlendMode!
ColorStateList!
PorterDuff.Mode!
Int
Int
Float
Int
Float
Rect!
Boolean
getClipBounds(outRect: Rect!)
Boolean
ContentCaptureSession!
CharSequence!
Context!
ContextMenu.ContextMenuInfo!
Boolean
java-static Int
getDefaultSize(size: Int, measureSpec: Int)
Display!
IntArray<Int>!
Bitmap!

This function is deprecated.

Int

This function is deprecated.

Int

This function is deprecated.

Unit
getDrawingRect(outRect: Rect!)
Long
Float
Int
Boolean
Boolean
Int
ArrayList<View!>!
getFocusables(direction: Int)
Unit
Drawable!
Int
BlendMode!
ColorStateList!
PorterDuff.Mode!
Boolean
getGlobalVisibleRect(r: Rect!, globalOffset: Point!)
Handler!
Float
Float
Float
Float
Runnable!
Boolean
Int
Unit
getHitRect(outRect: Rect!)
Int
Int
Drawable!
Drawable!
Int
Int
Int
Int
Boolean
KeyEvent.DispatcherState!
Int
Int
Int
ViewGroup.LayoutParams!
Int
Float
Int
Boolean
Unit
Unit
Unit
Matrix!
Int
Int
Int
Int
Int
Int
Int
Int
Int
Int
Int
Int
Int
View.OnFocusChangeListener!
Int
ViewOutlineProvider!
Int
Int
ViewOverlay!
Int
Int
Int
Int
Int
Int
ViewParent!
ViewParent!
Float
Float
PointerIcon!
(Mutable)List<Rect!>!
Array<String!>!
Resources!
Boolean
Int
Float
Int
AttachedSurfaceControl!
View!
WindowInsets!
Float
Float
Float
Float
Float
Int
Int
Int
Int
Int
Int
Int
Int
Int
Int
CharSequence!
StateListAnimator!
Int
Int
(Mutable)List<Rect!>!
Int

This function is deprecated.

Any!
Int
Int
CharSequence!
Int
Float
Int
TouchDelegate!
ArrayList<View!>!
Float
String!
Float
Float
Float
Long
Int
Int
Drawable!
Drawable!
Int
ViewTranslationResponse!
ViewTreeObserver!
Int
Int
Int
WindowId!
WindowInsetsController!
Int

This function is deprecated.

IBinder!
Int
Unit
Float
Float
Float
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
java-static View!
inflate(context: Context!, resource: Int, root: ViewGroup!)
Unit
invalidate(dirty: Rect!)

This function is deprecated.

Unit
Unit
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean

This function is deprecated.

Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
View!
keyboardNavigationClusterSearch(currentCluster: View!, direction: Int)
Unit
measure(widthMeasureSpec: Int, heightMeasureSpec: Int)
java-static IntArray<Int>!
mergeDrawableStates(baseState: IntArray!, additionalState: IntArray!)
Unit
Unit
Unit
Unit
WindowInsets!
Unit
Boolean
Boolean
Unit
Unit
InputConnection!
Unit
onCreateViewTranslationRequest(
    supportedFormats: IntArray!,
    requestsCollector: Consumer<ViewTranslationRequest!>!
)
Unit
onCreateVirtualViewTranslationRequests(
    virtualIds: LongArray!,
    supportedFormats: IntArray!,
    requestsCollector: Consumer<ViewTranslationRequest!>!
)
Unit
Boolean
Unit
onDraw(canvas: Canvas!)
Unit
Unit
Boolean
Unit
Unit
Unit
onFocusChanged(
    gainFocus: Boolean,
    direction: Int,
    previouslyFocusedRect: Rect!
)
Boolean
Unit
Boolean
Unit
Unit
Boolean
onKeyDown(keyCode: Int, event: KeyEvent!)
Boolean
onKeyLongPress(keyCode: Int, event: KeyEvent!)
Boolean
onKeyMultiple(keyCode: Int, repeatCount: Int, event: KeyEvent!)
Boolean
onKeyPreIme(keyCode: Int, event: KeyEvent!)
Boolean
onKeyShortcut(keyCode: Int, event: KeyEvent!)
Boolean
onKeyUp(keyCode: Int, event: KeyEvent!)
Unit
onOverScrolled(
    scrollX: Int,
    scrollY: Int,
    clampedX: Boolean,
    clampedY: Boolean
)
Unit
Unit
Unit
Unit
Unit
Unit
Unit
ContentInfo!
Unit
Unit
onRtlPropertiesChanged(layoutDirection: Int)
Parcelable!
Unit
onScreenStateChanged(screenState: Int)
Unit
onScrollCaptureSearch(
    localVisibleRect: Rect!,
    windowOffset: Point!,
    targets: Consumer<ScrollCaptureTarget!>!
)
Unit
onScrollChanged(l: Int, t: Int, oldl: Int, oldt: Int)
Boolean
onSetAlpha(alpha: Int)
Unit
onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int)
Unit
Boolean
Unit
Unit
Unit
Unit
onVisibilityChanged(changedView: View!, visibility: Int)
Unit
onWindowFocusChanged(hasWindowFocus: Boolean)
Unit

This function is deprecated.

Unit
Boolean
overScrollBy(
    deltaX: Int,
    deltaY: Int,
    scrollX: Int,
    scrollY: Int,
    scrollRangeX: Int,
    scrollRangeY: Int,
    maxOverScrollX: Int,
    maxOverScrollY: Int,
    isTouchEvent: Boolean
)
Boolean
performAccessibilityAction(action: Int, arguments: Bundle!)
Boolean
Boolean
performHapticFeedback(feedbackConstant: Int)
Boolean
ContentInfo!
Unit
playSoundEffect(soundConstant: Int)
Boolean
post(action: Runnable!)
Boolean
postDelayed(action: Runnable!, delayMillis: Long)
Unit
Unit
postInvalidateDelayed(delayMilliseconds: Long)
Unit
Unit
Unit
postOnAnimationDelayed(action: Runnable!, delayMillis: Long)
Unit
Unit
Boolean
Unit
Unit
Unit
Unit
Unit

This function is deprecated.

Boolean
Unit
Unit
Boolean
Unit
T!
<T : View?> requireViewById(id: Int)
Unit
java-static Int
resolveSize(size: Int, measureSpec: Int)
java-static Int
resolveSizeAndState(size: Int, measureSpec: Int, childMeasuredState: Int)
Unit
Unit
saveAttributeDataForStyleable(
    context: Context!,
    styleable: IntArray!,
    attrs: AttributeSet!,
    t: TypedArray!,
    defStyleAttr: Int,
    defStyleRes: Int
)
Unit
Unit
scheduleDrawable(who: Drawable!, what: Runnable!, when: Long)
Unit
scrollBy(x: Int, y: Int)
Unit
scrollTo(x: Int, y: Int)
Unit
Unit
Unit
setAccessibilityDataSensitive(accessibilityDataSensitive: Int)
Unit
Unit
Unit
Unit
setAccessibilityPaneTitle(accessibilityPaneTitle: CharSequence!)
Unit
Unit
Unit
setActivated(activated: Boolean)
Unit
setAllowClickWhenDisabled(clickableWhenDisabled: Boolean)
Unit
Unit
Unit
setAlpha(alpha: Float)
Unit
setAnimation(animation: Animation!)
Unit
Unit
Unit
setAutofillHints(autofillHints: Array<String!>!)
Unit
Unit
setBackground(background: Drawable!)
Unit
Unit

This function is deprecated.

Unit
Unit
Unit
Unit
Unit
setBottom(bottom: Int)
Unit
Unit
setClickable(clickable: Boolean)
Unit
setClipBounds(clipBounds: Rect!)
Unit
setClipToOutline(clipToOutline: Boolean)
Unit
Unit
setContentDescription(contentDescription: CharSequence!)
Unit
setContextClickable(contextClickable: Boolean)
Unit
setDefaultFocusHighlightEnabled(defaultFocusHighlightEnabled: Boolean)
Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit
Unit
setElevation(elevation: Float)
Unit
setEnabled(enabled: Boolean)
Unit
Unit
Unit
setFitsSystemWindows(fitSystemWindows: Boolean)
Unit
setFocusable(focusable: Boolean)
Unit
setFocusableInTouchMode(focusableInTouchMode: Boolean)
Unit
setFocusedByDefault(isFocusedByDefault: Boolean)
Unit
Unit
setForeground(foreground: Drawable!)
Unit
Unit
Unit
Unit
setHandwritingBoundsOffsets(
    offsetLeft: Float,
    offsetTop: Float,
    offsetRight: Float,
    offsetBottom: Float
)
Unit
Unit
setHapticFeedbackEnabled(hapticFeedbackEnabled: Boolean)
Unit
setHasTransientState(hasTransientState: Boolean)
Unit
setHorizontalFadingEdgeEnabled(horizontalFadingEdgeEnabled: Boolean)
Unit
setHorizontalScrollBarEnabled(horizontalScrollBarEnabled: Boolean)
Unit
Unit
Unit
setHovered(hovered: Boolean)
Unit
setId(id: Int)
Unit
Unit
Unit
Unit
setIsCredential(isCredential: Boolean)
Unit
setIsHandwritingDelegate(isHandwritingDelegate: Boolean)
Unit
setKeepScreenOn(keepScreenOn: Boolean)
Unit
Unit
Unit
Unit
setLayerType(layerType: Int, paint: Paint!)
Unit
setLayoutDirection(layoutDirection: Int)
Unit
Unit
setLeft(left: Int)
Unit
setLeftTopRightBottom(left: Int, top: Int, right: Int, bottom: Int)
Unit
setLongClickable(longClickable: Boolean)
Unit
setMeasuredDimension(measuredWidth: Int, measuredHeight: Int)
Unit
setMinimumHeight(minHeight: Int)
Unit
setMinimumWidth(minWidth: Int)
Unit
Unit
setNextClusterForwardId(nextClusterForwardId: Int)
Unit
setNextFocusDownId(nextFocusDownId: Int)
Unit
setNextFocusForwardId(nextFocusForwardId: Int)
Unit
setNextFocusLeftId(nextFocusLeftId: Int)
Unit
setNextFocusRightId(nextFocusRightId: Int)
Unit
setNextFocusUpId(nextFocusUpId: Int)
Unit
Unit
Unit
Unit
Unit
Unit
Unit
Unit
Unit
Unit
Unit
Unit
setOnReceiveContentListener(
    mimeTypes: Array<String!>!,
    listener: OnReceiveContentListener!
)
Unit
Unit

This function is deprecated.

Unit
Unit
Unit
Unit
Unit
setOverScrollMode(overScrollMode: Int)
Unit
setPadding(left: Int, top: Int, right: Int, bottom: Int)
Unit
setPaddingRelative(start: Int, top: Int, end: Int, bottom: Int)
Unit
setPivotX(pivotX: Float)
Unit
setPivotY(pivotY: Float)
Unit
setPointerIcon(pointerIcon: PointerIcon!)
Unit
setPreferKeepClear(preferKeepClear: Boolean)
Unit
Unit
setPressed(pressed: Boolean)
Unit
setRenderEffect(renderEffect: RenderEffect!)
Unit
setRevealOnFocusHint(revealOnFocus: Boolean)
Unit
setRight(right: Int)
Unit
setRotation(rotation: Float)
Unit
setRotationX(rotationX: Float)
Unit
setRotationY(rotationY: Float)
Unit
Unit
Unit
setScaleX(scaleX: Float)
Unit
setScaleY(scaleY: Float)
Unit
setScreenReaderFocusable(screenReaderFocusable: Boolean)
Unit
setScrollBarDefaultDelayBeforeFade(
    scrollBarDefaultDelayBeforeFade: Int
)
Unit
setScrollBarFadeDuration(scrollBarFadeDuration: Int)
Unit
setScrollBarSize(scrollBarSize: Int)
Unit
Unit
Unit
Unit
setScrollContainer(isScrollContainer: Boolean)
Unit
setScrollIndicators(indicators: Int)
Unit
setScrollX(value: Int)
Unit
setScrollY(value: Int)
Unit
Unit
setSelected(selected: Boolean)
Unit
setSoundEffectsEnabled(soundEffectsEnabled: Boolean)
Unit
setStateDescription(stateDescription: CharSequence!)
Unit
Unit
Unit

This function is deprecated.

Unit
setTag(tag: Any!)
Unit
setTextAlignment(textAlignment: Int)
Unit
setTextDirection(textDirection: Int)
Unit
Unit
setTop(top: Int)
Unit
Unit
Unit
setTransitionName(transitionName: String!)
Unit
Unit
setTranslationX(translationX: Float)
Unit
setTranslationY(translationY: Float)
Unit
setTranslationZ(translationZ: Float)
Unit
setVerticalFadingEdgeEnabled(verticalFadingEdgeEnabled: Boolean)
Unit
setVerticalScrollBarEnabled(verticalScrollBarEnabled: Boolean)
Unit
Unit
Unit
Unit
Unit
setWillNotCacheDrawing(willNotCacheDrawing: Boolean)

This function is deprecated.

Unit
setWillNotDraw(willNotDraw: Boolean)
Unit
setX(x: Float)
Unit
setY(y: Float)
Unit
setZ(z: Float)
Boolean
ActionMode!
Unit
Boolean
startDrag(
    data: ClipData!,
    shadowBuilder: View.DragShadowBuilder!,
    myLocalState: Any!,
    flags: Int
)

This function is deprecated.

Boolean
startDragAndDrop(
    data: ClipData!,
    shadowBuilder: View.DragShadowBuilder!,
    myLocalState: Any!,
    flags: Int
)
Boolean
Unit
String!
Unit
Unit
Unit
Unit
Boolean
Boolean

This function is deprecated.

Boolean
From android.view.ViewGroup
Unit
Unit
addExtraDataToAccessibilityNodeInfo(
    info: AccessibilityNodeInfo!,
    extraDataKey: String!,
    arguments: Bundle!
)
Unit
addFocusables(views: ArrayList<View!>!, direction: Int, focusableMode: Int)
Unit
addKeyboardNavigationClusters(
    views: (Mutable)Collection<View!>!,
    direction: Int
)
Boolean
Unit
Unit
addView(child: View!)
Boolean
addViewInLayout(child: View!, index: Int, params: ViewGroup.LayoutParams!)
Unit
attachLayoutAnimationParameters(
    child: View!,
    params: ViewGroup.LayoutParams!,
    index: Int,
    count: Int
)
Unit
attachViewToParent(child: View!, index: Int, params: ViewGroup.LayoutParams!)
Unit
Boolean
Unit
Unit
childHasTransientStateChanged(
    child: View!,
    childHasTransientState: Boolean
)
Unit
Unit
Unit
Unit
Unit
debug(depth: Int)
Unit
Unit
Unit
detachViewsFromParent(start: Int, count: Int)
WindowInsets!
Boolean
Unit
Unit
dispatchCreateViewTranslationRequest(
    viewIds: (Mutable)Map<AutofillId!, LongArray!>!,
    supportedFormats: IntArray!,
    capability: TranslationCapability!,
    requests: (Mutable)List<ViewTranslationRequest!>!
)
Unit
Boolean
Unit
dispatchDraw(canvas: Canvas!)
Unit
Unit
Unit
Boolean
Boolean
Boolean
Boolean
Boolean
Unit
Unit
Unit
Unit
Unit
Unit
dispatchScrollCaptureSearch(
    localVisibleRect: Rect!,
    windowOffset: Point!,
    targets: Consumer<ScrollCaptureTarget!>!
)
Unit
Unit
Unit
Unit
Unit

This function is deprecated.

Unit
Boolean
Boolean
Boolean
dispatchUnhandledMove(focused: View!, direction: Int)
Unit
dispatchVisibilityChanged(changedView: View!, visibility: Int)
Unit
Unit
Unit
WindowInsets!
dispatchWindowInsetsAnimationProgress(
    insets: WindowInsets!,
    runningAnimations: (Mutable)List<WindowInsetsAnimation!>!
)
WindowInsetsAnimation.Bounds!
Unit

This function is deprecated.

Unit
Boolean
drawChild(canvas: Canvas!, child: View!, drawingTime: Long)
Unit
Unit
View!
OnBackInvokedDispatcher!
Unit
findViewsWithText(
    outViews: ArrayList<View!>!,
    text: CharSequence!,
    flags: Int
)
View!
focusSearch(focused: View!, direction: Int)
Unit
Boolean
View!
getChildAt(index: Int)
Int
Int
getChildDrawingOrder(childCount: Int, drawingPosition: Int)
java-static Int
getChildMeasureSpec(spec: Int, padding: Int, childDimension: Int)
Boolean
Boolean
getChildVisibleRect(child: View!, r: Rect!, offset: Point!)
Boolean
Boolean
Int
View!
LayoutAnimationController!
Animation.AnimationListener!
Int
LayoutTransition!
Int
ViewGroupOverlay!
Int

This function is deprecated.

Boolean
Boolean
Boolean
Int
indexOfChild(child: View!)
Unit
invalidateChild(child: View!, dirty: Rect!)

This function is deprecated.

ViewParent!
invalidateChildInParent(location: IntArray!, dirty: Rect!)

This function is deprecated.

Boolean

This function is deprecated.

Boolean

This function is deprecated.

Boolean
Boolean

This function is deprecated.

Boolean
Boolean
Boolean
Unit
Unit
layout(l: Int, t: Int, r: Int, b: Int)
Unit
measureChild(
    child: View!,
    parentWidthMeasureSpec: Int,
    parentHeightMeasureSpec: Int
)
Unit
measureChildWithMargins(
    child: View!,
    parentWidthMeasureSpec: Int,
    widthUsed: Int,
    parentHeightMeasureSpec: Int,
    heightUsed: Int
)
Unit
measureChildren(widthMeasureSpec: Int, heightMeasureSpec: Int)
Unit
notifySubtreeAccessibilityStateChanged(
    child: View!,
    source: View!,
    changeType: Int
)
Unit
offsetDescendantRectToMyCoords(descendant: View!, rect: Rect!)
Unit
offsetRectIntoDescendantCoords(descendant: View!, rect: Rect!)
Unit
IntArray<Int>!
Unit
onDescendantInvalidated(child: View!, target: View!)
Unit
Boolean
Boolean
Boolean
onNestedFling(
    target: View!,
    velocityX: Float,
    velocityY: Float,
    consumed: Boolean
)
Boolean
onNestedPreFling(target: View!, velocityX: Float, velocityY: Float)
Boolean
onNestedPrePerformAccessibilityAction(
    target: View!,
    action: Int,
    args: Bundle!
)
Unit
onNestedPreScroll(target: View!, dx: Int, dy: Int, consumed: IntArray!)
Unit
onNestedScroll(
    target: View!,
    dxConsumed: Int,
    dyConsumed: Int,
    dxUnconsumed: Int,
    dyUnconsumed: Int
)
Unit
onNestedScrollAccepted(child: View!, target: View!, axes: Int)
Boolean
onRequestFocusInDescendants(direction: Int, previouslyFocusedRect: Rect!)
Boolean
PointerIcon!
onResolvePointerIcon(event: MotionEvent!, pointerIndex: Int)
Boolean
onStartNestedScroll(child: View!, target: View!, nestedScrollAxes: Int)
Unit
Unit
onViewAdded(child: View!)
Unit
Unit
Unit
Unit
Unit
removeDetachedView(child: View!, animate: Boolean)
Unit
removeView(view: View!)
Unit
removeViewAt(index: Int)
Unit
Unit
removeViews(start: Int, count: Int)
Unit
removeViewsInLayout(start: Int, count: Int)
Unit
requestChildFocus(child: View!, focused: View!)
Boolean
requestChildRectangleOnScreen(
    child: View!,
    rectangle: Rect!,
    immediate: Boolean
)
Unit
Boolean
requestFocus(direction: Int, previouslyFocusedRect: Rect!)
Boolean
Unit
Boolean
Unit
Unit
Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit
Unit

This function is deprecated.

Unit
setClipChildren(clipChildren: Boolean)
Unit
setClipToPadding(clipToPadding: Boolean)
Unit
Unit
Unit
Unit
setLayoutMode(layoutMode: Int)
Unit
Unit
Unit
Unit
setPersistentDrawingCache(drawingCacheToKeep: Int)

This function is deprecated.

Unit
Unit
setTouchscreenBlocksFocus(touchscreenBlocksFocus: Boolean)
Unit
setTransitionGroup(isTransitionGroup: Boolean)
Unit
Boolean
showContextMenuForChild(originalView: View!)
ActionMode!
startActionModeForChild(
    originalView: View!,
    callback: ActionMode.Callback!
)
Unit
Unit
Unit
Unit

Constants

ARTWORK_DISPLAY_MODE_FILL

@UnstableApi
const val ARTWORK_DISPLAY_MODE_FILL = 2: Int

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
const val ARTWORK_DISPLAY_MODE_FIT = 1: Int

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

ARTWORK_DISPLAY_MODE_OFF

@UnstableApi
const val ARTWORK_DISPLAY_MODE_OFF = 0: Int

No artwork is shown.

SHOW_BUFFERING_ALWAYS

@UnstableApi
const val SHOW_BUFFERING_ALWAYS = 2: Int

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

SHOW_BUFFERING_NEVER

@UnstableApi
const val SHOW_BUFFERING_NEVER = 0: Int

The buffering view is never shown.

SHOW_BUFFERING_WHEN_PLAYING

@UnstableApi
const val SHOW_BUFFERING_WHEN_PLAYING = 1: Int

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

Public constructors

PlayerView

PlayerView(context: Context!)

PlayerView

PlayerView(context: Context!, attrs: AttributeSet?)

PlayerView

PlayerView(context: Context!, attrs: AttributeSet?, defStyleAttr: Int)

Public functions

dispatchKeyEvent

fun dispatchKeyEvent(event: KeyEvent!): Boolean

dispatchMediaKeyEvent

@UnstableApi
fun dispatchMediaKeyEvent(event: KeyEvent!): Boolean

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
event: KeyEvent!

A key event.

Returns
Boolean

Whether the key event was handled.

getAdOverlayInfos

fun getAdOverlayInfos(): (Mutable)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.

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

fun getAdViewGroup(): ViewGroup!

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.

getUseArtwork

@UnstableApi
fun getUseArtwork(): Boolean

getVideoSurfaceView

@UnstableApi
fun getVideoSurfaceView(): View?

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
View?

The SurfaceView, TextureView, SphericalGLSurfaceView, VideoDecoderGLSurfaceView or null.

hideController

@UnstableApi
fun hideController(): Unit

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

isControllerFullyVisible

@UnstableApi
fun isControllerFullyVisible(): Boolean

Returns whether the controller is currently fully visible.

onPause

fun onPause(): Unit

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

fun onResume(): Unit

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

fun onTrackballEvent(ev: MotionEvent!): Boolean

performClick

fun performClick(): Boolean

setAspectRatioListener

@UnstableApi
fun setAspectRatioListener(
    listener: AspectRatioFrameLayout.AspectRatioListener?
): Unit

Sets the AspectRatioFrameLayout.AspectRatioListener.

Parameters
listener: AspectRatioFrameLayout.AspectRatioListener?

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

setControllerAnimationEnabled

@UnstableApi
fun setControllerAnimationEnabled(animationEnabled: Boolean): Unit

Sets whether controller animation is enabled.

setControllerHideDuringAds

@UnstableApi
fun setControllerHideDuringAds(controllerHideDuringAds: Boolean): Unit

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
controllerHideDuringAds: Boolean

Whether the playback controls are hidden when ads are playing.

setControllerOnFullScreenModeChangedListener

@UnstableApi
fun setControllerOnFullScreenModeChangedListener(
    listener: PlayerControlView.OnFullScreenModeChangedListener?
): Unit

Sets the PlayerControlView.OnFullScreenModeChangedListener.

Clears any listener set by setFullscreenButtonClickListener.

Parameters
listener: PlayerControlView.OnFullScreenModeChangedListener?

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

setControllerVisibilityListener

@UnstableApi
fun setControllerVisibilityListener(
    listener: PlayerControlView.VisibilityListener?
): Unit

Sets the PlayerControlView.VisibilityListener.

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

setControllerVisibilityListener

fun setControllerVisibilityListener(
    listener: PlayerView.ControllerVisibilityListener?
): Unit

Sets the ControllerVisibilityListener.

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

Parameters
listener: PlayerView.ControllerVisibilityListener?

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

setCustomErrorMessage

@UnstableApi
fun setCustomErrorMessage(message: CharSequence?): Unit

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
message: CharSequence?

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

setErrorMessageProvider

fun setErrorMessageProvider(
    errorMessageProvider: ErrorMessageProvider<PlaybackException!>?
): Unit

Sets the optional ErrorMessageProvider.

Parameters
errorMessageProvider: ErrorMessageProvider<PlaybackException!>?

The error message provider.

setExtraAdGroupMarkers

@UnstableApi
fun setExtraAdGroupMarkers(
    extraAdGroupTimesMs: LongArray?,
    extraPlayedAdGroups: BooleanArray?
): Unit

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
extraAdGroupTimesMs: LongArray?

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

extraPlayedAdGroups: BooleanArray?

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

setFullscreenButtonClickListener

fun setFullscreenButtonClickListener(
    listener: PlayerView.FullscreenButtonClickListener?
): Unit

Sets the FullscreenButtonClickListener.

Clears any listener set by setControllerOnFullScreenModeChangedListener.

Parameters
listener: PlayerView.FullscreenButtonClickListener?

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
fun setKeepContentOnPlayerReset(keepContentOnPlayerReset: Boolean): Unit

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
keepContentOnPlayerReset: Boolean

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

setRepeatToggleModes

@UnstableApi
fun setRepeatToggleModes(
    @RepeatModeUtil.RepeatToggleModes repeatToggleModes: Int
): Unit

Sets which repeat toggle modes are enabled.

Parameters
@RepeatModeUtil.RepeatToggleModes repeatToggleModes: Int

A set of RepeatModeUtil.RepeatToggleModes.

setResizeMode

@UnstableApi
fun setResizeMode(@AspectRatioFrameLayout.ResizeMode resizeMode: Int): Unit

Sets the ResizeMode.

Parameters
@AspectRatioFrameLayout.ResizeMode resizeMode: Int

The ResizeMode.

setShowBuffering

@UnstableApi
fun setShowBuffering(@PlayerView.ShowBuffering showBuffering: Int): Unit

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 showBuffering: Int

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
fun setShowFastForwardButton(showFastForwardButton: Boolean): Unit

Sets whether the fast forward button is shown.

Parameters
showFastForwardButton: Boolean

Whether the fast forward button is shown.

setShowMultiWindowTimeBar

@UnstableApi
fun setShowMultiWindowTimeBar(showMultiWindowTimeBar: Boolean): Unit

setShowNextButton

@UnstableApi
fun setShowNextButton(showNextButton: Boolean): Unit

Sets whether the next button is shown.

Parameters
showNextButton: Boolean

Whether the next button is shown.

setShowPlayButtonIfPlaybackIsSuppressed

@UnstableApi
fun setShowPlayButtonIfPlaybackIsSuppressed(
    showPlayButtonIfSuppressed: Boolean
): Unit

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

The default is true.

Parameters
showPlayButtonIfSuppressed: Boolean

Whether to show a play button if playback is suppressed.

setShowPreviousButton

@UnstableApi
fun setShowPreviousButton(showPreviousButton: Boolean): Unit

Sets whether the previous button is shown.

Parameters
showPreviousButton: Boolean

Whether the previous button is shown.

setShowRewindButton

@UnstableApi
fun setShowRewindButton(showRewindButton: Boolean): Unit

Sets whether the rewind button is shown.

Parameters
showRewindButton: Boolean

Whether the rewind button is shown.

setShowShuffleButton

@UnstableApi
fun setShowShuffleButton(showShuffleButton: Boolean): Unit

Sets whether the shuffle button is shown.

Parameters
showShuffleButton: Boolean

Whether the shuffle button is shown.

setShowSubtitleButton

@UnstableApi
fun setShowSubtitleButton(showSubtitleButton: Boolean): Unit

Sets whether the subtitle button is shown.

Parameters
showSubtitleButton: Boolean

Whether the subtitle button is shown.

setShowVrButton

@UnstableApi
fun setShowVrButton(showVrButton: Boolean): Unit

Sets whether the vr button is shown.

Parameters
showVrButton: Boolean

Whether the vr button is shown.

setShutterBackgroundColor

@UnstableApi
fun setShutterBackgroundColor(color: @ColorInt Int): Unit

Sets the background color of the exo_shutter view.

Parameters
color: @ColorInt Int

The background color.

setUseArtwork

@UnstableApi
fun setUseArtwork(useArtwork: Boolean): Unit

setVisibility

fun setVisibility(visibility: Int): Unit

showController

@UnstableApi
fun showController(): Unit

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
java-static fun switchTargetView(
    player: Player!,
    oldPlayerView: PlayerView?,
    newPlayerView: PlayerView?
): Unit

Switches the view targeted by a given Player.

Parameters
player: Player!

The player whose target view is being switched.

oldPlayerView: PlayerView?

The old view to detach from the player.

newPlayerView: PlayerView?

The new view to attach to the player.

Protected functions

onContentAspectRatioChanged

@UnstableApi
protected fun onContentAspectRatioChanged(
    contentFrame: AspectRatioFrameLayout?,
    aspectRatio: Float
): Unit

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
contentFrame: AspectRatioFrameLayout?

The content frame, or null.

aspectRatio: Float

The aspect ratio to apply.

Public properties

controllerAutoShow

var controllerAutoShowBoolean

controllerHideOnTouch

var controllerHideOnTouchBoolean

controllerShowTimeoutMs

var controllerShowTimeoutMsInt

defaultArtwork

var defaultArtworkDrawable?

overlayFrameLayout

val overlayFrameLayoutFrameLayout?

player

var playerPlayer?

subtitleView

val subtitleViewSubtitleView?

useController

var useControllerBoolean