Skip to content

Most visited

Recently visited

navigation

BufferingParams

public final class BufferingParams
extends Object implements Parcelable

java.lang.Object
   ↳ android.media.BufferingParams


Structure for source buffering management params. Used by getDefaultBufferingParams(), getBufferingParams() and setBufferingParams(BufferingParams) to control source buffering behavior.

There are two stages of source buffering in MediaPlayer: initial buffering (when MediaPlayer is being prepared) and rebuffering (when MediaPlayer is playing back source). BufferingParams includes mode and corresponding watermarks for each stage of source buffering. The watermarks could be either size based (in milliseconds), or time based (in kilobytes) or both, depending on the mode.

There are 4 buffering modes: BUFFERING_MODE_NONE, BUFFERING_MODE_TIME_ONLY, BUFFERING_MODE_SIZE_ONLY and BUFFERING_MODE_TIME_THEN_SIZE. MediaPlayer source component has default buffering modes which can be queried by calling getDefaultBufferingParams(). Users should always use those default modes or their downsized version when trying to change buffering params. For example, BUFFERING_MODE_TIME_THEN_SIZE can be downsized to BUFFERING_MODE_NONE, BUFFERING_MODE_TIME_ONLY or BUFFERING_MODE_SIZE_ONLY. But BUFFERING_MODE_TIME_ONLY can not be downsized to BUFFERING_MODE_SIZE_ONLY.

  • initial buffering stage: has one watermark which is used when MediaPlayer is being prepared. When cached data amount exceeds this watermark, MediaPlayer is prepared.
  • rebuffering stage: has two watermarks, low and high, which are used when MediaPlayer is playing back content.
    • When cached data amount exceeds high watermark, MediaPlayer will pause buffering. Buffering will resume when cache runs below some limit which could be low watermark or some intermediate value decided by the source component.
    • When cached data amount runs below low watermark, MediaPlayer will paused playback. Playback will resume when cached data amount exceeds high watermark or reaches end of stream.

Users should use BufferingParams.Builder to change BufferingParams.

Summary

Nested classes

class BufferingParams.Builder

Builder class for BufferingParams objects. 

Constants

int BUFFERING_MODE_NONE

This mode indicates that source buffering is not supported.

int BUFFERING_MODE_SIZE_ONLY

This mode indicates that only size based source buffering is supported.

int BUFFERING_MODE_TIME_ONLY

This mode indicates that only time based source buffering is supported.

int BUFFERING_MODE_TIME_THEN_SIZE

This mode indicates that both time and size based source buffering are supported, and time based calculation precedes size based.

Inherited constants

From interface android.os.Parcelable

Fields

public static final Creator<BufferingParams> CREATOR

Public methods

int describeContents()

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

int getInitialBufferingMode()

Return the initial buffering mode used when MediaPlayer is being prepared.

int getInitialBufferingWatermarkKB()

Return the size based initial buffering watermark in kilobytes.

int getInitialBufferingWatermarkMs()

Return the time based initial buffering watermark in milliseconds.

int getRebufferingMode()

Return the rebuffering mode used when MediaPlayer is playing back source.

int getRebufferingWatermarkHighKB()

Return the size based high watermark in kilobytes for rebuffering.

int getRebufferingWatermarkHighMs()

Return the time based high watermark in milliseconds for rebuffering.

int getRebufferingWatermarkLowKB()

Return the size based low watermark in kilobytes for rebuffering.

int getRebufferingWatermarkLowMs()

Return the time based low watermark in milliseconds for rebuffering.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

From class java.lang.Object
From interface android.os.Parcelable

Constants

BUFFERING_MODE_NONE

int BUFFERING_MODE_NONE

This mode indicates that source buffering is not supported.

Constant Value: 0 (0x00000000)

BUFFERING_MODE_SIZE_ONLY

int BUFFERING_MODE_SIZE_ONLY

This mode indicates that only size based source buffering is supported. This means the watermark(s) are size based.

Constant Value: 2 (0x00000002)

BUFFERING_MODE_TIME_ONLY

int BUFFERING_MODE_TIME_ONLY

This mode indicates that only time based source buffering is supported. This means the watermark(s) are time based.

Constant Value: 1 (0x00000001)

BUFFERING_MODE_TIME_THEN_SIZE

int BUFFERING_MODE_TIME_THEN_SIZE

This mode indicates that both time and size based source buffering are supported, and time based calculation precedes size based. Size based calculation will be used only when time information is not available from the source.

Constant Value: 3 (0x00000003)

Fields

Public methods

describeContents

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(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.

getInitialBufferingMode

int getInitialBufferingMode ()

Return the initial buffering mode used when MediaPlayer is being prepared.

Returns
int one of the values that can be set in setInitialBufferingMode(int)

getInitialBufferingWatermarkKB

int getInitialBufferingWatermarkKB ()

Return the size based initial buffering watermark in kilobytes. It is meaningful only when initial buffering mode obatined from getInitialBufferingMode() is size based.

Returns
int size based initial buffering watermark in kilobytes

getInitialBufferingWatermarkMs

int getInitialBufferingWatermarkMs ()

Return the time based initial buffering watermark in milliseconds. It is meaningful only when initial buffering mode obatined from getInitialBufferingMode() is time based.

Returns
int time based initial buffering watermark in milliseconds

getRebufferingMode

int getRebufferingMode ()

Return the rebuffering mode used when MediaPlayer is playing back source.

Returns
int one of the values that can be set in setRebufferingMode(int)

getRebufferingWatermarkHighKB

int getRebufferingWatermarkHighKB ()

Return the size based high watermark in kilobytes for rebuffering. It is meaningful only when rebuffering mode obatined from getRebufferingMode() is size based.

Returns
int size based high watermark for rebuffering in kilobytes

getRebufferingWatermarkHighMs

int getRebufferingWatermarkHighMs ()

Return the time based high watermark in milliseconds for rebuffering. It is meaningful only when rebuffering mode obatined from getRebufferingMode() is time based.

Returns
int time based high watermark for rebuffering in milliseconds

getRebufferingWatermarkLowKB

int getRebufferingWatermarkLowKB ()

Return the size based low watermark in kilobytes for rebuffering. It is meaningful only when rebuffering mode obatined from getRebufferingMode() is size based.

Returns
int size based low watermark for rebuffering in kilobytes

getRebufferingWatermarkLowMs

int getRebufferingWatermarkLowMs ()

Return the time based low watermark in milliseconds for rebuffering. It is meaningful only when rebuffering mode obatined from getRebufferingMode() is time based.

Returns
int time based low watermark for rebuffering in milliseconds

writeToParcel

void writeToParcel (Parcel dest, 
                int flags)

Flatten this object in to a Parcel.

Parameters
dest Parcel: The Parcel in which the object should be written.
flags int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.
This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.