Class TrackSelectionParameters.Builder
- java.lang.Object
-
- com.google.android.exoplayer2.trackselection.TrackSelectionParameters.Builder
-
- Direct Known Subclasses:
DefaultTrackSelector.Parameters.Builder
,DefaultTrackSelector.ParametersBuilder
- Enclosing class:
- TrackSelectionParameters
public static class TrackSelectionParameters.Builder extends Object
A builder forTrackSelectionParameters
. See theTrackSelectionParameters
documentation for explanations of the parameters that can be configured using this builder.
-
-
Constructor Summary
Constructors Modifier Constructor Description Builder()
Deprecated.Context
constraints will not be set using this constructor.Builder(Context context)
Creates a builder with default initial values.protected
Builder(Bundle bundle)
Creates a builder with the initial values specified inbundle
.protected
Builder(TrackSelectionParameters initialValues)
Creates a builder with the initial values specified ininitialValues
.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description TrackSelectionParameters.Builder
addOverride(TrackSelectionOverride override)
Adds an override, replacing any override for the sameTrackGroup
.TrackSelectionParameters
build()
Builds aTrackSelectionParameters
instance with the selected values.TrackSelectionParameters.Builder
clearOverride(TrackGroup mediaTrackGroup)
Removes the override for the provided mediaTrackGroup
, if there is one.TrackSelectionParameters.Builder
clearOverrides()
Removes all overrides.TrackSelectionParameters.Builder
clearOverridesOfType(@com.google.android.exoplayer2.C.TrackType int trackType)
Removes all overrides of the provided track type.TrackSelectionParameters.Builder
clearVideoSizeConstraints()
Equivalent tosetMaxVideoSize(Integer.MAX_VALUE, Integer.MAX_VALUE)
.TrackSelectionParameters.Builder
clearViewportSizeConstraints()
Equivalent tosetViewportSize(Integer.MAX_VALUE, Integer.MAX_VALUE, true)
.protected TrackSelectionParameters.Builder
set(TrackSelectionParameters parameters)
Overrides the value of the builder with the value ofTrackSelectionParameters
.TrackSelectionParameters.Builder
setDisabledTrackTypes(Set<@TrackType Integer> disabledTrackTypes)
Deprecated.TrackSelectionParameters.Builder
setForceHighestSupportedBitrate(boolean forceHighestSupportedBitrate)
Sets whether to force selection of the highest bitrate audio and video tracks that comply with all other constraints.TrackSelectionParameters.Builder
setForceLowestBitrate(boolean forceLowestBitrate)
Sets whether to force selection of the single lowest bitrate audio and video tracks that comply with all other constraints.TrackSelectionParameters.Builder
setIgnoredTextSelectionFlags(@com.google.android.exoplayer2.C.SelectionFlags int ignoredTextSelectionFlags)
Sets a bitmask of selection flags that are ignored for text track selections.TrackSelectionParameters.Builder
setMaxAudioBitrate(int maxAudioBitrate)
Sets the maximum allowed audio bitrate.TrackSelectionParameters.Builder
setMaxAudioChannelCount(int maxAudioChannelCount)
Sets the maximum allowed audio channel count.TrackSelectionParameters.Builder
setMaxVideoBitrate(int maxVideoBitrate)
Sets the maximum allowed video bitrate.TrackSelectionParameters.Builder
setMaxVideoFrameRate(int maxVideoFrameRate)
Sets the maximum allowed video frame rate.TrackSelectionParameters.Builder
setMaxVideoSize(int maxVideoWidth, int maxVideoHeight)
Sets the maximum allowed video width and height.TrackSelectionParameters.Builder
setMaxVideoSizeSd()
Equivalent tosetMaxVideoSize(1279, 719)
.TrackSelectionParameters.Builder
setMinVideoBitrate(int minVideoBitrate)
Sets the minimum allowed video bitrate.TrackSelectionParameters.Builder
setMinVideoFrameRate(int minVideoFrameRate)
Sets the minimum allowed video frame rate.TrackSelectionParameters.Builder
setMinVideoSize(int minVideoWidth, int minVideoHeight)
Sets the minimum allowed video width and height.TrackSelectionParameters.Builder
setOverrideForType(TrackSelectionOverride override)
Sets an override, replacing all existing overrides with the same track type.TrackSelectionParameters.Builder
setPreferredAudioLanguage(String preferredAudioLanguage)
Sets the preferred language for audio and forced text tracks.TrackSelectionParameters.Builder
setPreferredAudioLanguages(String... preferredAudioLanguages)
Sets the preferred languages for audio and forced text tracks.TrackSelectionParameters.Builder
setPreferredAudioMimeType(String mimeType)
Sets the preferred sample MIME type for audio tracks.TrackSelectionParameters.Builder
setPreferredAudioMimeTypes(String... mimeTypes)
Sets the preferred sample MIME types for audio tracks.TrackSelectionParameters.Builder
setPreferredAudioRoleFlags(@com.google.android.exoplayer2.C.RoleFlags int preferredAudioRoleFlags)
Sets the preferredC.RoleFlags
for audio tracks.TrackSelectionParameters.Builder
setPreferredTextLanguage(String preferredTextLanguage)
Sets the preferred language for text tracks.TrackSelectionParameters.Builder
setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettings(Context context)
Sets the preferred language and role flags for text tracks based on the accessibility settings ofCaptioningManager
.TrackSelectionParameters.Builder
setPreferredTextLanguages(String... preferredTextLanguages)
Sets the preferred languages for text tracks.TrackSelectionParameters.Builder
setPreferredTextRoleFlags(@com.google.android.exoplayer2.C.RoleFlags int preferredTextRoleFlags)
Sets the preferredC.RoleFlags
for text tracks.TrackSelectionParameters.Builder
setPreferredVideoMimeType(String mimeType)
Sets the preferred sample MIME type for video tracks.TrackSelectionParameters.Builder
setPreferredVideoMimeTypes(String... mimeTypes)
Sets the preferred sample MIME types for video tracks.TrackSelectionParameters.Builder
setPreferredVideoRoleFlags(@com.google.android.exoplayer2.C.RoleFlags int preferredVideoRoleFlags)
Sets the preferredC.RoleFlags
for video tracks.TrackSelectionParameters.Builder
setSelectUndeterminedTextLanguage(boolean selectUndeterminedTextLanguage)
Sets whether a text track with undetermined language should be selected if no track witha preferred language
is available, or if the preferred language is unset.TrackSelectionParameters.Builder
setTrackTypeDisabled(@com.google.android.exoplayer2.C.TrackType int trackType, boolean disabled)
Sets whether a track type is disabled.TrackSelectionParameters.Builder
setViewportSize(int viewportWidth, int viewportHeight, boolean viewportOrientationMayChange)
Sets the viewport size to constrain adaptive video selections so that only tracks suitable for the viewport are selected.TrackSelectionParameters.Builder
setViewportSizeToPhysicalDisplaySize(Context context, boolean viewportOrientationMayChange)
Equivalent to callingsetViewportSize(int, int, boolean)
with the viewport size obtained fromUtil.getCurrentDisplayModeSize(Context)
.
-
-
-
Constructor Detail
-
Builder
@Deprecated public Builder()
Deprecated.Context
constraints will not be set using this constructor. UseBuilder(Context)
instead.
-
Builder
public Builder(Context context)
Creates a builder with default initial values.- Parameters:
context
- Any context.
-
Builder
protected Builder(TrackSelectionParameters initialValues)
Creates a builder with the initial values specified ininitialValues
.
-
Builder
protected Builder(Bundle bundle)
Creates a builder with the initial values specified inbundle
.
-
-
Method Detail
-
set
@CanIgnoreReturnValue protected TrackSelectionParameters.Builder set(TrackSelectionParameters parameters)
Overrides the value of the builder with the value ofTrackSelectionParameters
.
-
setMaxVideoSizeSd
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setMaxVideoSizeSd()
Equivalent tosetMaxVideoSize(1279, 719)
.- Returns:
- This builder.
-
clearVideoSizeConstraints
@CanIgnoreReturnValue public TrackSelectionParameters.Builder clearVideoSizeConstraints()
Equivalent tosetMaxVideoSize(Integer.MAX_VALUE, Integer.MAX_VALUE)
.- Returns:
- This builder.
-
setMaxVideoSize
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setMaxVideoSize(int maxVideoWidth, int maxVideoHeight)
Sets the maximum allowed video width and height.- Parameters:
maxVideoWidth
- Maximum allowed video width in pixels.maxVideoHeight
- Maximum allowed video height in pixels.- Returns:
- This builder.
-
setMaxVideoFrameRate
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setMaxVideoFrameRate(int maxVideoFrameRate)
Sets the maximum allowed video frame rate.- Parameters:
maxVideoFrameRate
- Maximum allowed video frame rate in hertz.- Returns:
- This builder.
-
setMaxVideoBitrate
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setMaxVideoBitrate(int maxVideoBitrate)
Sets the maximum allowed video bitrate.- Parameters:
maxVideoBitrate
- Maximum allowed video bitrate in bits per second.- Returns:
- This builder.
-
setMinVideoSize
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setMinVideoSize(int minVideoWidth, int minVideoHeight)
Sets the minimum allowed video width and height.- Parameters:
minVideoWidth
- Minimum allowed video width in pixels.minVideoHeight
- Minimum allowed video height in pixels.- Returns:
- This builder.
-
setMinVideoFrameRate
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setMinVideoFrameRate(int minVideoFrameRate)
Sets the minimum allowed video frame rate.- Parameters:
minVideoFrameRate
- Minimum allowed video frame rate in hertz.- Returns:
- This builder.
-
setMinVideoBitrate
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setMinVideoBitrate(int minVideoBitrate)
Sets the minimum allowed video bitrate.- Parameters:
minVideoBitrate
- Minimum allowed video bitrate in bits per second.- Returns:
- This builder.
-
setViewportSizeToPhysicalDisplaySize
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setViewportSizeToPhysicalDisplaySize(Context context, boolean viewportOrientationMayChange)
Equivalent to callingsetViewportSize(int, int, boolean)
with the viewport size obtained fromUtil.getCurrentDisplayModeSize(Context)
.- Parameters:
context
- Any context.viewportOrientationMayChange
- Whether the viewport orientation may change during playback.- Returns:
- This builder.
-
clearViewportSizeConstraints
@CanIgnoreReturnValue public TrackSelectionParameters.Builder clearViewportSizeConstraints()
Equivalent tosetViewportSize(Integer.MAX_VALUE, Integer.MAX_VALUE, true)
.- Returns:
- This builder.
-
setViewportSize
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setViewportSize(int viewportWidth, int viewportHeight, boolean viewportOrientationMayChange)
Sets the viewport size to constrain adaptive video selections so that only tracks suitable for the viewport are selected.- Parameters:
viewportWidth
- Viewport width in pixels.viewportHeight
- Viewport height in pixels.viewportOrientationMayChange
- Whether the viewport orientation may change during playback.- Returns:
- This builder.
-
setPreferredVideoMimeType
public TrackSelectionParameters.Builder setPreferredVideoMimeType(@Nullable String mimeType)
Sets the preferred sample MIME type for video tracks.- Parameters:
mimeType
- The preferred MIME type for video tracks, ornull
to clear a previously set preference.- Returns:
- This builder.
-
setPreferredVideoMimeTypes
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setPreferredVideoMimeTypes(String... mimeTypes)
Sets the preferred sample MIME types for video tracks.- Parameters:
mimeTypes
- The preferred MIME types for video tracks in order of preference, or an empty list for no preference.- Returns:
- This builder.
-
setPreferredVideoRoleFlags
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setPreferredVideoRoleFlags(@RoleFlags @com.google.android.exoplayer2.C.RoleFlags int preferredVideoRoleFlags)
Sets the preferredC.RoleFlags
for video tracks.- Parameters:
preferredVideoRoleFlags
- Preferred video role flags.- Returns:
- This builder.
-
setPreferredAudioLanguage
public TrackSelectionParameters.Builder setPreferredAudioLanguage(@Nullable String preferredAudioLanguage)
Sets the preferred language for audio and forced text tracks.- Parameters:
preferredAudioLanguage
- Preferred audio language as an IETF BCP 47 conformant tag, ornull
to select the default track, or the first track if there's no default.- Returns:
- This builder.
-
setPreferredAudioLanguages
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setPreferredAudioLanguages(String... preferredAudioLanguages)
Sets the preferred languages for audio and forced text tracks.- Parameters:
preferredAudioLanguages
- Preferred audio languages as IETF BCP 47 conformant tags in order of preference, or an empty array to select the default track, or the first track if there's no default.- Returns:
- This builder.
-
setPreferredAudioRoleFlags
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setPreferredAudioRoleFlags(@RoleFlags @com.google.android.exoplayer2.C.RoleFlags int preferredAudioRoleFlags)
Sets the preferredC.RoleFlags
for audio tracks.- Parameters:
preferredAudioRoleFlags
- Preferred audio role flags.- Returns:
- This builder.
-
setMaxAudioChannelCount
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setMaxAudioChannelCount(int maxAudioChannelCount)
Sets the maximum allowed audio channel count.- Parameters:
maxAudioChannelCount
- Maximum allowed audio channel count.- Returns:
- This builder.
-
setMaxAudioBitrate
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setMaxAudioBitrate(int maxAudioBitrate)
Sets the maximum allowed audio bitrate.- Parameters:
maxAudioBitrate
- Maximum allowed audio bitrate in bits per second.- Returns:
- This builder.
-
setPreferredAudioMimeType
public TrackSelectionParameters.Builder setPreferredAudioMimeType(@Nullable String mimeType)
Sets the preferred sample MIME type for audio tracks.- Parameters:
mimeType
- The preferred MIME type for audio tracks, ornull
to clear a previously set preference.- Returns:
- This builder.
-
setPreferredAudioMimeTypes
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setPreferredAudioMimeTypes(String... mimeTypes)
Sets the preferred sample MIME types for audio tracks.- Parameters:
mimeTypes
- The preferred MIME types for audio tracks in order of preference, or an empty list for no preference.- Returns:
- This builder.
-
setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettings
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettings(Context context)
Sets the preferred language and role flags for text tracks based on the accessibility settings ofCaptioningManager
.Does nothing for API levels < 19 or when the
CaptioningManager
is disabled.- Parameters:
context
- AContext
.- Returns:
- This builder.
-
setPreferredTextLanguage
public TrackSelectionParameters.Builder setPreferredTextLanguage(@Nullable String preferredTextLanguage)
Sets the preferred language for text tracks.- Parameters:
preferredTextLanguage
- Preferred text language as an IETF BCP 47 conformant tag, ornull
to select the default track if there is one, or no track otherwise.- Returns:
- This builder.
-
setPreferredTextLanguages
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setPreferredTextLanguages(String... preferredTextLanguages)
Sets the preferred languages for text tracks.- Parameters:
preferredTextLanguages
- Preferred text languages as IETF BCP 47 conformant tags in order of preference, or an empty array to select the default track if there is one, or no track otherwise.- Returns:
- This builder.
-
setPreferredTextRoleFlags
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setPreferredTextRoleFlags(@RoleFlags @com.google.android.exoplayer2.C.RoleFlags int preferredTextRoleFlags)
Sets the preferredC.RoleFlags
for text tracks.- Parameters:
preferredTextRoleFlags
- Preferred text role flags.- Returns:
- This builder.
-
setIgnoredTextSelectionFlags
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setIgnoredTextSelectionFlags(@SelectionFlags @com.google.android.exoplayer2.C.SelectionFlags int ignoredTextSelectionFlags)
Sets a bitmask of selection flags that are ignored for text track selections.- Parameters:
ignoredTextSelectionFlags
- A bitmask ofC.SelectionFlags
that are ignored for text track selections.- Returns:
- This builder.
-
setSelectUndeterminedTextLanguage
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setSelectUndeterminedTextLanguage(boolean selectUndeterminedTextLanguage)
Sets whether a text track with undetermined language should be selected if no track witha preferred language
is available, or if the preferred language is unset.- Parameters:
selectUndeterminedTextLanguage
- Whether a text track with undetermined language should be selected if no preferred language track is available.- Returns:
- This builder.
-
setForceLowestBitrate
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setForceLowestBitrate(boolean forceLowestBitrate)
Sets whether to force selection of the single lowest bitrate audio and video tracks that comply with all other constraints.- Parameters:
forceLowestBitrate
- Whether to force selection of the single lowest bitrate audio and video tracks.- Returns:
- This builder.
-
setForceHighestSupportedBitrate
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setForceHighestSupportedBitrate(boolean forceHighestSupportedBitrate)
Sets whether to force selection of the highest bitrate audio and video tracks that comply with all other constraints.- Parameters:
forceHighestSupportedBitrate
- Whether to force selection of the highest bitrate audio and video tracks.- Returns:
- This builder.
-
addOverride
@CanIgnoreReturnValue public TrackSelectionParameters.Builder addOverride(TrackSelectionOverride override)
Adds an override, replacing any override for the sameTrackGroup
.
-
setOverrideForType
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setOverrideForType(TrackSelectionOverride override)
Sets an override, replacing all existing overrides with the same track type.
-
clearOverride
@CanIgnoreReturnValue public TrackSelectionParameters.Builder clearOverride(TrackGroup mediaTrackGroup)
Removes the override for the provided mediaTrackGroup
, if there is one.
-
clearOverridesOfType
@CanIgnoreReturnValue public TrackSelectionParameters.Builder clearOverridesOfType(@com.google.android.exoplayer2.C.TrackType int trackType)
Removes all overrides of the provided track type.
-
clearOverrides
@CanIgnoreReturnValue public TrackSelectionParameters.Builder clearOverrides()
Removes all overrides.
-
setDisabledTrackTypes
@CanIgnoreReturnValue @Deprecated public TrackSelectionParameters.Builder setDisabledTrackTypes(Set<@TrackType Integer> disabledTrackTypes)
Deprecated.Sets the disabled track types, preventing all tracks of those types from being selected for playback. Any previously disabled track types are cleared.- Parameters:
disabledTrackTypes
- The track types to disable.- Returns:
- This builder.
-
setTrackTypeDisabled
@CanIgnoreReturnValue public TrackSelectionParameters.Builder setTrackTypeDisabled(@com.google.android.exoplayer2.C.TrackType int trackType, boolean disabled)
Sets whether a track type is disabled. If disabled, no tracks of the specified type will be selected for playback.- Parameters:
trackType
- The track type.disabled
- Whether the track type should be disabled.- Returns:
- This builder.
-
build
public TrackSelectionParameters build()
Builds aTrackSelectionParameters
instance with the selected values.
-
-