public final class

DataSpec.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.media3.datasource.DataSpec.Builder

Overview

Builds DataSpec instances.

Use DataSpec#buildUpon() to obtain a builder representing an existing DataSpec.

Summary

Constructors
publicBuilder()

Creates a new instance with default values.

Methods
public DataSpecbuild()

Builds a DataSpec with the builder's current values.

public DataSpec.BuildersetCustomData(java.lang.Object customData)

Sets the DataSpec.customData.

public DataSpec.BuildersetFlags(int flags)

Sets the DataSpec.flags.

public DataSpec.BuildersetHttpBody(byte[] httpBody[])

Sets DataSpec.httpBody.

public DataSpec.BuildersetHttpMethod(int httpMethod)

Sets DataSpec.httpMethod.

public DataSpec.BuildersetHttpRequestHeaders(java.util.Map<java.lang.String, java.lang.String> httpRequestHeaders)

Sets the DataSpec.httpRequestHeaders.

public DataSpec.BuildersetKey(java.lang.String key)

Sets the DataSpec.key.

public DataSpec.BuildersetLength(long length)

Sets the DataSpec.length.

public DataSpec.BuildersetPosition(long position)

Sets the DataSpec.position.

public DataSpec.BuildersetUri(java.lang.String uriString)

Sets DataSpec.uri.

public DataSpec.BuildersetUri(Uri uri)

Sets DataSpec.uri.

public DataSpec.BuildersetUriPositionOffset(long uriPositionOffset)

Sets the DataSpec.uriPositionOffset.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Creates a new instance with default values.

Methods

public DataSpec.Builder setUri(java.lang.String uriString)

Sets DataSpec.uri.

Parameters:

uriString: The DataSpec.uri.

Returns:

The builder.

public DataSpec.Builder setUri(Uri uri)

Sets DataSpec.uri.

Parameters:

uri: The DataSpec.uri.

Returns:

The builder.

public DataSpec.Builder setUriPositionOffset(long uriPositionOffset)

Sets the DataSpec.uriPositionOffset. The default value is 0.

Parameters:

uriPositionOffset: The DataSpec.uriPositionOffset.

Returns:

The builder.

public DataSpec.Builder setHttpMethod(int httpMethod)

Sets DataSpec.httpMethod. The default value is DataSpec.HTTP_METHOD_GET.

Parameters:

httpMethod: The DataSpec.httpMethod.

Returns:

The builder.

public DataSpec.Builder setHttpBody(byte[] httpBody[])

Sets DataSpec.httpBody. The default value is null.

Parameters:

httpBody: The DataSpec.httpBody.

Returns:

The builder.

public DataSpec.Builder setHttpRequestHeaders(java.util.Map<java.lang.String, java.lang.String> 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.

public DataSpec.Builder setPosition(long position)

Sets the DataSpec.position. The default value is 0.

Parameters:

position: The DataSpec.position.

Returns:

The builder.

public DataSpec.Builder setLength(long length)

Sets the DataSpec.length. The default value is C.LENGTH_UNSET.

Parameters:

length: The DataSpec.length.

Returns:

The builder.

public DataSpec.Builder setKey(java.lang.String key)

Sets the DataSpec.key. The default value is null.

Parameters:

key: The DataSpec.key.

Returns:

The builder.

public DataSpec.Builder setFlags(int flags)

Sets the DataSpec.flags. The default value is 0.

Parameters:

flags: The DataSpec.flags.

Returns:

The builder.

public DataSpec.Builder setCustomData(java.lang.Object customData)

Sets the DataSpec.customData. The default value is null.

Parameters:

customData: The DataSpec.customData.

Returns:

The builder.

public DataSpec build()

Builds a DataSpec with the builder's current values.

Returns:

The build DataSpec.