FakeTrackSelection
@UnstableApi
class FakeTrackSelection : BaseTrackSelection
| kotlin.Any | ||
| ↳ | androidx.media3.exoplayer.trackselection.BaseTrackSelection | |
| ↳ | androidx.media3.test.utils.FakeTrackSelection |
A fake ExoTrackSelection that only returns 1 fixed track, and allows querying the number of calls to its methods.
Summary
Public constructors |
|---|
FakeTrackSelection(rendererTrackGroup: TrackGroup!) |
FakeTrackSelection(rendererTrackGroup: TrackGroup!, selectedIndex: Int) |
Public functions |
|
|---|---|
Unit |
disable()Disables this track selection. |
Unit |
enable()Enables the track selection. |
Boolean |
|
Int |
evaluateQueueSize(Returns the number of chunks that should be retained in the queue. |
Boolean |
excludeTrack(index: Int, exclusionDurationMs: Long)Attempts to exclude the track at the specified index in the selection, making it ineligible for selection by calls to |
Any? |
Returns optional data associated with the current track selection. |
Int |
Returns the reason for the current track selection. |
Int |
hashCode() |
Boolean |
isTrackExcluded(index: Int, nowMs: Long)Returns whether the track at the specified index in the selection is excluded. |
Unit |
updateSelectedTrack(Updates the selected track for sources that load media in discrete |
Inherited Constants |
||||
|---|---|---|---|---|
|
Inherited functions |
||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||
|
Inherited properties |
||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
Public functions
disable
fun disable(): Unit
Disables this track selection. No further dynamic changes via updateSelectedTrack, evaluateQueueSize or shouldCancelChunkLoad will happen after this call.
This method may only be called when the track selection is already enabled.
enable
fun enable(): Unit
Enables the track selection. Dynamic changes via updateSelectedTrack, evaluateQueueSize or shouldCancelChunkLoad will only happen after this call.
This method may not be called when the track selection is already enabled.
evaluateQueueSize
fun evaluateQueueSize(
playbackPositionUs: Long,
queue: (Mutable)List<MediaChunk!>!
): Int
Returns the number of chunks that should be retained in the queue.
May be called by sources that load media in discrete MediaChunks and support discarding of buffered chunks.
To avoid excessive re-buffering, implementations should normally return the size of the queue. An example of a case where a smaller value may be returned is if network conditions have improved dramatically, allowing chunks to be discarded and re-buffered in a track of significantly higher quality. Discarding chunks may allow faster switching to a higher quality track in this case.
Note that even if the source supports discarding of buffered chunks, the actual number of discarded chunks is not guaranteed. The source will call updateSelectedTrack with the updated queue of chunks before loading a new chunk to allow switching to another quality.
This method will only be called when the selection is enabled and none of the MediaChunks in the queue are currently loading.
| Parameters | |
|---|---|
playbackPositionUs: Long |
The current playback position in microseconds. If playback of the period to which this track selection belongs has not yet started, the value will be the starting position in the period minus the duration of any media in previous periods still to be played. |
queue: (Mutable)List<MediaChunk!>! |
The queue of buffered |
| Returns | |
|---|---|
Int |
The number of chunks to retain in the queue. |
excludeTrack
fun excludeTrack(index: Int, exclusionDurationMs: Long): Boolean
Attempts to exclude the track at the specified index in the selection, making it ineligible for selection by calls to updateSelectedTrack for the specified period of time.
Exclusion will fail if all other tracks are currently excluded. If excluding the currently selected track, note that it will remain selected until the next call to updateSelectedTrack.
This method will only be called when the selection is enabled.
| Parameters | |
|---|---|
index: Int |
The index of the track in the selection. |
exclusionDurationMs: Long |
The duration of time for which the track should be excluded, in milliseconds. |
| Returns | |
|---|---|
Boolean |
Whether exclusion was successful. |
getSelectionData
fun getSelectionData(): Any?
Returns optional data associated with the current track selection.
getSelectionReason
@C.SelectionReason
fun getSelectionReason(): Int
Returns the reason for the current track selection.
isTrackExcluded
fun isTrackExcluded(index: Int, nowMs: Long): Boolean
Returns whether the track at the specified index in the selection is excluded.
| Parameters | |
|---|---|
index: Int |
The index of the track in the selection. |
nowMs: Long |
The current time in the timebase of |
updateSelectedTrack
fun updateSelectedTrack(
playbackPositionUs: Long,
bufferedDurationUs: Long,
availableDurationUs: Long,
queue: (Mutable)List<MediaChunk!>!,
mediaChunkIterators: Array<MediaChunkIterator!>!
): Unit
Updates the selected track for sources that load media in discrete MediaChunks.
This method will only be called when the selection is enabled.
| Parameters | |
|---|---|
playbackPositionUs: Long |
The current playback position in microseconds. If playback of the period to which this track selection belongs has not yet started, the value will be the starting position in the period minus the duration of any media in previous periods still to be played. |
bufferedDurationUs: Long |
The duration of media currently buffered from the current playback position, in microseconds. Note that the next load position can be calculated as |
availableDurationUs: Long |
The duration of media available for buffering from the current playback position, in microseconds, or |
queue: (Mutable)List<MediaChunk!>! |
The queue of already buffered |
mediaChunkIterators: Array<MediaChunkIterator!>! |
An array of |