-
- All Implemented Interfaces:
-
android.graphics.drawable.Drawable.Callback,android.view.KeyEvent.Callback,android.view.ViewManager,android.view.ViewParent,android.view.accessibility.AccessibilityEventSource
public class VideoView extends RelativeLayout
This is a support VideoView that will use the standard VideoView on devices below JellyBean. On devices with JellyBean and up we will use the ExoPlayer in order to better support HLS streaming and full 1080p video resolutions which the VideoView struggles with, and in some cases crashes.
To an external user this view should have the same APIs used with the standard VideoView to help with quick implementations.
-
-
Field Summary
Fields Modifier and Type Field Description protected ImageViewpreviewImageViewprotected UrivideoUriprotected longpositionOffsetprotected booleanreleaseOnDetachFromWindowprotected booleanhandleAudioFocus
-
Constructor Summary
Constructors Constructor Description VideoView(Context context)VideoView(Context context, AttributeSet attrs)VideoView(Context context, AttributeSet attrs, int defStyleAttr)VideoView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
-
Method Summary
Modifier and Type Method Description voidsetOnTouchListener(View.OnTouchListener listener)voidrelease()Stops the playback and releases all resources attached to thisVideoView. voidsetPreviewImage(Drawable drawable)Sets an image that will be visible only when the video is loading. voidsetPreviewImage(int resourceId)Sets an image that will be visible only when the video is loading. voidsetPreviewImage(Bitmap bitmap)Sets an image that will be visible only when the video is loading. voidsetPreviewImage(Uri uri)Sets an image that will be visible only when the video is loading. voidsetControls(VideoControls controls)voidsetControls(VideoControlsCore controls)voidshowControls()Requests the VideoControls to become visible. VideoControlsCoregetVideoControlsCore()voidsetVideoURI(Uri uri)Sets the Uri location for the video to play voidsetVideoURI(Uri uri, MediaSource mediaSource)Sets the Uri location for the video to play voidsetVideoPath(String path)Sets the path to the video. voidsetDrmCallback(MediaDrmCallback drmCallback)Sets the MediaDrmCallback to use when handling DRM for media. floatgetVolume()Retrieves the current media volume booleansetVolume(float volume)Sets the volume level for devices that supportthe ExoPlayer (JellyBean or greater). voidreset()Stops the current video playback and resets the listener statesso that we receive the callbacks for events like onPrepared voidseekTo(long milliSeconds)Moves the current video progress to the specified location. booleanisPlaying()Returns if a video is currently in playback voidstart()voidpause()If a video is currently in playback, it will be paused voidpause(boolean transientFocusLoss)Pauses the current video in playback, only abandoning the stream_ic_audio focus if transientFocusLossisfalse.voidstopPlayback()If a video is currently in playback then the playback will be stopped booleanrestart()If the video has completed playback, calling {@code restart}will seek to the beginning of the video, and play it.voidsuspend()If a video is currently in playback then the playback will be suspended longgetDuration()Retrieves the duration of the current stream_ic_audio item. voidoverrideDuration(long duration)Setting this will override the duration that the item may actually be. longgetCurrentPosition()Retrieves the current position of the stream_ic_audio playback. voidrestartOverridePosition()Restarts the stream_ic_audio position to the start if the position is being overridden (see overridePosition). voidoverridePosition(boolean override)Sets if the position should be overridden, allowing the time to be restarted at will. voidsetOverridePositionMatchesPlaybackSpeed(boolean match)If set the overridden position will use the same playback rate as themedia in playback. intgetBufferPercentage()Retrieves the current buffer percent of the video. WindowInfogetWindowInfo()Retrieves the information associated with the current com.google.android.exoplayer2.Timeline.Window used by the ExoPlayer backed implementation. voidsetRepeatMode(int repeatMode)Sets the repeat mode for this MediaPlayer. booleansetPlaybackSpeed(float speed)Sets the playback speed for this MediaPlayer. voidsetCaptionListener(CaptionListener listener)Sets the caption listener for this MediaPlayerOnly the exoplayer implementation supports captions. floatgetPlaybackSpeed()Retrieves the current speed the media is playing at. booleantrackSelectionAvailable()Determines if the current video player implementation supportstrack selection for stream_ic_audio or video tracks. voidsetTrack(ExoMedia.RendererType trackType, int trackIndex)Changes to the track with trackIndexfor the specifiedtrackTypevoidsetTrack(ExoMedia.RendererType trackType, int groupIndex, int trackIndex)Changes to the track with trackIndexfor the specifiedtrackTypeintgetSelectedTrackIndex(ExoMedia.RendererType type, int groupIndex)voidclearSelectedTracks(ExoMedia.RendererType type)Clear all selected tracks for the specified renderer. Map<ExoMedia.RendererType, TrackGroupArray>getAvailableTracks()Retrieves a list of available tracks to select from. voidsetRendererEnabled(ExoMedia.RendererType type, boolean enabled)Enables or disables the track associated with the type.booleanisRendererEnabled(ExoMedia.RendererType type)Return true if at least one renderer for the given type is enabled voidsetScaleType(ScaleType scaleType)Sets how the video should be scaled in the view voidsetMeasureBasedOnAspectRatioEnabled(boolean measureBasedOnAspectRatioEnabled)Measures the underlying VideoViewApi using the video's aspect ratio if {@code true}voidsetVideoRotation(int rotation)Sets the rotation for the Video voidsetOnPreparedListener(OnPreparedListener listener)Sets the listener to inform of VideoPlayer prepared events voidsetOnCompletionListener(OnCompletionListener listener)Sets the listener to inform of VideoPlayer completion events voidsetOnBufferUpdateListener(OnBufferUpdateListener listener)Sets the listener to inform of VideoPlayer buffer update events voidsetOnSeekCompletionListener(OnSeekCompletionListener listener)Sets the listener to inform of VideoPlayer seek completion events voidsetOnErrorListener(OnErrorListener listener)Sets the listener to inform of playback errors voidsetId3MetadataListener(MetadataListener listener)Sets the listener to inform of ID3 metadata updates voidsetAnalyticsListener(AnalyticsListener listener)Sets the listener to inform of Analytics updates voidsetOnVideoSizedChangedListener(OnVideoSizeChangedListener listener)Sets the listener to inform of video size changes BitmapgetBitmap()Returns a Bitmap representation of the current contents of theview. ImageViewgetPreviewImageView()Gets the preview ImageView for use with image loading libraries. UrigetVideoUri()voidsetPositionOffset(long offset)Sets the amount of time to change the return value from getCurrentPosition.This value will be reset when a new stream_ic_audio item is selected. voidsetReleaseOnDetachFromWindow(boolean releaseOnDetach)WARNING: Use of this method may cause memory leaks. voidsetHandleAudioFocus(boolean handleAudioFocus)Enables or Disables automatic handling of stream_ic_audio focus. -
Methods inherited from class android.widget.RelativeLayout
checkLayoutParams, generateDefaultLayoutParams, generateLayoutParams, getAccessibilityClassName, getBaseline, getGravity, getIgnoreGravity, onLayout, onMeasure, requestLayout, setGravity, setHorizontalGravity, setIgnoreGravity, setVerticalGravity, shouldDelayChildPressedState -
Methods inherited from class android.view.ViewGroup
addChildrenForAccessibility, addFocusables, addKeyboardNavigationClusters, addStatesFromChildren, addTouchables, addView, addViewInLayout, attachLayoutAnimationParameters, attachViewToParent, bringChildToFront, canAnimate, childDrawableStateChanged, childHasTransientStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, debug, detachAllViewsFromParent, detachViewFromParent, detachViewsFromParent, dispatchApplyWindowInsets, dispatchCapturedPointerEvent, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchDraw, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchFreezeSelfOnly, dispatchGenericFocusedEvent, dispatchGenericPointerEvent, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchPointerCaptureChanged, dispatchProvideAutofillStructure, dispatchProvideStructure, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchSystemUiVisibilityChanged, dispatchThawSelfOnly, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, drawChild, drawableStateChanged, endViewTransition, findFocus, findViewsWithText, focusSearch, focusableViewAvailable, gatherTransparentRegion, getChildAt, getChildCount, getChildDrawingOrder, getChildMeasureSpec, getChildStaticTransformation, getChildVisibleRect, getClipChildren, getClipToPadding, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getLayoutMode, getLayoutTransition, getNestedScrollAxes, getOverlay, getPersistentDrawingCache, getTouchscreenBlocksFocus, hasFocus, hasTransientState, indexOfChild, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isChildrenDrawingOrderEnabled, isChildrenDrawnWithCacheEnabled, isLayoutSuppressed, isMotionEventSplittingEnabled, isTransitionGroup, jumpDrawablesToCurrentState, layout, measureChild, measureChildWithMargins, measureChildren, notifySubtreeAccessibilityStateChanged, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onAttachedToWindow, onCreateDrawableState, onDescendantInvalidated, onDetachedFromWindow, onInterceptHoverEvent, onInterceptTouchEvent, onNestedFling, onNestedPreFling, onNestedPrePerformAccessibilityAction, onNestedPreScroll, onNestedScroll, onNestedScrollAccepted, onRequestFocusInDescendants, onRequestSendAccessibilityEvent, onResolvePointerIcon, onStartNestedScroll, onStopNestedScroll, onViewAdded, onViewRemoved, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeDetachedView, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestDisallowInterceptTouchEvent, requestFocus, requestSendAccessibilityEvent, requestTransparentRegion, restoreDefaultFocus, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setChildrenDrawingCacheEnabled, setChildrenDrawingOrderEnabled, setChildrenDrawnWithCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setLayoutMode, setLayoutTransition, setMotionEventSplittingEnabled, setOnHierarchyChangeListener, setPersistentDrawingCache, setStaticTransformationsEnabled, setTouchscreenBlocksFocus, setTransitionGroup, showContextMenuForChild, startActionModeForChild, startLayoutAnimation, startViewTransition, suppressLayout, updateViewLayout -
Methods inherited from class android.view.View
addExtraDataToAccessibilityNodeInfo, addOnAttachStateChangeListener, addOnLayoutChangeListener, addOnUnhandledKeyEventListener, animate, announceForAccessibility, autofill, awakenScrollBars, bringToFront, buildDrawingCache, buildLayer, callOnClick, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, cancelDragAndDrop, cancelLongPress, cancelPendingInputEvents, checkInputConnectionProxy, clearAnimation, combineMeasuredStates, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeSystemWindowInsets, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createAccessibilityNodeInfo, createContextMenu, destroyDrawingCache, dispatchGenericMotionEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPopulateAccessibilityEvent, draw, drawableHotspotChanged, findViewById, findViewWithTag, fitSystemWindows, forceHasOverlappingRendering, forceLayout, generateViewId, getAccessibilityDelegate, getAccessibilityLiveRegion, getAccessibilityNodeProvider, getAccessibilityPaneTitle, getAccessibilityTraversalAfter, getAccessibilityTraversalBefore, getAlpha, getAnimation, getAnimationMatrix, getApplicationWindowToken, getAttributeResolutionStack, getAttributeSourceResourceMap, getAutofillHints, getAutofillId, getAutofillType, getAutofillValue, getBackground, getBackgroundTintBlendMode, getBackgroundTintList, getBackgroundTintMode, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getCameraDistance, getClipBounds, getClipBounds, getClipToOutline, getContentCaptureSession, getContentDescription, getContext, getContextMenuInfo, getDefaultFocusHighlightEnabled, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getElevation, getExplicitStyle, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusable, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getForegroundTintBlendMode, getForegroundTintList, getForegroundTintMode, getGlobalVisibleRect, getHandler, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getHorizontalScrollbarThumbDrawable, getHorizontalScrollbarTrackDrawable, getId, getImportantForAccessibility, getImportantForAutofill, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLocalVisibleRect, getLocationInSurface, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextClusterForwardId, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOutlineAmbientShadowColor, getOutlineProvider, getOutlineSpotShadowColor, getOverScrollMode, getOverlay, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getPointerIcon, getResources, getRevealOnFocusHint, getRight, getRightFadingEdgeStrength, getRightPaddingOffset, getRootView, getRootWindowInsets, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollIndicators, getScrollX, getScrollY, getSolidColor, getSourceLayoutResId, getStateListAnimator, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getSystemGestureExclusionRects, getSystemUiVisibility, getTag, getTextAlignment, getTextDirection, getTooltipText, getTop, getTopFadingEdgeStrength, getTopPaddingOffset, getTouchDelegate, getTouchables, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getUniqueDrawingId, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarThumbDrawable, getVerticalScrollbarTrackDrawable, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowId, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, getZ, hasExplicitFocusable, hasFocusable, hasNestedScrollingParent, hasOnClickListeners, hasOverlappingRendering, hasPointerCapture, hasWindowFocus, inflate, invalidate, invalidateDrawable, invalidateOutline, isAccessibilityFocused, isAccessibilityHeading, isActivated, isAttachedToWindow, isClickable, isContextClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isFocusedByDefault, isForceDarkAllowed, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isImportantForAutofill, isInEditMode, isInLayout, isInTouchMode, isKeyboardNavigationCluster, isLaidOut, isLayoutDirectionResolved, isLayoutRequested, isLongClickable, isNestedScrollingEnabled, isOpaque, isPaddingOffsetRequired, isPaddingRelative, isPivotSet, isPressed, isSaveEnabled, isSaveFromParentEnabled, isScreenReaderFocusable, isScrollContainer, isScrollbarFadingEnabled, isSelected, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentResolved, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVisibleToUserForAutofill, keyboardNavigationClusterSearch, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAnimationEnd, onAnimationStart, onApplyWindowInsets, onCancelPendingInputEvents, onCapturedPointerEvent, onCheckIsTextEditor, onConfigurationChanged, onCreateContextMenu, onCreateInputConnection, onDisplayHint, onDragEvent, onDraw, onDrawForeground, onDrawScrollBars, onFilterTouchEventForSecurity, onFinishInflate, onFinishTemporaryDetach, onFocusChanged, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onOverScrolled, onPointerCaptureChange, onPopulateAccessibilityEvent, onProvideAutofillStructure, onProvideAutofillVirtualStructure, onProvideStructure, onProvideVirtualStructure, onRestoreInstanceState, onRtlPropertiesChanged, onSaveInstanceState, onScreenStateChanged, onScrollChanged, onSetAlpha, onSizeChanged, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onVisibilityAggregated, onVisibilityChanged, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, onWindowVisibilityChanged, overScrollBy, performAccessibilityAction, performClick, performContextClick, performHapticFeedback, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidateDelayed, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, releasePointerCapture, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, removeOnUnhandledKeyEventListener, requestApplyInsets, requestFitSystemWindows, requestFocusFromTouch, requestPointerCapture, requestRectangleOnScreen, requestUnbufferedDispatch, requireViewById, resetPivot, resolveSize, resolveSizeAndState, restoreHierarchyState, saveAttributeDataForStyleable, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAccessibilityDelegate, setAccessibilityHeading, setAccessibilityLiveRegion, setAccessibilityPaneTitle, setAccessibilityTraversalAfter, setAccessibilityTraversalBefore, setActivated, setAlpha, setAnimation, setAnimationMatrix, setAutofillHints, setAutofillId, setBackground, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBackgroundTintBlendMode, setBackgroundTintList, setBackgroundTintMode, setBottom, setCameraDistance, setClickable, setClipBounds, setClipToOutline, setContentCaptureSession, setContentDescription, setContextClickable, setDefaultFocusHighlightEnabled, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setElevation, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusableInTouchMode, setFocusedByDefault, setForceDarkAllowed, setForeground, setForegroundGravity, setForegroundTintBlendMode, setForegroundTintList, setForegroundTintMode, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHorizontalScrollbarThumbDrawable, setHorizontalScrollbarTrackDrawable, setHovered, setId, setImportantForAccessibility, setImportantForAutofill, setKeepScreenOn, setKeyboardNavigationCluster, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutParams, setLeft, setLeftTopRightBottom, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextClusterForwardId, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnApplyWindowInsetsListener, setOnCapturedPointerListener, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOutlineAmbientShadowColor, setOutlineProvider, setOutlineSpotShadowColor, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPointerIcon, setPressed, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScreenReaderFocusable, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollBarSize, setScrollBarStyle, setScrollContainer, setScrollIndicators, setScrollX, setScrollY, setScrollbarFadingEnabled, setSelected, setSoundEffectsEnabled, setStateListAnimator, setSystemGestureExclusionRects, setSystemUiVisibility, setTag, setTextAlignment, setTextDirection, setTooltipText, setTop, setTouchDelegate, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVerticalScrollbarThumbDrawable, setVerticalScrollbarTrackDrawable, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, setZ, showContextMenu, startActionMode, startAnimation, startDrag, startDragAndDrop, startNestedScroll, stopNestedScroll, toString, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, updateDragShadow, verifyDrawable, willNotCacheDrawing, willNotDraw -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
VideoView
VideoView(Context context)
-
VideoView
VideoView(Context context, AttributeSet attrs)
-
VideoView
VideoView(Context context, AttributeSet attrs, int defStyleAttr)
-
VideoView
VideoView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
-
-
Method Detail
-
setOnTouchListener
void setOnTouchListener(View.OnTouchListener listener)
-
release
void release()
Stops the playback and releases all resources attached to thisVideoView. This should not be called manually unless setReleaseOnDetachFromWindow has been set.
-
setPreviewImage
void setPreviewImage(Drawable drawable)
Sets an image that will be visible only when the video is loading.
- Parameters:
drawable- The drawable to use for the preview image
-
setPreviewImage
void setPreviewImage(int resourceId)
Sets an image that will be visible only when the video is loading.
- Parameters:
resourceId- The resourceId representing the preview image
-
setPreviewImage
void setPreviewImage(Bitmap bitmap)
Sets an image that will be visible only when the video is loading.
- Parameters:
bitmap- The bitmap to use for the preview image
-
setPreviewImage
void setPreviewImage(Uri uri)
Sets an image that will be visible only when the video is loading.
- Parameters:
uri- The Uri pointing to the preview image
-
setControls
@Deprecated() void setControls(VideoControls controls)
-
setControls
void setControls(VideoControlsCore controls)
-
showControls
void showControls()
Requests the VideoControls to become visible. This should only be called after setControls.
-
getVideoControlsCore
@Nullable() VideoControlsCore getVideoControlsCore()
-
setVideoURI
void setVideoURI(Uri uri)
Sets the Uri location for the video to play
- Parameters:
uri- The video's Uri
-
setVideoURI
void setVideoURI(Uri uri, MediaSource mediaSource)
Sets the Uri location for the video to play
- Parameters:
uri- The video's UrimediaSource- MediaSource that should be used
-
setVideoPath
void setVideoPath(String path)
Sets the path to the video. This path can be a web address (e.g. http://) oran absolute local path (e.g. file://)
- Parameters:
path- The path to the video
-
setDrmCallback
void setDrmCallback(MediaDrmCallback drmCallback)
Sets the MediaDrmCallback to use when handling DRM for media.This should be called before specifying the videos uri or pathNOTE: DRM is only supported on API 18 +
- Parameters:
drmCallback- The callback to use when handling DRM media
-
getVolume
float getVolume()
Retrieves the current media volume
-
setVolume
boolean setVolume(float volume)
Sets the volume level for devices that supportthe ExoPlayer (JellyBean or greater).
- Parameters:
volume- The volume range [0.0 - 1.
-
reset
void reset()
Stops the current video playback and resets the listener statesso that we receive the callbacks for events like onPrepared
-
seekTo
void seekTo(long milliSeconds)
Moves the current video progress to the specified location.
- Parameters:
milliSeconds- The time to move the playback to
-
isPlaying
boolean isPlaying()
Returns if a video is currently in playback
-
start
void start()
-
pause
void pause()
If a video is currently in playback, it will be paused
-
pause
void pause(boolean transientFocusLoss)
Pauses the current video in playback, only abandoning the stream_ic_audio focus if
transientFocusLossisfalse. Calling pause shouldbe used in most cases unless the stream_ic_audio focus is being handled manually- Parameters:
transientFocusLoss-trueif the pause is temporary and the stream_ic_audio focus should be retained
-
stopPlayback
void stopPlayback()
If a video is currently in playback then the playback will be stopped
-
restart
boolean restart()
If the video has completed playback, calling
{@code restart}will seek to the beginning of the video, and play it.
-
suspend
void suspend()
If a video is currently in playback then the playback will be suspended
-
getDuration
long getDuration()
Retrieves the duration of the current stream_ic_audio item. This should only be called afterthe item is prepared (see setOnPreparedListener).If overrideDuration is set then that value will be returned.
-
overrideDuration
void overrideDuration(long duration)
Setting this will override the duration that the item may actually be. This method shouldonly be used when the item doesn't return the correct duration such as with stream_ic_audio streams.This only overrides the current stream_ic_audio item.
- Parameters:
duration- The duration for the current media item or < 0 to disable
-
getCurrentPosition
long getCurrentPosition()
Retrieves the current position of the stream_ic_audio playback. If an stream_ic_audio item is not currentlyin playback then the value will be 0. This should only be called after the item isprepared (see setOnPreparedListener)
-
restartOverridePosition
void restartOverridePosition()
Restarts the stream_ic_audio position to the start if the position is being overridden (see overridePosition).This will be the value specified with setPositionOffset or 0 if it hasn't been set.
-
overridePosition
void overridePosition(boolean override)
Sets if the position should be overridden, allowing the time to be restarted at will. Thisis useful for streaming media where the media doesn't have breaks between songs.
- Parameters:
override- True if the position should be overridden
-
setOverridePositionMatchesPlaybackSpeed
void setOverridePositionMatchesPlaybackSpeed(boolean match)
If set the overridden position will use the same playback rate as themedia in playback.
- Parameters:
match-trueto match the playback speed
-
getBufferPercentage
int getBufferPercentage()
Retrieves the current buffer percent of the video. If a video is not currentlyprepared or buffering the value will be 0. This should only be called after the video isprepared (see setOnPreparedListener)
-
getWindowInfo
@Nullable() WindowInfo getWindowInfo()
Retrieves the information associated with the current com.google.android.exoplayer2.Timeline.Window used by the ExoPlayer backed implementation. When the android.media.MediaPlayer backedimplementation is being used this will be null.
-
setRepeatMode
void setRepeatMode(int repeatMode)
Sets the repeat mode for this MediaPlayer.Note: This will only change the ExoPlayer implementation
- Parameters:
repeatMode- The repeat mode to use
-
setPlaybackSpeed
boolean setPlaybackSpeed(float speed)
Sets the playback speed for this MediaPlayer.
- Parameters:
speed- The speed to play the media back at
-
setCaptionListener
void setCaptionListener(CaptionListener listener)
Sets the caption listener for this MediaPlayerOnly the exoplayer implementation supports captions.
- Parameters:
listener- The caption listener
-
getPlaybackSpeed
float getPlaybackSpeed()
Retrieves the current speed the media is playing at.
-
trackSelectionAvailable
boolean trackSelectionAvailable()
Determines if the current video player implementation supportstrack selection for stream_ic_audio or video tracks.
-
setTrack
@Deprecated() void setTrack(ExoMedia.RendererType trackType, int trackIndex)
Changes to the track with
trackIndexfor the specifiedtrackType- Parameters:
trackType- The type for the track to switch to the selected indextrackIndex- The index for the track to switch to
-
setTrack
void setTrack(ExoMedia.RendererType trackType, int groupIndex, int trackIndex)
Changes to the track with
trackIndexfor the specifiedtrackType- Parameters:
trackType- The type for the track to switch to the selected indexgroupIndex- The index for the group in the TrackGroupArray specified by thetrackTypetrackIndex- The index for the track to switch to
-
getSelectedTrackIndex
int getSelectedTrackIndex(ExoMedia.RendererType type, int groupIndex)
-
clearSelectedTracks
void clearSelectedTracks(ExoMedia.RendererType type)
Clear all selected tracks for the specified renderer.
- Parameters:
type- The renderer type
-
getAvailableTracks
@Nullable() Map<ExoMedia.RendererType, TrackGroupArray> getAvailableTracks()
Retrieves a list of available tracks to select from. Typically trackSelectionAvailable should be called before this.
-
setRendererEnabled
void setRendererEnabled(ExoMedia.RendererType type, boolean enabled)
Enables or disables the track associated with the
type. Note, by default alltracks are enabled- Parameters:
type- The ExoMedia.RendererType to enable or disable the track forenabled-trueif the track should be enabled.
-
isRendererEnabled
boolean isRendererEnabled(ExoMedia.RendererType type)
Return true if at least one renderer for the given type is enabled
- Parameters:
type- The renderer type
-
setScaleType
void setScaleType(ScaleType scaleType)
Sets how the video should be scaled in the view
- Parameters:
scaleType- how to scale the videos
-
setMeasureBasedOnAspectRatioEnabled
void setMeasureBasedOnAspectRatioEnabled(boolean measureBasedOnAspectRatioEnabled)
Measures the underlying VideoViewApi using the video's aspect ratio if
{@code true}- Parameters:
measureBasedOnAspectRatioEnabled- whether to measure using the video's aspect ratio or not
-
setVideoRotation
void setVideoRotation(int rotation)
Sets the rotation for the Video
- Parameters:
rotation- The rotation to apply to the video
-
setOnPreparedListener
void setOnPreparedListener(OnPreparedListener listener)
Sets the listener to inform of VideoPlayer prepared events
- Parameters:
listener- The listener
-
setOnCompletionListener
void setOnCompletionListener(OnCompletionListener listener)
Sets the listener to inform of VideoPlayer completion events
- Parameters:
listener- The listener
-
setOnBufferUpdateListener
void setOnBufferUpdateListener(OnBufferUpdateListener listener)
Sets the listener to inform of VideoPlayer buffer update events
- Parameters:
listener- The listener
-
setOnSeekCompletionListener
void setOnSeekCompletionListener(OnSeekCompletionListener listener)
Sets the listener to inform of VideoPlayer seek completion events
- Parameters:
listener- The listener
-
setOnErrorListener
void setOnErrorListener(OnErrorListener listener)
Sets the listener to inform of playback errors
- Parameters:
listener- The listener
-
setId3MetadataListener
void setId3MetadataListener(MetadataListener listener)
Sets the listener to inform of ID3 metadata updates
- Parameters:
listener- The listener
-
setAnalyticsListener
void setAnalyticsListener(AnalyticsListener listener)
Sets the listener to inform of Analytics updates
- Parameters:
listener- The listener to inform
-
setOnVideoSizedChangedListener
void setOnVideoSizedChangedListener(OnVideoSizeChangedListener listener)
Sets the listener to inform of video size changes
- Parameters:
listener- The listener
-
getBitmap
@Nullable() Bitmap getBitmap()
Returns a Bitmap representation of the current contents of theview. If the surface isn't ready or we cannot access it for some reason then
nullwill be returned instead.NOTE: Only the
TextureViewimplementations support getting the bitmapmeaning that if the backing implementation is aSurfaceViewthen the resultwill always benull
-
getPreviewImageView
ImageView getPreviewImageView()
Gets the preview ImageView for use with image loading libraries.
-
getVideoUri
@Nullable() Uri getVideoUri()
-
setPositionOffset
void setPositionOffset(long offset)
Sets the amount of time to change the return value from getCurrentPosition.This value will be reset when a new stream_ic_audio item is selected.
- Parameters:
offset- The millisecond value to offset the position
-
setReleaseOnDetachFromWindow
void setReleaseOnDetachFromWindow(boolean releaseOnDetach)
WARNING: Use of this method may cause memory leaks.
Enables or disables the automatic release when the VideoView is detachedfrom the window. Normally this is expected to release all resources usedby calling release. If
releaseOnDetachis disabledthen release will need to be manually called.- Parameters:
releaseOnDetach- False to disable the automatic release in onDetachedFromWindow
-
setHandleAudioFocus
void setHandleAudioFocus(boolean handleAudioFocus)
Enables or Disables automatic handling of stream_ic_audio focus. By default this is enabledhowever in instances where a service handles playback of both stream_ic_audio and video itis recommended to disable this and manually handle it in the service for consistency
- Parameters:
handleAudioFocus-{@code true}to handle stream_ic_audio focus
-
-
-
-