Class DataSpec.Builder
- java.lang.Object
-
- com.google.android.exoplayer2.upstream.DataSpec.Builder
-
-
Constructor Summary
Constructors Constructor Description Builder()
Creates a new instance with default values.
-
Method Summary
-
-
-
Method Detail
-
setUri
@CanIgnoreReturnValue public DataSpec.Builder setUri(String uriString)
SetsDataSpec.uri
.- Parameters:
uriString
- TheDataSpec.uri
.- Returns:
- The builder.
-
setUri
@CanIgnoreReturnValue public DataSpec.Builder setUri(Uri uri)
SetsDataSpec.uri
.- Parameters:
uri
- TheDataSpec.uri
.- Returns:
- The builder.
-
setUriPositionOffset
@CanIgnoreReturnValue public DataSpec.Builder setUriPositionOffset(long uriPositionOffset)
Sets theDataSpec.uriPositionOffset
. The default value is 0.- Parameters:
uriPositionOffset
- TheDataSpec.uriPositionOffset
.- Returns:
- The builder.
-
setHttpMethod
@CanIgnoreReturnValue public DataSpec.Builder setHttpMethod(@com.google.android.exoplayer2.upstream.DataSpec.HttpMethod int httpMethod)
SetsDataSpec.httpMethod
. The default value isDataSpec.HTTP_METHOD_GET
.- Parameters:
httpMethod
- TheDataSpec.httpMethod
.- Returns:
- The builder.
-
setHttpBody
@CanIgnoreReturnValue public DataSpec.Builder setHttpBody(@Nullable byte[] httpBody)
SetsDataSpec.httpBody
. The default value isnull
.- Parameters:
httpBody
- TheDataSpec.httpBody
.- Returns:
- The builder.
-
setHttpRequestHeaders
@CanIgnoreReturnValue public DataSpec.Builder setHttpRequestHeaders(Map<String,String> httpRequestHeaders)
Sets theDataSpec.httpRequestHeaders
. The default value is an empty map.Note:
Range
,Accept-Encoding
andUser-Agent
should not be set with this method, since they are set directly byHttpDataSource
implementations. SeeDataSpec.httpRequestHeaders
for more details.- Parameters:
httpRequestHeaders
- TheDataSpec.httpRequestHeaders
.- Returns:
- The builder.
-
setPosition
@CanIgnoreReturnValue public DataSpec.Builder setPosition(long position)
Sets theDataSpec.position
. The default value is 0.- Parameters:
position
- TheDataSpec.position
.- Returns:
- The builder.
-
setLength
@CanIgnoreReturnValue public DataSpec.Builder setLength(long length)
Sets theDataSpec.length
. The default value isC.LENGTH_UNSET
.- Parameters:
length
- TheDataSpec.length
.- Returns:
- The builder.
-
setKey
@CanIgnoreReturnValue public DataSpec.Builder setKey(@Nullable String key)
Sets theDataSpec.key
. The default value isnull
.- Parameters:
key
- TheDataSpec.key
.- Returns:
- The builder.
-
setFlags
@CanIgnoreReturnValue public DataSpec.Builder setFlags(@com.google.android.exoplayer2.upstream.DataSpec.Flags int flags)
Sets theDataSpec.flags
. The default value is 0.- Parameters:
flags
- TheDataSpec.flags
.- Returns:
- The builder.
-
setCustomData
@CanIgnoreReturnValue public DataSpec.Builder setCustomData(@Nullable Object customData)
Sets theDataSpec.customData
. The default value isnull
.- Parameters:
customData
- TheDataSpec.customData
.- Returns:
- The builder.
-
build
public DataSpec build()
Builds aDataSpec
with the builder's current values.- Returns:
- The build
DataSpec
. - Throws:
IllegalStateException
- IfsetUri(java.lang.String)
has not been called.
-
-