Class StubExoPlayer
- java.lang.Object
-
- com.google.android.exoplayer2.BasePlayer
-
- com.google.android.exoplayer2.testutil.StubPlayer
-
- com.google.android.exoplayer2.testutil.StubExoPlayer
-
public class StubExoPlayer extends StubPlayer implements ExoPlayer
An abstractExoPlayerimplementation that throwsUnsupportedOperationExceptionfrom every method.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.ExoPlayer
ExoPlayer.AudioComponent, ExoPlayer.AudioOffloadListener, ExoPlayer.Builder, ExoPlayer.DeviceComponent, ExoPlayer.TextComponent, ExoPlayer.VideoComponent
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.Player
Player.Command, Player.Commands, Player.DiscontinuityReason, Player.Event, Player.EventListener, Player.Events, Player.Listener, Player.MediaItemTransitionReason, Player.PlaybackSuppressionReason, Player.PlayWhenReadyChangeReason, Player.PositionInfo, Player.RepeatMode, Player.State, Player.TimelineChangeReason
-
-
Field Summary
-
Fields inherited from class com.google.android.exoplayer2.BasePlayer
window
-
Fields inherited from interface com.google.android.exoplayer2.ExoPlayer
DEFAULT_DETACH_SURFACE_TIMEOUT_MS, DEFAULT_RELEASE_TIMEOUT_MS
-
Fields inherited from interface com.google.android.exoplayer2.Player
COMMAND_ADJUST_DEVICE_VOLUME, COMMAND_CHANGE_MEDIA_ITEMS, COMMAND_GET_AUDIO_ATTRIBUTES, COMMAND_GET_CURRENT_MEDIA_ITEM, COMMAND_GET_DEVICE_VOLUME, COMMAND_GET_MEDIA_ITEMS_METADATA, COMMAND_GET_TEXT, COMMAND_GET_TIMELINE, COMMAND_GET_TRACK_INFOS, COMMAND_GET_VOLUME, COMMAND_INVALID, COMMAND_PLAY_PAUSE, COMMAND_PREPARE, COMMAND_SEEK_BACK, COMMAND_SEEK_FORWARD, COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM, COMMAND_SEEK_IN_CURRENT_WINDOW, COMMAND_SEEK_TO_DEFAULT_POSITION, COMMAND_SEEK_TO_MEDIA_ITEM, COMMAND_SEEK_TO_NEXT, COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, COMMAND_SEEK_TO_NEXT_WINDOW, COMMAND_SEEK_TO_PREVIOUS, COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM, COMMAND_SEEK_TO_PREVIOUS_WINDOW, COMMAND_SEEK_TO_WINDOW, COMMAND_SET_DEVICE_VOLUME, COMMAND_SET_MEDIA_ITEMS_METADATA, COMMAND_SET_REPEAT_MODE, COMMAND_SET_SHUFFLE_MODE, COMMAND_SET_SPEED_AND_PITCH, COMMAND_SET_TRACK_SELECTION_PARAMETERS, COMMAND_SET_VIDEO_SURFACE, COMMAND_SET_VOLUME, COMMAND_STOP, DISCONTINUITY_REASON_AUTO_TRANSITION, DISCONTINUITY_REASON_INTERNAL, DISCONTINUITY_REASON_REMOVE, DISCONTINUITY_REASON_SEEK, DISCONTINUITY_REASON_SEEK_ADJUSTMENT, DISCONTINUITY_REASON_SKIP, EVENT_AVAILABLE_COMMANDS_CHANGED, EVENT_IS_LOADING_CHANGED, EVENT_IS_PLAYING_CHANGED, EVENT_MAX_SEEK_TO_PREVIOUS_POSITION_CHANGED, EVENT_MEDIA_ITEM_TRANSITION, EVENT_MEDIA_METADATA_CHANGED, EVENT_PLAY_WHEN_READY_CHANGED, EVENT_PLAYBACK_PARAMETERS_CHANGED, EVENT_PLAYBACK_STATE_CHANGED, EVENT_PLAYBACK_SUPPRESSION_REASON_CHANGED, EVENT_PLAYER_ERROR, EVENT_PLAYLIST_METADATA_CHANGED, EVENT_POSITION_DISCONTINUITY, EVENT_REPEAT_MODE_CHANGED, EVENT_SEEK_BACK_INCREMENT_CHANGED, EVENT_SEEK_FORWARD_INCREMENT_CHANGED, EVENT_SHUFFLE_MODE_ENABLED_CHANGED, EVENT_TIMELINE_CHANGED, EVENT_TRACK_SELECTION_PARAMETERS_CHANGED, EVENT_TRACKS_CHANGED, MEDIA_ITEM_TRANSITION_REASON_AUTO, MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED, MEDIA_ITEM_TRANSITION_REASON_REPEAT, MEDIA_ITEM_TRANSITION_REASON_SEEK, PLAY_WHEN_READY_CHANGE_REASON_AUDIO_BECOMING_NOISY, PLAY_WHEN_READY_CHANGE_REASON_AUDIO_FOCUS_LOSS, PLAY_WHEN_READY_CHANGE_REASON_END_OF_MEDIA_ITEM, PLAY_WHEN_READY_CHANGE_REASON_REMOTE, PLAY_WHEN_READY_CHANGE_REASON_USER_REQUEST, PLAYBACK_SUPPRESSION_REASON_NONE, PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS, REPEAT_MODE_ALL, REPEAT_MODE_OFF, REPEAT_MODE_ONE, STATE_BUFFERING, STATE_ENDED, STATE_IDLE, STATE_READY, TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, TIMELINE_CHANGE_REASON_SOURCE_UPDATE
-
-
Constructor Summary
Constructors Constructor Description StubExoPlayer()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddAnalyticsListener(AnalyticsListener listener)Adds anAnalyticsListenerto receive analytics events.voidaddAudioOffloadListener(ExoPlayer.AudioOffloadListener listener)Adds a listener to receive audio offload events.voidaddListener(Player.EventListener listener)Registers a listener to receive events from the player.voidaddMediaSource(int index, MediaSource mediaSource)Adds a media source at the given index of the playlist.voidaddMediaSource(MediaSource mediaSource)Adds a media source to the end of the playlist.voidaddMediaSources(int index, List<MediaSource> mediaSources)Adds a list of media sources at the given index of the playlist.voidaddMediaSources(List<MediaSource> mediaSources)Adds a list of media sources to the end of the playlist.voidclearAuxEffectInfo()Detaches any previously attached auxiliary audio effect from the underlying audio track.voidclearCameraMotionListener(CameraMotionListener listener)Clears the listener which receives camera motion events if it matches the one passed.voidclearVideoFrameMetadataListener(VideoFrameMetadataListener listener)Clears the listener which receives video frame metadata events if it matches the one passed.PlayerMessagecreateMessage(PlayerMessage.Target target)Creates a message that can be sent to aPlayerMessage.Target.booleanexperimentalIsSleepingForOffload()Returns whether the player has paused its main loop to save power in offload scheduling mode.voidexperimentalSetOffloadSchedulingEnabled(boolean offloadSchedulingEnabled)Sets whether audio offload scheduling is enabled.AnalyticsCollectorgetAnalyticsCollector()Returns theAnalyticsCollectorused for collecting analytics events.ExoPlayer.AudioComponentgetAudioComponent()Deprecated.DecoderCountersgetAudioDecoderCounters()ReturnsDecoderCountersfor audio, or null if no audio is being played.FormatgetAudioFormat()Returns the audio format currently being played, or null if no audio is being played.intgetAudioSessionId()Returns the audio session identifier, orC.AUDIO_SESSION_ID_UNSETif not set.ClockgetClock()Returns theClockused for playback.ExoPlayer.DeviceComponentgetDeviceComponent()Deprecated.booleangetPauseAtEndOfMediaItems()Returns whether the player pauses playback at the end of each media item.LoopergetPlaybackLooper()Returns theLooperassociated with the playback thread.ExoPlaybackExceptiongetPlayerError()Returns the error that caused playback to fail.intgetRendererCount()Returns the number of renderers.intgetRendererType(int index)Returns the track type that the renderer at a given index handles.SeekParametersgetSeekParameters()Returns the currently activeSeekParametersof the player.booleangetSkipSilenceEnabled()Returns whether skipping silences in the audio stream is enabled.ExoPlayer.TextComponentgetTextComponent()Deprecated.TrackSelectorgetTrackSelector()Returns the track selector that this player uses, or null if track selection is not supported.intgetVideoChangeFrameRateStrategy()Returns theC.VideoChangeFrameRateStrategy.ExoPlayer.VideoComponentgetVideoComponent()Deprecated.DecoderCountersgetVideoDecoderCounters()ReturnsDecoderCountersfor video, or null if no video is being played.FormatgetVideoFormat()Returns the video format currently being played, or null if no video is being played.intgetVideoScalingMode()Returns theC.VideoScalingMode.voidprepare(MediaSource mediaSource)Deprecated.voidprepare(MediaSource mediaSource, boolean resetPosition, boolean resetState)Deprecated.voidremoveAnalyticsListener(AnalyticsListener listener)Removes anAnalyticsListener.voidremoveAudioOffloadListener(ExoPlayer.AudioOffloadListener listener)Removes a listener of audio offload events.voidremoveListener(Player.EventListener listener)Unregister a listener registered throughExoPlayer.addListener(EventListener).voidretry()Deprecated.voidsetAudioAttributes(AudioAttributes audioAttributes, boolean handleAudioFocus)Sets the attributes for audio playback, used by the underlying audio track.voidsetAudioSessionId(int audioSessionId)Sets the ID of the audio session to attach to the underlyingAudioTrack.voidsetAuxEffectInfo(AuxEffectInfo auxEffectInfo)Sets information on an auxiliary audio effect to attach to the underlying audio track.voidsetCameraMotionListener(CameraMotionListener listener)Sets a listener of camera motion events.voidsetForegroundMode(boolean foregroundMode)Sets whether the player is allowed to keep holding limited resources such as video decoders, even when in the idle state.voidsetHandleAudioBecomingNoisy(boolean handleAudioBecomingNoisy)Sets whether the player should pause automatically when audio is rerouted from a headset to device speakers.voidsetHandleWakeLock(boolean handleWakeLock)Deprecated.voidsetMediaSource(MediaSource mediaSource)Clears the playlist, adds the specifiedMediaSourceand resets the position to the default position.voidsetMediaSource(MediaSource mediaSource, boolean resetPosition)Clears the playlist and adds the specifiedMediaSource.voidsetMediaSource(MediaSource mediaSource, long startPositionMs)Clears the playlist and adds the specifiedMediaSource.voidsetMediaSources(List<MediaSource> mediaSources)Clears the playlist, adds the specifiedMediaSourcesand resets the position to the default position.voidsetMediaSources(List<MediaSource> mediaSources, boolean resetPosition)Clears the playlist and adds the specifiedMediaSources.voidsetMediaSources(List<MediaSource> mediaSources, int startMediaItemIndex, long startPositionMs)Clears the playlist and adds the specifiedMediaSources.voidsetPauseAtEndOfMediaItems(boolean pauseAtEndOfMediaItems)Sets whether to pause playback at the end of each media item.voidsetPriorityTaskManager(PriorityTaskManager priorityTaskManager)Sets aPriorityTaskManager, or null to clear a previously set priority task manager.voidsetSeekParameters(SeekParameters seekParameters)Sets the parameters that control how seek operations are performed.voidsetShuffleOrder(ShuffleOrder shuffleOrder)Sets the shuffle order.voidsetSkipSilenceEnabled(boolean skipSilenceEnabled)Sets whether skipping silences in the audio stream is enabled.voidsetThrowsWhenUsingWrongThread(boolean throwsWhenUsingWrongThread)Deprecated.voidsetVideoChangeFrameRateStrategy(int videoChangeFrameRateStrategy)Sets aC.VideoChangeFrameRateStrategythat will be used by the player when provided with a video outputSurface.voidsetVideoFrameMetadataListener(VideoFrameMetadataListener listener)Sets a listener to receive video frame metadata events.voidsetVideoScalingMode(int videoScalingMode)Sets theC.VideoScalingMode.voidsetWakeMode(int wakeMode)Sets how the player should keep the device awake for playback when the screen is off.-
Methods inherited from class com.google.android.exoplayer2.testutil.StubPlayer
addListener, addMediaItems, clearVideoSurface, clearVideoSurface, clearVideoSurfaceHolder, clearVideoSurfaceView, clearVideoTextureView, decreaseDeviceVolume, getApplicationLooper, getAudioAttributes, getAvailableCommands, getBufferedPosition, getContentBufferedPosition, getContentPosition, getCurrentAdGroupIndex, getCurrentAdIndexInAdGroup, getCurrentCues, getCurrentMediaItemIndex, getCurrentPeriodIndex, getCurrentPosition, getCurrentTimeline, getCurrentTrackGroups, getCurrentTrackSelections, getCurrentTracksInfo, getDeviceInfo, getDeviceVolume, getDuration, getMaxSeekToPreviousPosition, getMediaMetadata, getPlaybackParameters, getPlaybackState, getPlaybackSuppressionReason, getPlaylistMetadata, getPlayWhenReady, getRepeatMode, getSeekBackIncrement, getSeekForwardIncrement, getShuffleModeEnabled, getTotalBufferedDuration, getTrackSelectionParameters, getVideoSize, getVolume, increaseDeviceVolume, isDeviceMuted, isLoading, isPlayingAd, moveMediaItems, prepare, release, removeListener, removeMediaItems, seekTo, setDeviceMuted, setDeviceVolume, setMediaItems, setMediaItems, setPlaybackParameters, setPlaylistMetadata, setPlayWhenReady, setRepeatMode, setShuffleModeEnabled, setTrackSelectionParameters, setVideoSurface, setVideoSurfaceHolder, setVideoSurfaceView, setVideoTextureView, setVolume, stop, stop
-
Methods inherited from class com.google.android.exoplayer2.BasePlayer
addMediaItem, addMediaItem, addMediaItems, canAdvertiseSession, clearMediaItems, getAvailableCommands, getBufferedPercentage, getContentDuration, getCurrentLiveOffset, getCurrentManifest, getCurrentMediaItem, getCurrentWindowIndex, getMediaItemAt, getMediaItemCount, getNextMediaItemIndex, getNextWindowIndex, getPreviousMediaItemIndex, getPreviousWindowIndex, hasNext, hasNextMediaItem, hasNextWindow, hasPrevious, hasPreviousMediaItem, hasPreviousWindow, isCommandAvailable, isCurrentMediaItemDynamic, isCurrentMediaItemLive, isCurrentMediaItemSeekable, isCurrentWindowDynamic, isCurrentWindowLive, isCurrentWindowSeekable, isPlaying, moveMediaItem, next, pause, play, previous, removeMediaItem, seekBack, seekForward, seekTo, seekToDefaultPosition, seekToDefaultPosition, seekToNext, seekToNextMediaItem, seekToNextWindow, seekToPrevious, seekToPreviousMediaItem, seekToPreviousWindow, setMediaItem, setMediaItem, setMediaItem, setMediaItems, setPlaybackSpeed
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.android.exoplayer2.Player
addListener, addMediaItem, addMediaItem, addMediaItems, addMediaItems, canAdvertiseSession, clearMediaItems, clearVideoSurface, clearVideoSurface, clearVideoSurfaceHolder, clearVideoSurfaceView, clearVideoTextureView, decreaseDeviceVolume, getApplicationLooper, getAudioAttributes, getAvailableCommands, getBufferedPercentage, getBufferedPosition, getContentBufferedPosition, getContentDuration, getContentPosition, getCurrentAdGroupIndex, getCurrentAdIndexInAdGroup, getCurrentCues, getCurrentLiveOffset, getCurrentManifest, getCurrentMediaItem, getCurrentMediaItemIndex, getCurrentPeriodIndex, getCurrentPosition, getCurrentTimeline, getCurrentTrackGroups, getCurrentTrackSelections, getCurrentTracksInfo, getCurrentWindowIndex, getDeviceInfo, getDeviceVolume, getDuration, getMaxSeekToPreviousPosition, getMediaItemAt, getMediaItemCount, getMediaMetadata, getNextMediaItemIndex, getNextWindowIndex, getPlaybackParameters, getPlaybackState, getPlaybackSuppressionReason, getPlaylistMetadata, getPlayWhenReady, getPreviousMediaItemIndex, getPreviousWindowIndex, getRepeatMode, getSeekBackIncrement, getSeekForwardIncrement, getShuffleModeEnabled, getTotalBufferedDuration, getTrackSelectionParameters, getVideoSize, getVolume, hasNext, hasNextMediaItem, hasNextWindow, hasPrevious, hasPreviousMediaItem, hasPreviousWindow, increaseDeviceVolume, isCommandAvailable, isCurrentMediaItemDynamic, isCurrentMediaItemLive, isCurrentMediaItemSeekable, isCurrentWindowDynamic, isCurrentWindowLive, isCurrentWindowSeekable, isDeviceMuted, isLoading, isPlaying, isPlayingAd, moveMediaItem, moveMediaItems, next, pause, play, prepare, previous, release, removeListener, removeMediaItem, removeMediaItems, seekBack, seekForward, seekTo, seekTo, seekToDefaultPosition, seekToDefaultPosition, seekToNext, seekToNextMediaItem, seekToNextWindow, seekToPrevious, seekToPreviousMediaItem, seekToPreviousWindow, setDeviceMuted, setDeviceVolume, setMediaItem, setMediaItem, setMediaItem, setMediaItems, setMediaItems, setMediaItems, setPlaybackParameters, setPlaybackSpeed, setPlaylistMetadata, setPlayWhenReady, setRepeatMode, setShuffleModeEnabled, setTrackSelectionParameters, setVideoSurface, setVideoSurfaceHolder, setVideoSurfaceView, setVideoTextureView, setVolume, stop, stop
-
-
-
-
Method Detail
-
getAudioComponent
@Deprecated public ExoPlayer.AudioComponent getAudioComponent()
Deprecated.- Specified by:
getAudioComponentin interfaceExoPlayer
-
getVideoComponent
@Deprecated public ExoPlayer.VideoComponent getVideoComponent()
Deprecated.- Specified by:
getVideoComponentin interfaceExoPlayer
-
getTextComponent
@Deprecated public ExoPlayer.TextComponent getTextComponent()
Deprecated.- Specified by:
getTextComponentin interfaceExoPlayer
-
getDeviceComponent
@Deprecated public ExoPlayer.DeviceComponent getDeviceComponent()
Deprecated.- Specified by:
getDeviceComponentin interfaceExoPlayer
-
getPlaybackLooper
public Looper getPlaybackLooper()
Description copied from interface:ExoPlayerReturns theLooperassociated with the playback thread.- Specified by:
getPlaybackLooperin interfaceExoPlayer
-
getClock
public Clock getClock()
Description copied from interface:ExoPlayerReturns theClockused for playback.
-
addListener
public void addListener(Player.EventListener listener)
Description copied from interface:ExoPlayerRegisters a listener to receive events from the player.The listener's methods will be called on the thread associated with
Player.getApplicationLooper().- Specified by:
addListenerin interfaceExoPlayer- Parameters:
listener- The listener to register.
-
removeListener
public void removeListener(Player.EventListener listener)
Description copied from interface:ExoPlayerUnregister a listener registered throughExoPlayer.addListener(EventListener). The listener will no longer receive events from the player.- Specified by:
removeListenerin interfaceExoPlayer- Parameters:
listener- The listener to unregister.
-
addAudioOffloadListener
public void addAudioOffloadListener(ExoPlayer.AudioOffloadListener listener)
Description copied from interface:ExoPlayerAdds a listener to receive audio offload events.- Specified by:
addAudioOffloadListenerin interfaceExoPlayer- Parameters:
listener- The listener to register.
-
removeAudioOffloadListener
public void removeAudioOffloadListener(ExoPlayer.AudioOffloadListener listener)
Description copied from interface:ExoPlayerRemoves a listener of audio offload events.- Specified by:
removeAudioOffloadListenerin interfaceExoPlayer- Parameters:
listener- The listener to unregister.
-
getAnalyticsCollector
public AnalyticsCollector getAnalyticsCollector()
Description copied from interface:ExoPlayerReturns theAnalyticsCollectorused for collecting analytics events.- Specified by:
getAnalyticsCollectorin interfaceExoPlayer
-
addAnalyticsListener
public void addAnalyticsListener(AnalyticsListener listener)
Description copied from interface:ExoPlayerAdds anAnalyticsListenerto receive analytics events.- Specified by:
addAnalyticsListenerin interfaceExoPlayer- Parameters:
listener- The listener to be added.
-
removeAnalyticsListener
public void removeAnalyticsListener(AnalyticsListener listener)
Description copied from interface:ExoPlayerRemoves anAnalyticsListener.- Specified by:
removeAnalyticsListenerin interfaceExoPlayer- Parameters:
listener- The listener to be removed.
-
getPlayerError
public ExoPlaybackException getPlayerError()
Description copied from interface:PlayerReturns the error that caused playback to fail. This is the same error that will have been reported viaPlayer.Listener.onPlayerError(PlaybackException)at the time of failure. It can be queried using this method until the player is re-prepared.Note that this method will always return
nullifPlayer.getPlaybackState()is notPlayer.STATE_IDLE.- Specified by:
getPlayerErrorin interfaceExoPlayer- Specified by:
getPlayerErrorin interfacePlayer- Overrides:
getPlayerErrorin classStubPlayer- Returns:
- The error, or
null. - See Also:
Player.Listener.onPlayerError(PlaybackException)
-
retry
@Deprecated public void retry()
Deprecated.
-
prepare
@Deprecated public void prepare(MediaSource mediaSource)
Deprecated.
-
prepare
@Deprecated public void prepare(MediaSource mediaSource, boolean resetPosition, boolean resetState)
Deprecated.
-
setMediaSource
public void setMediaSource(MediaSource mediaSource)
Description copied from interface:ExoPlayerClears the playlist, adds the specifiedMediaSourceand resets the position to the default position.- Specified by:
setMediaSourcein interfaceExoPlayer- Parameters:
mediaSource- The newMediaSource.
-
setMediaSource
public void setMediaSource(MediaSource mediaSource, long startPositionMs)
Description copied from interface:ExoPlayerClears the playlist and adds the specifiedMediaSource.- Specified by:
setMediaSourcein interfaceExoPlayer- Parameters:
mediaSource- The newMediaSource.startPositionMs- The position in milliseconds to start playback from.
-
setMediaSource
public void setMediaSource(MediaSource mediaSource, boolean resetPosition)
Description copied from interface:ExoPlayerClears the playlist and adds the specifiedMediaSource.- Specified by:
setMediaSourcein interfaceExoPlayer- Parameters:
mediaSource- The newMediaSource.resetPosition- Whether the playback position should be reset to the default position. If false, playback will start from the position defined byPlayer.getCurrentMediaItemIndex()andPlayer.getCurrentPosition().
-
setMediaSources
public void setMediaSources(List<MediaSource> mediaSources)
Description copied from interface:ExoPlayerClears the playlist, adds the specifiedMediaSourcesand resets the position to the default position.- Specified by:
setMediaSourcesin interfaceExoPlayer- Parameters:
mediaSources- The newMediaSources.
-
setMediaSources
public void setMediaSources(List<MediaSource> mediaSources, boolean resetPosition)
Description copied from interface:ExoPlayerClears the playlist and adds the specifiedMediaSources.- Specified by:
setMediaSourcesin interfaceExoPlayer- Parameters:
mediaSources- The newMediaSources.resetPosition- Whether the playback position should be reset to the default position in the firstTimeline.Window. If false, playback will start from the position defined byPlayer.getCurrentMediaItemIndex()andPlayer.getCurrentPosition().
-
setMediaSources
public void setMediaSources(List<MediaSource> mediaSources, int startMediaItemIndex, long startPositionMs)
Description copied from interface:ExoPlayerClears the playlist and adds the specifiedMediaSources.- Specified by:
setMediaSourcesin interfaceExoPlayer- Parameters:
mediaSources- The newMediaSources.startMediaItemIndex- The media item index to start playback from. IfC.INDEX_UNSETis passed, the current position is not reset.startPositionMs- The position in milliseconds to start playback from. IfC.TIME_UNSETis passed, the default position of the given media item is used. In any case, ifstartMediaItemIndexis set toC.INDEX_UNSET, this parameter is ignored and the position is not reset at all.
-
addMediaSource
public void addMediaSource(MediaSource mediaSource)
Description copied from interface:ExoPlayerAdds a media source to the end of the playlist.- Specified by:
addMediaSourcein interfaceExoPlayer- Parameters:
mediaSource- TheMediaSourceto add.
-
addMediaSource
public void addMediaSource(int index, MediaSource mediaSource)Description copied from interface:ExoPlayerAdds a media source at the given index of the playlist.- Specified by:
addMediaSourcein interfaceExoPlayer- Parameters:
index- The index at which to add the source.mediaSource- TheMediaSourceto add.
-
addMediaSources
public void addMediaSources(List<MediaSource> mediaSources)
Description copied from interface:ExoPlayerAdds a list of media sources to the end of the playlist.- Specified by:
addMediaSourcesin interfaceExoPlayer- Parameters:
mediaSources- TheMediaSourcesto add.
-
addMediaSources
public void addMediaSources(int index, List<MediaSource> mediaSources)Description copied from interface:ExoPlayerAdds a list of media sources at the given index of the playlist.- Specified by:
addMediaSourcesin interfaceExoPlayer- Parameters:
index- The index at which to add the media sources.mediaSources- TheMediaSourcesto add.
-
setShuffleOrder
public void setShuffleOrder(ShuffleOrder shuffleOrder)
Description copied from interface:ExoPlayerSets the shuffle order.- Specified by:
setShuffleOrderin interfaceExoPlayer- Parameters:
shuffleOrder- The shuffle order.
-
setAudioAttributes
public void setAudioAttributes(AudioAttributes audioAttributes, boolean handleAudioFocus)
Description copied from interface:ExoPlayerSets the attributes for audio playback, used by the underlying audio track. If not set, the default audio attributes will be used. They are suitable for general media playback.Setting the audio attributes during playback may introduce a short gap in audio output as the audio track is recreated. A new audio session id will also be generated.
If tunneling is enabled by the track selector, the specified audio attributes will be ignored, but they will take effect if audio is later played without tunneling.
If the device is running a build before platform API version 21, audio attributes cannot be set directly on the underlying audio track. In this case, the usage will be mapped onto an equivalent stream type using
Util.getStreamTypeForAudioUsage(int).If audio focus should be handled, the
AudioAttributes.usagemust beC.USAGE_MEDIAorC.USAGE_GAME. Other usages will throw anIllegalArgumentException.- Specified by:
setAudioAttributesin interfaceExoPlayer- Parameters:
audioAttributes- The attributes to use for audio playback.handleAudioFocus- True if the player should handle audio focus, false otherwise.
-
setAudioSessionId
public void setAudioSessionId(int audioSessionId)
Description copied from interface:ExoPlayerSets the ID of the audio session to attach to the underlyingAudioTrack.The audio session ID can be generated using
Util.generateAudioSessionIdV21(Context)for API 21+.- Specified by:
setAudioSessionIdin interfaceExoPlayer- Parameters:
audioSessionId- The audio session ID, orC.AUDIO_SESSION_ID_UNSETif it should be generated by the framework.
-
getAudioSessionId
public int getAudioSessionId()
Description copied from interface:ExoPlayerReturns the audio session identifier, orC.AUDIO_SESSION_ID_UNSETif not set.- Specified by:
getAudioSessionIdin interfaceExoPlayer
-
setAuxEffectInfo
public void setAuxEffectInfo(AuxEffectInfo auxEffectInfo)
Description copied from interface:ExoPlayerSets information on an auxiliary audio effect to attach to the underlying audio track.- Specified by:
setAuxEffectInfoin interfaceExoPlayer
-
clearAuxEffectInfo
public void clearAuxEffectInfo()
Description copied from interface:ExoPlayerDetaches any previously attached auxiliary audio effect from the underlying audio track.- Specified by:
clearAuxEffectInfoin interfaceExoPlayer
-
setSkipSilenceEnabled
public void setSkipSilenceEnabled(boolean skipSilenceEnabled)
Description copied from interface:ExoPlayerSets whether skipping silences in the audio stream is enabled.- Specified by:
setSkipSilenceEnabledin interfaceExoPlayer- Parameters:
skipSilenceEnabled- Whether skipping silences in the audio stream is enabled.
-
getSkipSilenceEnabled
public boolean getSkipSilenceEnabled()
Description copied from interface:ExoPlayerReturns whether skipping silences in the audio stream is enabled.- Specified by:
getSkipSilenceEnabledin interfaceExoPlayer
-
setVideoScalingMode
public void setVideoScalingMode(int videoScalingMode)
Description copied from interface:ExoPlayerSets theC.VideoScalingMode.The scaling mode only applies if a
MediaCodec-based videoRendereris enabled and if the output surface is owned by aSurfaceView.- Specified by:
setVideoScalingModein interfaceExoPlayer- Parameters:
videoScalingMode- TheC.VideoScalingMode.
-
getVideoScalingMode
public int getVideoScalingMode()
Description copied from interface:ExoPlayerReturns theC.VideoScalingMode.- Specified by:
getVideoScalingModein interfaceExoPlayer
-
setVideoChangeFrameRateStrategy
public void setVideoChangeFrameRateStrategy(int videoChangeFrameRateStrategy)
Description copied from interface:ExoPlayerSets aC.VideoChangeFrameRateStrategythat will be used by the player when provided with a video outputSurface.The strategy only applies if a
MediaCodec-based videoRendereris enabled. Applications wishing to useSurface.CHANGE_FRAME_RATE_ALWAYSshould set the mode toC.VIDEO_CHANGE_FRAME_RATE_STRATEGY_OFFto disable calls toSurface.setFrameRate(float, int, int)from ExoPlayer, and should then callSurface.setFrameRate(float, int, int)directly from application code.- Specified by:
setVideoChangeFrameRateStrategyin interfaceExoPlayer- Parameters:
videoChangeFrameRateStrategy- AC.VideoChangeFrameRateStrategy.
-
getVideoChangeFrameRateStrategy
public int getVideoChangeFrameRateStrategy()
Description copied from interface:ExoPlayerReturns theC.VideoChangeFrameRateStrategy.- Specified by:
getVideoChangeFrameRateStrategyin interfaceExoPlayer
-
setVideoFrameMetadataListener
public void setVideoFrameMetadataListener(VideoFrameMetadataListener listener)
Description copied from interface:ExoPlayerSets a listener to receive video frame metadata events.This method is intended to be called by the same component that sets the
Surfaceonto which video will be rendered. If using ExoPlayer's standard UI components, this method should not be called directly from application code.- Specified by:
setVideoFrameMetadataListenerin interfaceExoPlayer- Parameters:
listener- The listener.
-
clearVideoFrameMetadataListener
public void clearVideoFrameMetadataListener(VideoFrameMetadataListener listener)
Description copied from interface:ExoPlayerClears the listener which receives video frame metadata events if it matches the one passed. Else does nothing.- Specified by:
clearVideoFrameMetadataListenerin interfaceExoPlayer- Parameters:
listener- The listener to clear.
-
setCameraMotionListener
public void setCameraMotionListener(CameraMotionListener listener)
Description copied from interface:ExoPlayerSets a listener of camera motion events.- Specified by:
setCameraMotionListenerin interfaceExoPlayer- Parameters:
listener- The listener.
-
clearCameraMotionListener
public void clearCameraMotionListener(CameraMotionListener listener)
Description copied from interface:ExoPlayerClears the listener which receives camera motion events if it matches the one passed. Else does nothing.- Specified by:
clearCameraMotionListenerin interfaceExoPlayer- Parameters:
listener- The listener to clear.
-
setSeekParameters
public void setSeekParameters(@Nullable SeekParameters seekParameters)Description copied from interface:ExoPlayerSets the parameters that control how seek operations are performed.- Specified by:
setSeekParametersin interfaceExoPlayer- Parameters:
seekParameters- The seek parameters, ornullto use the defaults.
-
getSeekParameters
public SeekParameters getSeekParameters()
Description copied from interface:ExoPlayerReturns the currently activeSeekParametersof the player.- Specified by:
getSeekParametersin interfaceExoPlayer
-
createMessage
public PlayerMessage createMessage(PlayerMessage.Target target)
Description copied from interface:ExoPlayerCreates a message that can be sent to aPlayerMessage.Target. By default, the message will be delivered immediately without blocking on the playback thread. The defaultPlayerMessage.getType()is 0 and the defaultPlayerMessage.getPayload()is null. If a position is specified withPlayerMessage.setPosition(long), the message will be delivered at this position in the current media item defined byPlayer.getCurrentMediaItemIndex(). Alternatively, the message can be sent at a specific mediaItem usingPlayerMessage.setPosition(int, long).- Specified by:
createMessagein interfaceExoPlayer
-
getRendererCount
public int getRendererCount()
Description copied from interface:ExoPlayerReturns the number of renderers.- Specified by:
getRendererCountin interfaceExoPlayer
-
getRendererType
public int getRendererType(int index)
Description copied from interface:ExoPlayerReturns the track type that the renderer at a given index handles.For example, a video renderer will return
C.TRACK_TYPE_VIDEO, an audio renderer will returnC.TRACK_TYPE_AUDIOand a text renderer will returnC.TRACK_TYPE_TEXT.- Specified by:
getRendererTypein interfaceExoPlayer- Parameters:
index- The index of the renderer.- Returns:
- The
track typethat the renderer handles.
-
getTrackSelector
@Nullable public TrackSelector getTrackSelector()
Description copied from interface:ExoPlayerReturns the track selector that this player uses, or null if track selection is not supported.- Specified by:
getTrackSelectorin interfaceExoPlayer
-
setForegroundMode
public void setForegroundMode(boolean foregroundMode)
Description copied from interface:ExoPlayerSets whether the player is allowed to keep holding limited resources such as video decoders, even when in the idle state. By doing so, the player may be able to reduce latency when starting to play another piece of content for which the same resources are required.This mode should be used with caution, since holding limited resources may prevent other players of media components from acquiring them. It should only be enabled when both of the following conditions are true:
- The application that owns the player is in the foreground.
- The player is used in a way that may benefit from foreground mode. For this to be true,
the same player instance must be used to play multiple pieces of content, and there must
be gaps between the playbacks (i.e.
Player.stop()is called to halt one playback, andExoPlayer.prepare(com.google.android.exoplayer2.source.MediaSource)is called some time later to start a new one).
Note that foreground mode is not useful for switching between content without gaps between the playbacks. For this use case
Player.stop()does not need to be called, and simply callingExoPlayer.prepare(com.google.android.exoplayer2.source.MediaSource)for the new media will cause limited resources to be retained even if foreground mode is not enabled.If foreground mode is enabled, it's the application's responsibility to disable it when the conditions described above no longer hold.
- Specified by:
setForegroundModein interfaceExoPlayer- Parameters:
foregroundMode- Whether the player is allowed to keep limited resources even when in the idle state.
-
setPauseAtEndOfMediaItems
public void setPauseAtEndOfMediaItems(boolean pauseAtEndOfMediaItems)
Description copied from interface:ExoPlayerSets whether to pause playback at the end of each media item.This means the player will pause at the end of each window in the current
timeline. Listeners will be informed by a call toPlayer.Listener.onPlayWhenReadyChanged(boolean, int)with the reasonPlayer.PLAY_WHEN_READY_CHANGE_REASON_END_OF_MEDIA_ITEMwhen this happens.- Specified by:
setPauseAtEndOfMediaItemsin interfaceExoPlayer- Parameters:
pauseAtEndOfMediaItems- Whether to pause playback at the end of each media item.
-
getPauseAtEndOfMediaItems
public boolean getPauseAtEndOfMediaItems()
Description copied from interface:ExoPlayerReturns whether the player pauses playback at the end of each media item.- Specified by:
getPauseAtEndOfMediaItemsin interfaceExoPlayer- See Also:
ExoPlayer.setPauseAtEndOfMediaItems(boolean)
-
getAudioFormat
@Nullable public Format getAudioFormat()
Description copied from interface:ExoPlayerReturns the audio format currently being played, or null if no audio is being played.- Specified by:
getAudioFormatin interfaceExoPlayer
-
getVideoFormat
@Nullable public Format getVideoFormat()
Description copied from interface:ExoPlayerReturns the video format currently being played, or null if no video is being played.- Specified by:
getVideoFormatin interfaceExoPlayer
-
getAudioDecoderCounters
@Nullable public DecoderCounters getAudioDecoderCounters()
Description copied from interface:ExoPlayerReturnsDecoderCountersfor audio, or null if no audio is being played.- Specified by:
getAudioDecoderCountersin interfaceExoPlayer
-
getVideoDecoderCounters
@Nullable public DecoderCounters getVideoDecoderCounters()
Description copied from interface:ExoPlayerReturnsDecoderCountersfor video, or null if no video is being played.- Specified by:
getVideoDecoderCountersin interfaceExoPlayer
-
setHandleAudioBecomingNoisy
public void setHandleAudioBecomingNoisy(boolean handleAudioBecomingNoisy)
Description copied from interface:ExoPlayerSets whether the player should pause automatically when audio is rerouted from a headset to device speakers. See the audio becoming noisy documentation for more information.- Specified by:
setHandleAudioBecomingNoisyin interfaceExoPlayer- Parameters:
handleAudioBecomingNoisy- Whether the player should pause automatically when audio is rerouted from a headset to device speakers.
-
setHandleWakeLock
@Deprecated public void setHandleWakeLock(boolean handleWakeLock)
Deprecated.- Specified by:
setHandleWakeLockin interfaceExoPlayer
-
setWakeMode
public void setWakeMode(int wakeMode)
Description copied from interface:ExoPlayerSets how the player should keep the device awake for playback when the screen is off.Enabling this feature requires the
Manifest.permission.WAKE_LOCKpermission. It should be used together with a foregroundServicefor use cases where playback occurs and the screen is off (e.g. background audio playback). It is not useful when the screen will be kept on during playback (e.g. foreground video playback).When enabled, the locks (
PowerManager.WakeLock/WifiManager.WifiLock) will be held whenever the player is in thePlayer.STATE_READYorPlayer.STATE_BUFFERINGstates withplayWhenReady = true. The locks held depends on the specifiedC.WakeMode.- Specified by:
setWakeModein interfaceExoPlayer- Parameters:
wakeMode- TheC.WakeModeoption to keep the device awake during playback.
-
setPriorityTaskManager
public void setPriorityTaskManager(@Nullable PriorityTaskManager priorityTaskManager)Description copied from interface:ExoPlayerSets aPriorityTaskManager, or null to clear a previously set priority task manager.The priority
C.PRIORITY_PLAYBACKwill be set while the player is loading.- Specified by:
setPriorityTaskManagerin interfaceExoPlayer- Parameters:
priorityTaskManager- ThePriorityTaskManager, or null to clear a previously set priority task manager.
-
setThrowsWhenUsingWrongThread
@Deprecated public void setThrowsWhenUsingWrongThread(boolean throwsWhenUsingWrongThread)
Deprecated.Description copied from interface:ExoPlayerSets whether the player should throw anIllegalStateExceptionwhen methods are called from a thread other than the one associated withPlayer.getApplicationLooper().The default is
trueand this method will be removed in the future.- Specified by:
setThrowsWhenUsingWrongThreadin interfaceExoPlayer- Parameters:
throwsWhenUsingWrongThread- Whether to throw when methods are called from a wrong thread.
-
experimentalSetOffloadSchedulingEnabled
public void experimentalSetOffloadSchedulingEnabled(boolean offloadSchedulingEnabled)
Description copied from interface:ExoPlayerSets whether audio offload scheduling is enabled. If enabled, ExoPlayer's main loop will run as rarely as possible when playing an audio stream using audio offload.Only use this scheduling mode if the player is not displaying anything to the user. For example when the application is in the background, or the screen is off. The player state (including position) is rarely updated (roughly between every 10 seconds and 1 minute).
While offload scheduling is enabled, player events may be delivered severely delayed and apps should not interact with the player. When returning to the foreground, disable offload scheduling and wait for
ExoPlayer.AudioOffloadListener.onExperimentalOffloadSchedulingEnabledChanged(boolean)to be called withoffloadSchedulingEnabled = falsebefore interacting with the player.This mode should save significant power when the phone is playing offload audio with the screen off.
This mode only has an effect when playing an audio track in offload mode, which requires all the following:
- Audio offload rendering is enabled in
DefaultRenderersFactory.setEnableAudioOffload(boolean)or the equivalent option passed toDefaultAudioSink(AudioCapabilities, DefaultAudioSink.AudioProcessorChain, boolean, boolean, int). - An audio track is playing in a format that the device supports offloading (for example, MP3 or AAC).
- The
AudioSinkis playing with an offloadAudioTrack.
The state where ExoPlayer main loop has been paused to save power during offload playback can be queried with
ExoPlayer.experimentalIsSleepingForOffload().This method is experimental, and will be renamed or removed in a future release.
- Specified by:
experimentalSetOffloadSchedulingEnabledin interfaceExoPlayer- Parameters:
offloadSchedulingEnabled- Whether to enable offload scheduling.
- Audio offload rendering is enabled in
-
experimentalIsSleepingForOffload
public boolean experimentalIsSleepingForOffload()
Description copied from interface:ExoPlayerReturns whether the player has paused its main loop to save power in offload scheduling mode.
-
-