AdRequest


public final class AdRequest
extends Object implements Parcelable

java.lang.Object
   ↳ android.media.tv.AdRequest


An advertisement request which can be sent to TV input to request AD operations.

Summary

Constants

int REQUEST_TYPE_START

Request to start an advertisement.

int REQUEST_TYPE_STOP

Request to stop an advertisement.

Inherited constants

Fields

public static final Creator<AdRequest> CREATOR

Public constructors

AdRequest(int id, int requestType, ParcelFileDescriptor fileDescriptor, long startTime, long stopTime, long echoInterval, String mediaFileType, Bundle metadata)
AdRequest(int id, int requestType, Uri uri, long startTime, long stopTime, long echoInterval, Bundle metadata)

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

long getEchoIntervalMillis()

Gets the echo interval in milliseconds.

ParcelFileDescriptor getFileDescriptor()

Gets the file descriptor of the AD media.

int getId()

Gets the ID of AD request.

String getMediaFileType()

Gets the media file type such as mp4, mob, avi.

Bundle getMetadata()

Gets the metadata of the media file.

int getRequestType()

Gets the request type.

long getStartTimeMillis()

Gets the start time of the AD media in milliseconds.

long getStopTimeMillis()

Gets the stop time of the AD media in milliseconds.

Uri getUri()

Gets the URI of the AD media.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Constants

REQUEST_TYPE_START

Added in API level 33
public static final int REQUEST_TYPE_START

Request to start an advertisement.

Constant Value: 1 (0x00000001)

REQUEST_TYPE_STOP

Added in API level 33
public static final int REQUEST_TYPE_STOP

Request to stop an advertisement.

Constant Value: 2 (0x00000002)

Fields

CREATOR

Added in API level 33
public static final Creator<AdRequest> CREATOR

Public constructors

AdRequest

Added in API level 33
public AdRequest (int id, 
                int requestType, 
                ParcelFileDescriptor fileDescriptor, 
                long startTime, 
                long stopTime, 
                long echoInterval, 
                String mediaFileType, 
                Bundle metadata)

Parameters
id int

requestType int: Value is REQUEST_TYPE_START, or REQUEST_TYPE_STOP

fileDescriptor ParcelFileDescriptor: This value may be null.

startTime long

stopTime long

echoInterval long

mediaFileType String: This value may be null.

metadata Bundle: This value cannot be null.

AdRequest

Added in API level 34
public AdRequest (int id, 
                int requestType, 
                Uri uri, 
                long startTime, 
                long stopTime, 
                long echoInterval, 
                Bundle metadata)

Parameters
id int

requestType int: Value is REQUEST_TYPE_START, or REQUEST_TYPE_STOP

uri Uri: This value may be null.

startTime long

stopTime long

echoInterval long

metadata Bundle: This value cannot be null.

Public methods

describeContents

Added in API level 33
public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

getEchoIntervalMillis

Added in API level 33
public long getEchoIntervalMillis ()

Gets the echo interval in milliseconds.

The interval TV input needs to echo and inform TV interactive app service the video playback elapsed time.

Returns
long

See also:

getFileDescriptor

Added in API level 33
public ParcelFileDescriptor getFileDescriptor ()

Gets the file descriptor of the AD media.

Returns
ParcelFileDescriptor The file descriptor of the AD media. Can be null for REQUEST_TYPE_STOP or a URI is used.

getId

Added in API level 33
public int getId ()

Gets the ID of AD request.

Returns
int

getMediaFileType

Added in API level 33
public String getMediaFileType ()

Gets the media file type such as mp4, mob, avi.

Returns
String The media file type. Can be null for REQUEST_TYPE_STOP.

getMetadata

Added in API level 33
public Bundle getMetadata ()

Gets the metadata of the media file.

This includes additional information the TV input needs to play the AD media. This may include fields in MediaFormat like MediaFormat.KEY_SAMPLE_RATE, or integrity information like SHA. What data is included depends on the format of the media file.

Returns
Bundle The metadata of the media file. Can be an empty bundle for REQUEST_TYPE_STOP. This value cannot be null.

getRequestType

Added in API level 33
public int getRequestType ()

Gets the request type.

Returns
int Value is REQUEST_TYPE_START, or REQUEST_TYPE_STOP

getStartTimeMillis

Added in API level 33
public long getStartTimeMillis ()

Gets the start time of the AD media in milliseconds.

0 means start immediately

Returns
long

getStopTimeMillis

Added in API level 33
public long getStopTimeMillis ()

Gets the stop time of the AD media in milliseconds.

-1 means until the end

Returns
long

getUri

Added in API level 34
public Uri getUri ()

Gets the URI of the AD media.

Returns
Uri The URI of the AD media. Can be null for REQUEST_TYPE_STOP or a file descriptor is used.

writeToParcel

Added in API level 33
public void writeToParcel (Parcel dest, 
                int flags)

Flatten this object in to a Parcel.

Parameters
dest Parcel: This value cannot be null.

flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES