Class DefaultHlsPlaylistTracker
- java.lang.Object
-
- com.google.android.exoplayer2.source.hls.playlist.DefaultHlsPlaylistTracker
-
- All Implemented Interfaces:
HlsPlaylistTracker
,Loader.Callback<ParsingLoadable<HlsPlaylist>>
@Deprecated public final class DefaultHlsPlaylistTracker extends Object implements HlsPlaylistTracker, Loader.Callback<ParsingLoadable<HlsPlaylist>>
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.Default implementation forHlsPlaylistTracker
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.source.hls.playlist.HlsPlaylistTracker
HlsPlaylistTracker.Factory, HlsPlaylistTracker.PlaylistEventListener, HlsPlaylistTracker.PlaylistResetException, HlsPlaylistTracker.PlaylistStuckException, HlsPlaylistTracker.PrimaryPlaylistListener
-
-
Field Summary
Fields Modifier and Type Field Description static double
DEFAULT_PLAYLIST_STUCK_TARGET_DURATION_COEFFICIENT
Deprecated.Default coefficient applied on the target duration of a playlist to determine the amount of time after which an unchanging playlist is considered stuck.static HlsPlaylistTracker.Factory
FACTORY
Deprecated.Factory forDefaultHlsPlaylistTracker
instances.
-
Constructor Summary
Constructors Constructor Description DefaultHlsPlaylistTracker(HlsDataSourceFactory dataSourceFactory, LoadErrorHandlingPolicy loadErrorHandlingPolicy, HlsPlaylistParserFactory playlistParserFactory)
Deprecated.Creates an instance.DefaultHlsPlaylistTracker(HlsDataSourceFactory dataSourceFactory, LoadErrorHandlingPolicy loadErrorHandlingPolicy, HlsPlaylistParserFactory playlistParserFactory, double playlistStuckTargetDurationCoefficient)
Deprecated.Creates an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addListener(HlsPlaylistTracker.PlaylistEventListener listener)
Deprecated.Registers a listener to receive events from the playlist tracker.boolean
excludeMediaPlaylist(Uri playlistUrl, long exclusionDurationMs)
Deprecated.Excludes the given media playlist for the given duration, in milliseconds.long
getInitialStartTimeUs()
Deprecated.Returns the start time of the first loaded primary playlist, orC.TIME_UNSET
if no media playlist has been loaded.HlsMultivariantPlaylist
getMultivariantPlaylist()
Deprecated.Returns the multivariant playlist.HlsMediaPlaylist
getPlaylistSnapshot(Uri url, boolean isForPlayback)
Deprecated.Returns the most recent snapshot available of the playlist referenced by the providedUri
.boolean
isLive()
Deprecated.Returns whether the tracked playlists describe a live stream.boolean
isSnapshotValid(Uri url)
Deprecated.Returns whether the snapshot of the playlist referenced by the providedUri
is valid, meaning all the segments referenced by the playlist are expected to be available.void
maybeThrowPlaylistRefreshError(Uri url)
Deprecated.If the playlist is having trouble refreshing the playlist referenced by the givenUri
, this method throws the underlying error.void
maybeThrowPrimaryPlaylistRefreshError()
Deprecated.If the tracker is having trouble refreshing the multivariant playlist or the primary playlist, this method throws the underlying error.void
onLoadCanceled(ParsingLoadable<HlsPlaylist> loadable, long elapsedRealtimeMs, long loadDurationMs, boolean released)
Deprecated.Called when a load has been canceled.void
onLoadCompleted(ParsingLoadable<HlsPlaylist> loadable, long elapsedRealtimeMs, long loadDurationMs)
Deprecated.Called when a load has completed.Loader.LoadErrorAction
onLoadError(ParsingLoadable<HlsPlaylist> loadable, long elapsedRealtimeMs, long loadDurationMs, IOException error, int errorCount)
Deprecated.Called when a load encounters an error.void
refreshPlaylist(Uri url)
Deprecated.Requests a playlist refresh and removes it from the exclusion list.void
removeListener(HlsPlaylistTracker.PlaylistEventListener listener)
Deprecated.Unregisters a listener.void
start(Uri initialPlaylistUri, MediaSourceEventListener.EventDispatcher eventDispatcher, HlsPlaylistTracker.PrimaryPlaylistListener primaryPlaylistListener)
Deprecated.Starts the playlist tracker.void
stop()
Deprecated.Stops the playlist tracker and releases any acquired resources.
-
-
-
Field Detail
-
FACTORY
public static final HlsPlaylistTracker.Factory FACTORY
Deprecated.Factory forDefaultHlsPlaylistTracker
instances.
-
DEFAULT_PLAYLIST_STUCK_TARGET_DURATION_COEFFICIENT
public static final double DEFAULT_PLAYLIST_STUCK_TARGET_DURATION_COEFFICIENT
Deprecated.Default coefficient applied on the target duration of a playlist to determine the amount of time after which an unchanging playlist is considered stuck.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultHlsPlaylistTracker
public DefaultHlsPlaylistTracker(HlsDataSourceFactory dataSourceFactory, LoadErrorHandlingPolicy loadErrorHandlingPolicy, HlsPlaylistParserFactory playlistParserFactory)
Deprecated.Creates an instance.- Parameters:
dataSourceFactory
- A factory forDataSource
instances.loadErrorHandlingPolicy
- TheLoadErrorHandlingPolicy
.playlistParserFactory
- AnHlsPlaylistParserFactory
.
-
DefaultHlsPlaylistTracker
public DefaultHlsPlaylistTracker(HlsDataSourceFactory dataSourceFactory, LoadErrorHandlingPolicy loadErrorHandlingPolicy, HlsPlaylistParserFactory playlistParserFactory, double playlistStuckTargetDurationCoefficient)
Deprecated.Creates an instance.- Parameters:
dataSourceFactory
- A factory forDataSource
instances.loadErrorHandlingPolicy
- TheLoadErrorHandlingPolicy
.playlistParserFactory
- AnHlsPlaylistParserFactory
.playlistStuckTargetDurationCoefficient
- A coefficient to apply to the target duration of media playlists in order to determine that a non-changing playlist is stuck. Once a playlist is deemed stuck, aHlsPlaylistTracker.PlaylistStuckException
is thrown viamaybeThrowPlaylistRefreshError(Uri)
.
-
-
Method Detail
-
start
public void start(Uri initialPlaylistUri, MediaSourceEventListener.EventDispatcher eventDispatcher, HlsPlaylistTracker.PrimaryPlaylistListener primaryPlaylistListener)
Deprecated.Description copied from interface:HlsPlaylistTracker
Starts the playlist tracker.Must be called from the playback thread. A tracker may be restarted after a
HlsPlaylistTracker.stop()
call.- Specified by:
start
in interfaceHlsPlaylistTracker
- Parameters:
initialPlaylistUri
- Uri of the HLS stream. Can point to a media playlist or a multivariant playlist.eventDispatcher
- A dispatcher to notify of events.primaryPlaylistListener
- A callback for the primary playlist change events.
-
stop
public void stop()
Deprecated.Description copied from interface:HlsPlaylistTracker
Stops the playlist tracker and releases any acquired resources.Must be called once per
HlsPlaylistTracker.start(android.net.Uri, com.google.android.exoplayer2.source.MediaSourceEventListener.EventDispatcher, com.google.android.exoplayer2.source.hls.playlist.HlsPlaylistTracker.PrimaryPlaylistListener)
call.- Specified by:
stop
in interfaceHlsPlaylistTracker
-
addListener
public void addListener(HlsPlaylistTracker.PlaylistEventListener listener)
Deprecated.Description copied from interface:HlsPlaylistTracker
Registers a listener to receive events from the playlist tracker.- Specified by:
addListener
in interfaceHlsPlaylistTracker
- Parameters:
listener
- The listener.
-
removeListener
public void removeListener(HlsPlaylistTracker.PlaylistEventListener listener)
Deprecated.Description copied from interface:HlsPlaylistTracker
Unregisters a listener.- Specified by:
removeListener
in interfaceHlsPlaylistTracker
- Parameters:
listener
- The listener to unregister.
-
getMultivariantPlaylist
@Nullable public HlsMultivariantPlaylist getMultivariantPlaylist()
Deprecated.Description copied from interface:HlsPlaylistTracker
Returns the multivariant playlist.If the uri passed to
HlsPlaylistTracker.start(android.net.Uri, com.google.android.exoplayer2.source.MediaSourceEventListener.EventDispatcher, com.google.android.exoplayer2.source.hls.playlist.HlsPlaylistTracker.PrimaryPlaylistListener)
points to a media playlist, anHlsMultivariantPlaylist
with a single variant for said media playlist is returned.- Specified by:
getMultivariantPlaylist
in interfaceHlsPlaylistTracker
- Returns:
- The multivariant playlist. Null if the initial playlist has yet to be loaded.
-
getPlaylistSnapshot
@Nullable public HlsMediaPlaylist getPlaylistSnapshot(Uri url, boolean isForPlayback)
Deprecated.Description copied from interface:HlsPlaylistTracker
Returns the most recent snapshot available of the playlist referenced by the providedUri
.- Specified by:
getPlaylistSnapshot
in interfaceHlsPlaylistTracker
- Parameters:
url
- TheUri
corresponding to the requested media playlist.isForPlayback
- Whether the caller might use the snapshot to request media segments for playback. If true, the primary playlist may be updated to the one requested.- Returns:
- The most recent snapshot of the playlist referenced by the provided
Uri
. May be null if no snapshot has been loaded yet.
-
getInitialStartTimeUs
public long getInitialStartTimeUs()
Deprecated.Description copied from interface:HlsPlaylistTracker
Returns the start time of the first loaded primary playlist, orC.TIME_UNSET
if no media playlist has been loaded.- Specified by:
getInitialStartTimeUs
in interfaceHlsPlaylistTracker
-
isSnapshotValid
public boolean isSnapshotValid(Uri url)
Deprecated.Description copied from interface:HlsPlaylistTracker
Returns whether the snapshot of the playlist referenced by the providedUri
is valid, meaning all the segments referenced by the playlist are expected to be available. If the playlist is not valid then some of the segments may no longer be available.- Specified by:
isSnapshotValid
in interfaceHlsPlaylistTracker
- Parameters:
url
- TheUri
.- Returns:
- Whether the snapshot of the playlist referenced by the provided
Uri
is valid.
-
maybeThrowPrimaryPlaylistRefreshError
public void maybeThrowPrimaryPlaylistRefreshError() throws IOException
Deprecated.Description copied from interface:HlsPlaylistTracker
If the tracker is having trouble refreshing the multivariant playlist or the primary playlist, this method throws the underlying error. Otherwise, does nothing.- Specified by:
maybeThrowPrimaryPlaylistRefreshError
in interfaceHlsPlaylistTracker
- Throws:
IOException
- The underlying error.
-
maybeThrowPlaylistRefreshError
public void maybeThrowPlaylistRefreshError(Uri url) throws IOException
Deprecated.Description copied from interface:HlsPlaylistTracker
If the playlist is having trouble refreshing the playlist referenced by the givenUri
, this method throws the underlying error.- Specified by:
maybeThrowPlaylistRefreshError
in interfaceHlsPlaylistTracker
- Parameters:
url
- TheUri
.- Throws:
IOException
- The underyling error.
-
refreshPlaylist
public void refreshPlaylist(Uri url)
Deprecated.Description copied from interface:HlsPlaylistTracker
Requests a playlist refresh and removes it from the exclusion list.The playlist tracker may choose to delay the playlist refresh. The request is discarded if a refresh was already pending.
- Specified by:
refreshPlaylist
in interfaceHlsPlaylistTracker
- Parameters:
url
- TheUri
of the playlist to be refreshed.
-
isLive
public boolean isLive()
Deprecated.Description copied from interface:HlsPlaylistTracker
Returns whether the tracked playlists describe a live stream.- Specified by:
isLive
in interfaceHlsPlaylistTracker
- Returns:
- True if the content is live. False otherwise.
-
excludeMediaPlaylist
public boolean excludeMediaPlaylist(Uri playlistUrl, long exclusionDurationMs)
Deprecated.Description copied from interface:HlsPlaylistTracker
Excludes the given media playlist for the given duration, in milliseconds.- Specified by:
excludeMediaPlaylist
in interfaceHlsPlaylistTracker
- Parameters:
playlistUrl
- The URL of the media playlist.exclusionDurationMs
- The duration for which to exclude the playlist.- Returns:
- Whether exclusion was successful.
-
onLoadCompleted
public void onLoadCompleted(ParsingLoadable<HlsPlaylist> loadable, long elapsedRealtimeMs, long loadDurationMs)
Deprecated.Description copied from interface:Loader.Callback
Called when a load has completed.Note: There is guaranteed to be a memory barrier between
Loader.Loadable.load()
exiting and this callback being called.- Specified by:
onLoadCompleted
in interfaceLoader.Callback<ParsingLoadable<HlsPlaylist>>
- Parameters:
loadable
- The loadable whose load has completed.elapsedRealtimeMs
-SystemClock.elapsedRealtime()
when the load ended.loadDurationMs
- The duration in milliseconds of the load sinceLoader.startLoading(T, com.google.android.exoplayer2.upstream.Loader.Callback<T>, int)
was called.
-
onLoadCanceled
public void onLoadCanceled(ParsingLoadable<HlsPlaylist> loadable, long elapsedRealtimeMs, long loadDurationMs, boolean released)
Deprecated.Description copied from interface:Loader.Callback
Called when a load has been canceled.Note: If the
Loader
has not been released then there is guaranteed to be a memory barrier betweenLoader.Loadable.load()
exiting and this callback being called. If theLoader
has been released then this callback may be called beforeLoader.Loadable.load()
exits.- Specified by:
onLoadCanceled
in interfaceLoader.Callback<ParsingLoadable<HlsPlaylist>>
- Parameters:
loadable
- The loadable whose load has been canceled.elapsedRealtimeMs
-SystemClock.elapsedRealtime()
when the load was canceled.loadDurationMs
- The duration in milliseconds of the load sinceLoader.startLoading(T, com.google.android.exoplayer2.upstream.Loader.Callback<T>, int)
was called up to the point at which it was canceled.released
- True if the load was canceled because theLoader
was released. False otherwise.
-
onLoadError
public Loader.LoadErrorAction onLoadError(ParsingLoadable<HlsPlaylist> loadable, long elapsedRealtimeMs, long loadDurationMs, IOException error, int errorCount)
Deprecated.Description copied from interface:Loader.Callback
Called when a load encounters an error.Note: There is guaranteed to be a memory barrier between
Loader.Loadable.load()
exiting and this callback being called.- Specified by:
onLoadError
in interfaceLoader.Callback<ParsingLoadable<HlsPlaylist>>
- Parameters:
loadable
- The loadable whose load has encountered an error.elapsedRealtimeMs
-SystemClock.elapsedRealtime()
when the error occurred.loadDurationMs
- The duration in milliseconds of the load sinceLoader.startLoading(T, com.google.android.exoplayer2.upstream.Loader.Callback<T>, int)
was called up to the point at which the error occurred.error
- The load error.errorCount
- The number of errors this load has encountered, including this one.- Returns:
- The desired error handling action. One of
Loader.RETRY
,Loader.RETRY_RESET_ERROR_COUNT
,Loader.DONT_RETRY
,Loader.DONT_RETRY_FATAL
or a retry action created byLoader.createRetryAction(boolean, long)
.
-
-