docs/doc/reference/com/google/android/exoplayer2/upstream/DataSpec.Builder.html
Package com.google.android.exoplayer2.upstream
Enclosing class:DataSpec
public static final classDataSpec.Builderextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")
Builds DataSpec instances.
Use DataSpec#buildUpon() to obtain a builder representing an existing DataSpec.
Constructors | Constructor | Description |
| --- | --- |
| Builder() |
Creates a new instance with default values.
|
All Methods Instance Methods Concrete Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| DataSpec | build() |
Builds a DataSpec with the builder's current values.
|
| DataSpec.Builder | setCustomData(Object customData) |
Sets the DataSpec.customData.
|
| DataSpec.Builder | setFlags(@com.google.android.exoplayer2.upstream.DataSpec.Flags int flags) |
Sets the DataSpec.flags.
|
| DataSpec.Builder | setHttpBody(byte[] httpBody) |
Sets DataSpec.httpBody.
|
| DataSpec.Builder | setHttpMethod(@com.google.android.exoplayer2.upstream.DataSpec.HttpMethod int httpMethod) |
Sets DataSpec.httpMethod.
|
| DataSpec.Builder | setHttpRequestHeaders(Map<String,String> httpRequestHeaders) |
Sets the DataSpec.httpRequestHeaders.
|
| DataSpec.Builder | setKey(String key) |
Sets the DataSpec.key.
|
| DataSpec.Builder | setLength(long length) |
Sets the DataSpec.length.
|
| DataSpec.Builder | setPosition(long position) |
Sets the DataSpec.position.
|
| DataSpec.Builder | setUri(Uri uri) |
Sets DataSpec.uri.
|
| DataSpec.Builder | setUri(String uriString) |
Sets DataSpec.uri.
|
| DataSpec.Builder | setUriPositionOffset(long uriPositionOffset) |
Sets the DataSpec.uriPositionOffset.
|
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
public Builder()
Creates a new instance with default values.
-
@CanIgnoreReturnValue
public[DataSpec.Builder](DataSpec.Builder.html "class in com.google.android.exoplayer2.upstream")setUri([String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")uriString)
Sets DataSpec.uri.
Parameters:uriString - The DataSpec.uri.Returns:The builder.
-
@CanIgnoreReturnValue
public[DataSpec.Builder](DataSpec.Builder.html "class in com.google.android.exoplayer2.upstream")setUri([Uri](https://developer.android.com/reference/android/net/Uri.html "class or interface in android.net")uri)
Sets DataSpec.uri.
Parameters:uri - The DataSpec.uri.Returns:The builder.
-
@CanIgnoreReturnValue
public[DataSpec.Builder](DataSpec.Builder.html "class in com.google.android.exoplayer2.upstream")setUriPositionOffset(long uriPositionOffset)
Sets the DataSpec.uriPositionOffset. The default value is 0.
Parameters:uriPositionOffset - The DataSpec.uriPositionOffset.Returns:The builder.
-
@CanIgnoreReturnValue
public[DataSpec.Builder](DataSpec.Builder.html "class in com.google.android.exoplayer2.upstream")setHttpMethod(@com.google.android.exoplayer2.upstream.DataSpec.HttpMethod int httpMethod)
Sets DataSpec.httpMethod. The default value is DataSpec.HTTP_METHOD_GET.
Parameters:httpMethod - The DataSpec.httpMethod.Returns:The builder.
-
@CanIgnoreReturnValue
public[DataSpec.Builder](DataSpec.Builder.html "class in com.google.android.exoplayer2.upstream")setHttpBody(@Nullable
byte[] httpBody)
Sets DataSpec.httpBody. The default value is null.
Parameters:httpBody - The DataSpec.httpBody.Returns:The builder.
-
@CanIgnoreReturnValue
public[DataSpec.Builder](DataSpec.Builder.html "class in com.google.android.exoplayer2.upstream")setHttpRequestHeaders([Map](https://developer.android.com/reference/java/util/Map.html "class or interface in java.util")<[String](https://developer.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang"),[String](https://developer.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")> httpRequestHeaders)
Sets the DataSpec.httpRequestHeaders. The default value is an empty map.
Note: Range, Accept-Encoding and User-Agent should not be set with this method, since they are set directly by HttpDataSource implementations. See DataSpec.httpRequestHeaders for more details.
Parameters:httpRequestHeaders - The DataSpec.httpRequestHeaders.Returns:The builder.
-
@CanIgnoreReturnValue
public[DataSpec.Builder](DataSpec.Builder.html "class in com.google.android.exoplayer2.upstream")setPosition(long position)
Sets the DataSpec.position. The default value is 0.
Parameters:position - The DataSpec.position.Returns:The builder.
-
@CanIgnoreReturnValue
public[DataSpec.Builder](DataSpec.Builder.html "class in com.google.android.exoplayer2.upstream")setLength(long length)
Sets the DataSpec.length. The default value is C.LENGTH_UNSET.
Parameters:length - The DataSpec.length.Returns:The builder.
-
@CanIgnoreReturnValue
public[DataSpec.Builder](DataSpec.Builder.html "class in com.google.android.exoplayer2.upstream")setKey(@Nullable[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")key)
Sets the DataSpec.key. The default value is null.
Parameters:key - The DataSpec.key.Returns:The builder.
-
@CanIgnoreReturnValue
public[DataSpec.Builder](DataSpec.Builder.html "class in com.google.android.exoplayer2.upstream")setFlags(@com.google.android.exoplayer2.upstream.DataSpec.Flags int flags)
Sets the DataSpec.flags. The default value is 0.
Parameters:flags - The DataSpec.flags.Returns:The builder.
-
@CanIgnoreReturnValue
public[DataSpec.Builder](DataSpec.Builder.html "class in com.google.android.exoplayer2.upstream")setCustomData(@Nullable[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")customData)
Sets the DataSpec.customData. The default value is null.
Parameters:customData - The DataSpec.customData.Returns:The builder.
-
public[DataSpec](DataSpec.html "class in com.google.android.exoplayer2.upstream")build()
Builds a DataSpec with the builder's current values.
Returns:The build DataSpec.Throws:IllegalStateException - If setUri(java.lang.String) has not been called.