-
- All Implemented Interfaces:
-
android.graphics.drawable.Drawable.Callback,android.view.KeyEvent.Callback,android.view.accessibility.AccessibilityEventSource,com.getstream.sdk.chat.utils.exomedia.core.api.VideoViewApi,com.getstream.sdk.chat.utils.exomedia.core.video.ClearableSurface,com.getstream.sdk.chat.utils.exomedia.core.video.mp.NativeVideoDelegate.Callback
public class NativeTextureVideoView extends ResizingTextureView implements NativeVideoDelegate.Callback, VideoViewApi
A "Native" VideoView implementation using the android.view.TextureView as a backing instead of the older android.view.SurfaceView. This resolves issues with the SurfaceView because the TextureView is an actual View that follows the normal drawing paths; allowing the view to be animated, scaled, etc. NOTE: This does remove some of the functionality from the VideoView including:
- The MediaController
-
-
Constructor Summary
Constructors Constructor Description NativeTextureVideoView(Context context)NativeTextureVideoView(Context context, AttributeSet attrs)NativeTextureVideoView(Context context, AttributeSet attrs, int defStyleAttr)NativeTextureVideoView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
-
Method Summary
Modifier and Type Method Description voidsetDrmCallback(MediaDrmCallback drmCallback)Sets the MediaDrmCallback to use when handling DRM for media. voidstart()voidpause()longgetDuration()longgetCurrentPosition()voidseekTo(long milliseconds)booleanisPlaying()voidvideoSizeChanged(int width, int height)booleanonTouchEvent(MotionEvent ev)voidsetOnTouchListener(View.OnTouchListener listener)voidsetVideoUri(Uri uri)voidsetVideoUri(Uri uri, MediaSource mediaSource)floatgetVolume()booleansetVolume(float volume)intgetBufferedPercent()WindowInfogetWindowInfo()booleanrestart()If the video has completed playback, calling {@code restart}will seek to the beginning of the video, and play it.voidstopPlayback(boolean clearSurface)Performs the functionality to stop the video in playback voidrelease()booleansetPlaybackSpeed(float speed)Sets the playback speed for this MediaPlayer. floatgetPlaybackSpeed()voidsetCaptionListener(CaptionListener listener)booleantrackSelectionAvailable()voidsetTrack(ExoMedia.RendererType trackType, int trackIndex)voidsetTrack(ExoMedia.RendererType type, int groupIndex, int trackIndex)intgetSelectedTrackIndex(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 voidsetListenerMux(ListenerMux listenerMux)voidonVideoSizeChanged(int width, int height, float pixelWidthHeightRatio)voidsetRepeatMode(int repeatMode)voidsuspend()Cleans up the resources being held. voidsetVideoURI(Uri uri)Sets video URI. voidsetVideoURI(Uri uri, Map<String, String> headers)Sets video URI using specific headers. voidsetOnPreparedListener(MediaPlayer.OnPreparedListener listener)Register a callback to be invoked when the media fileis loaded and ready to go. voidsetOnCompletionListener(MediaPlayer.OnCompletionListener listener)Register a callback to be invoked when the end of a media filehas been reached during playback. voidsetOnBufferingUpdateListener(MediaPlayer.OnBufferingUpdateListener listener)Register a callback to be invoked when the status of a networkstream's buffer has changed. voidsetOnSeekCompleteListener(MediaPlayer.OnSeekCompleteListener listener)Register a callback to be invoked when a seek operation has beencompleted. voidsetOnErrorListener(MediaPlayer.OnErrorListener listener)Register a callback to be invoked when an error occursduring playback or setup. voidsetOnInfoListener(MediaPlayer.OnInfoListener listener)Register a callback to be invoked when an informational eventoccurs during playback or setup. -
Methods inherited from class com.getstream.sdk.chat.utils.exomedia.core.video.ResizingTextureView
clearSurface, getScaleType, setMeasureBasedOnAspectRatioEnabled, setOnSizeChangeListener, setScaleType, setVideoRotation, setVideoRotation -
Methods inherited from class android.view.TextureView
buildLayer, draw, getBitmap, getLayerType, getSurfaceTexture, getSurfaceTextureListener, getTransform, isAvailable, isOpaque, lockCanvas, onAttachedToWindow, onDraw, onSizeChanged, onVisibilityChanged, setBackgroundDrawable, setForeground, setLayerPaint, setLayerType, setOpaque, setSurfaceTexture, setSurfaceTextureListener, setTransform, unlockCanvasAndPost -
Methods inherited from class android.view.View
addChildrenForAccessibility, addExtraDataToAccessibilityNodeInfo, addFocusables, addKeyboardNavigationClusters, addOnAttachStateChangeListener, addOnLayoutChangeListener, addOnUnhandledKeyEventListener, addTouchables, animate, announceForAccessibility, autofill, awakenScrollBars, bringToFront, buildDrawingCache, callOnClick, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, cancelDragAndDrop, cancelLongPress, cancelPendingInputEvents, checkInputConnectionProxy, clearAnimation, clearFocus, combineMeasuredStates, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeSystemWindowInsets, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createAccessibilityNodeInfo, createContextMenu, destroyDrawingCache, dispatchApplyWindowInsets, dispatchCapturedPointerEvent, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchDraw, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchGenericFocusedEvent, dispatchGenericMotionEvent, dispatchGenericPointerEvent, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPointerCaptureChanged, dispatchPopulateAccessibilityEvent, dispatchProvideAutofillStructure, dispatchProvideStructure, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchSystemUiVisibilityChanged, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, drawableHotspotChanged, drawableStateChanged, findFocus, findViewById, findViewWithTag, findViewsWithText, fitSystemWindows, focusSearch, forceHasOverlappingRendering, forceLayout, generateViewId, getAccessibilityClassName, getAccessibilityDelegate, getAccessibilityLiveRegion, getAccessibilityNodeProvider, getAccessibilityPaneTitle, getAccessibilityTraversalAfter, getAccessibilityTraversalBefore, getAlpha, getAnimation, getAnimationMatrix, getApplicationWindowToken, getAttributeResolutionStack, getAttributeSourceResourceMap, getAutofillHints, getAutofillId, getAutofillType, getAutofillValue, getBackground, getBackgroundTintBlendMode, getBackgroundTintList, getBackgroundTintMode, getBaseline, 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, 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, hasFocus, hasFocusable, hasNestedScrollingParent, hasOnClickListeners, hasOverlappingRendering, hasPointerCapture, hasTransientState, 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, isPaddingOffsetRequired, isPaddingRelative, isPivotSet, isPressed, isSaveEnabled, isSaveFromParentEnabled, isScreenReaderFocusable, isScrollContainer, isScrollbarFadingEnabled, isSelected, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentResolved, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVisibleToUserForAutofill, jumpDrawablesToCurrentState, keyboardNavigationClusterSearch, layout, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAnimationEnd, onAnimationStart, onApplyWindowInsets, onCancelPendingInputEvents, onCapturedPointerEvent, onCheckIsTextEditor, onConfigurationChanged, onCreateContextMenu, onCreateDrawableState, onCreateInputConnection, onDetachedFromWindow, onDisplayHint, onDragEvent, onDrawForeground, onDrawScrollBars, onFilterTouchEventForSecurity, onFinishInflate, onFinishTemporaryDetach, onFocusChanged, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onLayout, onMeasure, onOverScrolled, onPointerCaptureChange, onPopulateAccessibilityEvent, onProvideAutofillStructure, onProvideAutofillVirtualStructure, onProvideStructure, onProvideVirtualStructure, onResolvePointerIcon, onRestoreInstanceState, onRtlPropertiesChanged, onSaveInstanceState, onScreenStateChanged, onScrollChanged, onSetAlpha, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onVisibilityAggregated, 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, requestFocus, requestFocusFromTouch, requestLayout, requestPointerCapture, requestRectangleOnScreen, requestUnbufferedDispatch, requireViewById, resetPivot, resolveSize, resolveSizeAndState, restoreDefaultFocus, restoreHierarchyState, saveAttributeDataForStyleable, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAccessibilityDelegate, setAccessibilityHeading, setAccessibilityLiveRegion, setAccessibilityPaneTitle, setAccessibilityTraversalAfter, setAccessibilityTraversalBefore, setActivated, setAlpha, setAnimation, setAnimationMatrix, setAutofillHints, setAutofillId, setBackground, setBackgroundColor, 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, setForegroundGravity, setForegroundTintBlendMode, setForegroundTintList, setForegroundTintMode, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHorizontalScrollbarThumbDrawable, setHorizontalScrollbarTrackDrawable, setHovered, setId, setImportantForAccessibility, setImportantForAutofill, setKeepScreenOn, setKeyboardNavigationCluster, setLabelFor, 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 com.getstream.sdk.chat.utils.exomedia.core.api.VideoViewApi
getHeight, getWidth, seekTo, setMeasureBasedOnAspectRatioEnabled, setOnTouchListener, setTrack -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
NativeTextureVideoView
NativeTextureVideoView(Context context)
-
NativeTextureVideoView
NativeTextureVideoView(Context context, AttributeSet attrs)
-
NativeTextureVideoView
NativeTextureVideoView(Context context, AttributeSet attrs, int defStyleAttr)
-
NativeTextureVideoView
NativeTextureVideoView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
-
-
Method Detail
-
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
-
start
void start()
-
pause
void pause()
-
getDuration
long getDuration()
-
getCurrentPosition
long getCurrentPosition()
-
seekTo
void seekTo(long milliseconds)
-
isPlaying
boolean isPlaying()
-
videoSizeChanged
void videoSizeChanged(int width, int height)
-
onTouchEvent
boolean onTouchEvent(MotionEvent ev)
-
setOnTouchListener
void setOnTouchListener(View.OnTouchListener listener)
-
setVideoUri
void setVideoUri(Uri uri)
-
setVideoUri
void setVideoUri(Uri uri, MediaSource mediaSource)
-
getVolume
float getVolume()
-
setVolume
boolean setVolume(float volume)
-
getBufferedPercent
int getBufferedPercent()
-
getWindowInfo
@Nullable() WindowInfo getWindowInfo()
-
restart
boolean restart()
If the video has completed playback, calling
{@code restart}will seek to the beginning of the video, and play it.
-
stopPlayback
void stopPlayback(boolean clearSurface)
Performs the functionality to stop the video in playback
- Parameters:
clearSurface-trueif the surface should be cleared
-
release
void release()
-
setPlaybackSpeed
boolean setPlaybackSpeed(float speed)
Sets the playback speed for this MediaPlayer.
- Parameters:
speed- The speed to play the media back at
-
getPlaybackSpeed
float getPlaybackSpeed()
-
setCaptionListener
void setCaptionListener(CaptionListener listener)
-
trackSelectionAvailable
boolean trackSelectionAvailable()
-
setTrack
void setTrack(ExoMedia.RendererType trackType, int trackIndex)
-
setTrack
void setTrack(ExoMedia.RendererType type, int groupIndex, int trackIndex)
-
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
-
setListenerMux
void setListenerMux(ListenerMux listenerMux)
-
onVideoSizeChanged
void onVideoSizeChanged(int width, int height, float pixelWidthHeightRatio)
-
setRepeatMode
void setRepeatMode(int repeatMode)
-
suspend
void suspend()
Cleans up the resources being held. This should only be called whendestroying the video view
-
setVideoURI
void setVideoURI(Uri uri)
Sets video URI.
- Parameters:
uri- the URI of the video.
-
setVideoURI
void setVideoURI(Uri uri, Map<String, String> headers)
Sets video URI using specific headers.
- Parameters:
uri- The Uri for the video to playheaders- The headers for the URI request.Note that the cross domain redirection is allowed by default, but that can bechanged with key/value pairs through the headers parameter with"android-allow-cross-domain-redirect" as the key and "0" or "1" as the valueto disallow or allow cross domain redirection.
-
setOnPreparedListener
void setOnPreparedListener(MediaPlayer.OnPreparedListener listener)
Register a callback to be invoked when the media fileis loaded and ready to go.
- Parameters:
listener- The callback that will be run
-
setOnCompletionListener
void setOnCompletionListener(MediaPlayer.OnCompletionListener listener)
Register a callback to be invoked when the end of a media filehas been reached during playback.
- Parameters:
listener- The callback that will be run
-
setOnBufferingUpdateListener
void setOnBufferingUpdateListener(MediaPlayer.OnBufferingUpdateListener listener)
Register a callback to be invoked when the status of a networkstream's buffer has changed.
- Parameters:
listener- the callback that will be run.
-
setOnSeekCompleteListener
void setOnSeekCompleteListener(MediaPlayer.OnSeekCompleteListener listener)
Register a callback to be invoked when a seek operation has beencompleted.
- Parameters:
listener- the callback that will be run
-
setOnErrorListener
void setOnErrorListener(MediaPlayer.OnErrorListener listener)
Register a callback to be invoked when an error occursduring playback or setup. If no listener is specified,or if the listener returned false, TextureVideoView will informthe user of any errors.
- Parameters:
listener- The callback that will be run
-
setOnInfoListener
void setOnInfoListener(MediaPlayer.OnInfoListener listener)
Register a callback to be invoked when an informational eventoccurs during playback or setup.
- Parameters:
listener- The callback that will be run
-
-
-
-