Package 

Class VideoView

  • 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.

    • Method Summary

      Modifier and Type Method Description
      void setOnTouchListener(View.OnTouchListener listener)
      void release() Stops the playback and releases all resources attached to thisVideoView.
      void setPreviewImage(Drawable drawable) Sets an image that will be visible only when the video is loading.
      void setPreviewImage(int resourceId) Sets an image that will be visible only when the video is loading.
      void setPreviewImage(Bitmap bitmap) Sets an image that will be visible only when the video is loading.
      void setPreviewImage(Uri uri) Sets an image that will be visible only when the video is loading.
      void setControls(VideoControls controls)
      void setControls(VideoControlsCore controls)
      void showControls() Requests the VideoControls to become visible.
      VideoControlsCore getVideoControlsCore()
      void setVideoURI(Uri uri) Sets the Uri location for the video to play
      void setVideoURI(Uri uri, MediaSource mediaSource) Sets the Uri location for the video to play
      void setVideoPath(String path) Sets the path to the video.
      void setDrmCallback(MediaDrmCallback drmCallback) Sets the MediaDrmCallback to use when handling DRM for media.
      float getVolume() Retrieves the current media volume
      boolean setVolume(float volume) Sets the volume level for devices that supportthe ExoPlayer (JellyBean or greater).
      void reset() Stops the current video playback and resets the listener statesso that we receive the callbacks for events like onPrepared
      void seekTo(long milliSeconds) Moves the current video progress to the specified location.
      boolean isPlaying() Returns if a video is currently in playback
      void start()
      void pause() If a video is currently in playback, it will be paused
      void pause(boolean transientFocusLoss) Pauses the current video in playback, only abandoning the stream_ic_audio focus iftransientFocusLoss is false.
      void stopPlayback() If a video is currently in playback then the playback will be stopped
      boolean restart() If the video has completed playback, calling {@code restart} will seek to the beginning of the video, and play it.
      void suspend() If a video is currently in playback then the playback will be suspended
      long getDuration() Retrieves the duration of the current stream_ic_audio item.
      void overrideDuration(long duration) Setting this will override the duration that the item may actually be.
      long getCurrentPosition() Retrieves the current position of the stream_ic_audio playback.
      void restartOverridePosition() Restarts the stream_ic_audio position to the start if the position is being overridden (see overridePosition).
      void overridePosition(boolean override) Sets if the position should be overridden, allowing the time to be restarted at will.
      void setOverridePositionMatchesPlaybackSpeed(boolean match) If set the overridden position will use the same playback rate as themedia in playback.
      int getBufferPercentage() Retrieves the current buffer percent of the video.
      WindowInfo getWindowInfo() Retrieves the information associated with the current com.google.android.exoplayer2.Timeline.Window used by the ExoPlayer backed implementation.
      void setRepeatMode(int repeatMode) Sets the repeat mode for this MediaPlayer.
      boolean setPlaybackSpeed(float speed) Sets the playback speed for this MediaPlayer.
      void setCaptionListener(CaptionListener listener) Sets the caption listener for this MediaPlayerOnly the exoplayer implementation supports captions.
      float getPlaybackSpeed() Retrieves the current speed the media is playing at.
      boolean trackSelectionAvailable() Determines if the current video player implementation supportstrack selection for stream_ic_audio or video tracks.
      void setTrack(ExoMedia.RendererType trackType, int trackIndex) Changes to the track with trackIndex for the specifiedtrackType
      void setTrack(ExoMedia.RendererType trackType, int groupIndex, int trackIndex) Changes to the track with trackIndex for the specifiedtrackType
      int getSelectedTrackIndex(ExoMedia.RendererType type, int groupIndex)
      void clearSelectedTracks(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.
      void setRendererEnabled(ExoMedia.RendererType type, boolean enabled) Enables or disables the track associated with the type.
      boolean isRendererEnabled(ExoMedia.RendererType type) Return true if at least one renderer for the given type is enabled
      void setScaleType(ScaleType scaleType) Sets how the video should be scaled in the view
      void setMeasureBasedOnAspectRatioEnabled(boolean measureBasedOnAspectRatioEnabled) Measures the underlying VideoViewApi using the video's aspect ratio if {@code true}
      void setVideoRotation(int rotation) Sets the rotation for the Video
      void setOnPreparedListener(OnPreparedListener listener) Sets the listener to inform of VideoPlayer prepared events
      void setOnCompletionListener(OnCompletionListener listener) Sets the listener to inform of VideoPlayer completion events
      void setOnBufferUpdateListener(OnBufferUpdateListener listener) Sets the listener to inform of VideoPlayer buffer update events
      void setOnSeekCompletionListener(OnSeekCompletionListener listener) Sets the listener to inform of VideoPlayer seek completion events
      void setOnErrorListener(OnErrorListener listener) Sets the listener to inform of playback errors
      void setId3MetadataListener(MetadataListener listener) Sets the listener to inform of ID3 metadata updates
      void setAnalyticsListener(AnalyticsListener listener) Sets the listener to inform of Analytics updates
      void setOnVideoSizedChangedListener(OnVideoSizeChangedListener listener) Sets the listener to inform of video size changes
      Bitmap getBitmap() Returns a Bitmap representation of the current contents of theview.
      ImageView getPreviewImageView() Gets the preview ImageView for use with image loading libraries.
      Uri getVideoUri()
      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.
      void setReleaseOnDetachFromWindow(boolean releaseOnDetach) WARNING: Use of this method may cause memory leaks.
      void setHandleAudioFocus(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
    • Method Detail

      • 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
      • 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 Uri
        mediaSource - 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

      • 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 iftransientFocusLoss is false. Calling pause shouldbe used in most cases unless the stream_ic_audio focus is being handled manually

        Parameters:
        transientFocusLoss - true if 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

      • 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)

      • 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 - true to 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 trackIndex for the specifiedtrackType

        Parameters:
        trackType - The type for the track to switch to the selected index
        trackIndex - The index for the track to switch to
      • setTrack

         void setTrack(ExoMedia.RendererType trackType, int groupIndex, int trackIndex)

        Changes to the track with trackIndex for the specifiedtrackType

        Parameters:
        trackType - The type for the track to switch to the selected index
        groupIndex - The index for the group in the TrackGroupArray specified by the trackType
        trackIndex - The index for the track to switch to
      • 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 for
        enabled - true if the track should be enabled.
      • 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
      • setAnalyticsListener

         void setAnalyticsListener(AnalyticsListener listener)

        Sets the listener to inform of Analytics updates

        Parameters:
        listener - The listener to inform
      • 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 thennull will be returned instead.

        NOTE: Only the TextureView implementations support getting the bitmapmeaning that if the backing implementation is a SurfaceView then the resultwill always be null

      • 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 releaseOnDetach is 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