Stay organized with collections Save and categorize content based on your preferences.

PlaybackStats

@UnstableApi
public final class PlaybackStats


Statistics about playbacks.

Summary

Nested types

public final class PlaybackStats.EventTimeAndException

Stores an exception with the event time at which it occurred.

public final class PlaybackStats.EventTimeAndFormat

Stores a format with the event time at which it started being used, or null to indicate that no format was used.

public final class PlaybackStats.EventTimeAndPlaybackState

Stores a playback state with the event time at which it became active.

Constants

static final PlaybackStats

Empty playback stats.

static final int

Playback is abandoned before reaching the end of the media.

static final int

Playback is buffering to resume active playback.

static final int

Playback has reached the end of the media.

static final int

Playback is stopped due a fatal error and can be retried.

static final int

Playback is interrupted by an ad.

static final int

Playback is buffering in the background for initial playback start.

static final int

Playback is buffering in the foreground for initial playback start.

static final int

Playback has not started (initial state).

static final int

Playback is paused but ready to play.

static final int

Playback is buffering while paused.

static final int

Playback is actively playing.

static final int

Playback is handling a seek.

static final int

Playback is stopped and can be restarted.

static final int

Playback is suppressed (e.g. due to audio focus loss).

static final int

Playback is suppressed (e.g. due to audio focus loss) while buffering to resume a playback.

Public fields

final int

The number of playbacks which were abandoned before they were ready to play.

final int

The number of ad playbacks.

final List<PlaybackStats.EventTimeAndFormat>

The audio format history as EventTimeAndFormats ordered by EventTime.realTimeMs.

final int

The number of playbacks which were pre-buffered in the background.

final int

The number of playbacks which reached the ended state at least once.

final int

The total number of fatal errors.

final List<PlaybackStats.EventTimeAndException>

The history of fatal errors as EventTimeAndExceptions ordered by EventTime.realTimeMs.

final int

The total number of playback with at least one fatal error.

final long

The elapsed real-time as returned by SystemClock.elapsedRealtime() of the first reported playback event, or TIME_UNSET if no event has been reported.

final int

The number of playbacks which were the active foreground playback at some point.

final int

The number of playbacks with initial audio format bitrate data.

final int

The number of playbacks with initial video format bitrate data.

final int

The number of playbacks with initial video format height data.

final long

The maximum time spent during a single rebuffer, in milliseconds, or TIME_UNSET if no rebuffer occurred.

final List<long[]>

The media time history as an ordered list of long[2] arrays with [0] being the realtime as returned by SystemClock.elapsedRealtime() and [1] being the media time at this realtime, in milliseconds.

final int

The total number of non-fatal errors.

final List<PlaybackStats.EventTimeAndException>

The history of non-fatal errors as EventTimeAndExceptions ordered by EventTime.realTimeMs.

final int

The number of individual playbacks for which these stats were collected.

final List<PlaybackStats.EventTimeAndPlaybackState>

The playback state history as EventTimeAndPlaybackStates ordered by EventTime.realTimeMs.

final long

The accumulated sum of all audio format bitrates, in bits per second, times the time the format was used for playback, in milliseconds.

final long

The total media time for which audio format data is available, in milliseconds.

final long

The total number of audio underruns.

final long

The total bytes transferred during totalBandwidthTimeMs.

final long

The total time for which bandwidth measurement data is available, in milliseconds.

final long

The total number of dropped video frames.

final long

The total initial audio format bitrate for all playbacks, in bits per second, or LENGTH_UNSET if no initial audio format data is available.

final long

The total initial video format bitrate for all playbacks, in bits per second, or LENGTH_UNSET if no initial video format data is available.

final int

The total initial video format height for all playbacks, in pixels, or LENGTH_UNSET if no initial video format data is available.

final int

The total number of times a playback has been paused while rebuffering.

final int

The total number of times a playback has been paused.

final int

The total number of times a rebuffer occurred.

final int

The total number of times a seek occurred.

final long

The total time spent joining the playback, in milliseconds, or TIME_UNSET if no valid join time could be determined.

final long

The total media time for which video format bitrate data is available, in milliseconds.

final long

The accumulated sum of all video format bitrates, in bits per second, times the time the format was used for playback, in milliseconds.

final long

The total media time for which video format height data is available, in milliseconds.

final long

The accumulated sum of all video format heights, in pixels, times the time the format was used for playback, in milliseconds.

final int

The number of playbacks with a valid join time as documented in totalValidJoinTimeMs.

final List<PlaybackStats.EventTimeAndFormat>

The video format history as EventTimeAndFormats ordered by EventTime.realTimeMs.

Public constructors

Public methods

float

Returns the ratio of foreground playbacks which were abandoned before they were ready to play, or 0.0 if no playback has been in foreground.

float

Returns the mean rate at which audio underruns occurred, in underruns per play time second, or 0.0 if no time was spent playing.

float

Returns the mean rate at which video frames are dropped, in dropped frames per play time second, or 0.0 if no time was spent playing.

float

Returns the ratio of foreground playbacks which reached the ended state at least once, or 0.0 if no playback has been in foreground.

float

Returns the rate of fatal errors, in errors per play time second, or 0.0 if no time was spend playing.

float

Returns the ratio of foreground playbacks which experienced fatal errors, or 0.0 if no playback has been in foreground.

float

Returns the ratio of foreground join time to the total time spent playing and waiting, or 0.0 if no time was spend playing or waiting.

int

Returns the mean audio format bitrate, in bits per second, or LENGTH_UNSET if no audio format data is available.

int

Returns the mean network bandwidth based on transfer measurements, in bits per second, or LENGTH_UNSET if no transfer data is available.

long

Returns the mean time covered by any playback state per playback, in milliseconds, or TIME_UNSET if no playback was recorded.

int

Returns the mean initial audio format bitrate, in bits per second, or LENGTH_UNSET if no audio format data is available.

int

Returns the mean initial video format bitrate, in bits per second, or LENGTH_UNSET if no video format data is available.

int

Returns the mean initial video format height, in pixels, or LENGTH_UNSET if no video format data is available.

long

Returns the mean time spent joining the playback, in milliseconds, or TIME_UNSET if no valid join time is available.

float

Returns the mean number of non-fatal errors per foreground playback, or 0.0 if no playback has been in foreground.

float

Returns the mean number of times a playback has been paused while rebuffering per foreground playback, or 0.0 if no playback has been in foreground.

float

Returns the mean number of times a playback has been paused per foreground playback, or 0.0 if no playback has been in foreground.

long

Returns the mean time spent in a paused state per foreground playback, in milliseconds, or TIME_UNSET if no playback has been in foreground.

long

Returns the mean time spent playing or actively waiting for playback per foreground playback, in milliseconds, or TIME_UNSET if no playback has been in foreground.

long

Returns the mean time spent actively playing per foreground playback, in milliseconds, or TIME_UNSET if no playback has been in foreground.

float

Returns the mean number of times a rebuffer occurred per foreground playback, or 0.0 if no playback has been in foreground.

long

Returns the mean time spent rebuffering per foreground playback, in milliseconds, or TIME_UNSET if no playback has been in foreground.

float

Returns the mean number of times a seek occurred per foreground playback, or 0.0 if no playback has been in foreground.

long

Returns the mean time spent per foreground playback from the start of a seek until playback is ready again, in milliseconds, or TIME_UNSET if no playback has been in foreground.

long

Returns the mean time spent during a single rebuffer, in milliseconds, or TIME_UNSET if no rebuffer was recorded.

long

Returns the mean time spent from the start of a single seek until playback is ready again, in milliseconds, or TIME_UNSET if no seek occurred.

float

Returns the mean play time between fatal errors, in seconds.

float

Returns the mean play time between non-fatal errors, in seconds.

float

Returns the mean play time between rebuffer events, in seconds.

int

Returns the mean video format bitrate, in bits per second, or LENGTH_UNSET if no video format data is available.

int

Returns the mean video format height, in pixels, or LENGTH_UNSET if no video format data is available.

long

Returns the mean time spent actively waiting for playback per foreground playback, in milliseconds, or TIME_UNSET if no playback has been in foreground.

long
getMediaTimeMsAtRealtimeMs(long realtimeMs)

Returns the estimated media time at the given realtime, in milliseconds, or TIME_UNSET if the media time history is unknown.

float

Returns the rate of non-fatal errors, in errors per play time second, or 0.0 if no time was spend playing.

int

Returns the PlaybackState at the given time.

long

Returns the total time spent in a given PlaybackState, in milliseconds.

float

Returns the rate of rebuffer events, in rebuffers per play time second, or 0.0 if no time was spend playing.

float

Returns the ratio of rebuffer time to the total time spent playing and waiting, or 0.0 if no time was spend playing or waiting.

float

Returns the ratio of seek time to the total time spent playing and waiting, or 0.0 if no time was spend playing or waiting.

long

Returns the total time covered by any playback state, in milliseconds.

long

Returns the total time spent joining the playback in foreground, in milliseconds.

long

Returns the total time spent in a paused state, in milliseconds.

long

Returns the total time spent playing or actively waiting for playback, in milliseconds.

long

Returns the total time spent actively playing, in milliseconds.

long

Returns the total time spent rebuffering, in milliseconds.

long

Returns the total time spent from the start of a seek until playback is ready again, in milliseconds.

long

Returns the total time spent actively waiting for playback, in milliseconds.

float

Returns the ratio of wait times to the total time spent playing and waiting, or 0.0 if no time was spend playing or waiting.

static PlaybackStats
merge(PlaybackStats[] playbackStats)

Returns the combined PlaybackStats for all input PlaybackStats.

Constants

EMPTY

public static final PlaybackStats EMPTY

Empty playback stats.

PLAYBACK_STATE_ABANDONED

public static final int PLAYBACK_STATE_ABANDONED = 15

Playback is abandoned before reaching the end of the media.

PLAYBACK_STATE_BUFFERING

public static final int PLAYBACK_STATE_BUFFERING = 6

Playback is buffering to resume active playback.

PLAYBACK_STATE_ENDED

public static final int PLAYBACK_STATE_ENDED = 11

Playback has reached the end of the media.

PLAYBACK_STATE_FAILED

public static final int PLAYBACK_STATE_FAILED = 13

Playback is stopped due a fatal error and can be retried.

PLAYBACK_STATE_INTERRUPTED_BY_AD

public static final int PLAYBACK_STATE_INTERRUPTED_BY_AD = 14

Playback is interrupted by an ad.

PLAYBACK_STATE_JOINING_BACKGROUND

public static final int PLAYBACK_STATE_JOINING_BACKGROUND = 1

Playback is buffering in the background for initial playback start.

PLAYBACK_STATE_JOINING_FOREGROUND

public static final int PLAYBACK_STATE_JOINING_FOREGROUND = 2

Playback is buffering in the foreground for initial playback start.

PLAYBACK_STATE_NOT_STARTED

public static final int PLAYBACK_STATE_NOT_STARTED = 0

Playback has not started (initial state).

PLAYBACK_STATE_PAUSED

public static final int PLAYBACK_STATE_PAUSED = 4

Playback is paused but ready to play.

PLAYBACK_STATE_PAUSED_BUFFERING

public static final int PLAYBACK_STATE_PAUSED_BUFFERING = 7

Playback is buffering while paused.

PLAYBACK_STATE_PLAYING

public static final int PLAYBACK_STATE_PLAYING = 3

Playback is actively playing.

PLAYBACK_STATE_SEEKING

public static final int PLAYBACK_STATE_SEEKING = 5

Playback is handling a seek.

PLAYBACK_STATE_STOPPED

public static final int PLAYBACK_STATE_STOPPED = 12

Playback is stopped and can be restarted.

PLAYBACK_STATE_SUPPRESSED

public static final int PLAYBACK_STATE_SUPPRESSED = 9

Playback is suppressed (e.g. due to audio focus loss).

PLAYBACK_STATE_SUPPRESSED_BUFFERING

public static final int PLAYBACK_STATE_SUPPRESSED_BUFFERING = 10

Playback is suppressed (e.g. due to audio focus loss) while buffering to resume a playback.

Public fields

abandonedBeforeReadyCount

public final int abandonedBeforeReadyCount

The number of playbacks which were abandoned before they were ready to play.

adPlaybackCount

public final int adPlaybackCount

The number of ad playbacks.

audioFormatHistory

public final List<PlaybackStats.EventTimeAndFormataudioFormatHistory

The audio format history as EventTimeAndFormats ordered by EventTime.realTimeMs. The Format may be null if no audio format was used.

backgroundJoiningCount

public final int backgroundJoiningCount

The number of playbacks which were pre-buffered in the background.

endedCount

public final int endedCount

The number of playbacks which reached the ended state at least once.

fatalErrorCount

public final int fatalErrorCount

The total number of fatal errors. Errors are fatal if playback stopped due to this error.

fatalErrorHistory

public final List<PlaybackStats.EventTimeAndExceptionfatalErrorHistory

The history of fatal errors as EventTimeAndExceptions ordered by EventTime.realTimeMs. Errors are fatal if playback stopped due to this error.

fatalErrorPlaybackCount

public final int fatalErrorPlaybackCount

The total number of playback with at least one fatal error. Errors are fatal if playback stopped due to this error.

firstReportedTimeMs

public final long firstReportedTimeMs

The elapsed real-time as returned by SystemClock.elapsedRealtime() of the first reported playback event, or TIME_UNSET if no event has been reported.

foregroundPlaybackCount

public final int foregroundPlaybackCount

The number of playbacks which were the active foreground playback at some point.

initialAudioFormatBitrateCount

public final int initialAudioFormatBitrateCount

The number of playbacks with initial audio format bitrate data.

initialVideoFormatBitrateCount

public final int initialVideoFormatBitrateCount

The number of playbacks with initial video format bitrate data.

initialVideoFormatHeightCount

public final int initialVideoFormatHeightCount

The number of playbacks with initial video format height data.

maxRebufferTimeMs

public final long maxRebufferTimeMs

The maximum time spent during a single rebuffer, in milliseconds, or TIME_UNSET if no rebuffer occurred.

mediaTimeHistory

public final List<long[]> mediaTimeHistory

The media time history as an ordered list of long[2] arrays with [0] being the realtime as returned by SystemClock.elapsedRealtime() and [1] being the media time at this realtime, in milliseconds.

nonFatalErrorCount

public final int nonFatalErrorCount

The total number of non-fatal errors. Error are non-fatal if playback can recover from the error without stopping.

nonFatalErrorHistory

public final List<PlaybackStats.EventTimeAndExceptionnonFatalErrorHistory

The history of non-fatal errors as EventTimeAndExceptions ordered by EventTime.realTimeMs. Errors are non-fatal if playback can recover from the error without stopping.

playbackCount

public final int playbackCount

The number of individual playbacks for which these stats were collected.

playbackStateHistory

public final List<PlaybackStats.EventTimeAndPlaybackStateplaybackStateHistory

The playback state history as EventTimeAndPlaybackStates ordered by EventTime.realTimeMs.

totalAudioFormatBitrateTimeProduct

public final long totalAudioFormatBitrateTimeProduct

The accumulated sum of all audio format bitrates, in bits per second, times the time the format was used for playback, in milliseconds.

totalAudioFormatTimeMs

public final long totalAudioFormatTimeMs

The total media time for which audio format data is available, in milliseconds.

totalAudioUnderruns

public final long totalAudioUnderruns

The total number of audio underruns.

totalBandwidthBytes

public final long totalBandwidthBytes

The total bytes transferred during totalBandwidthTimeMs.

totalBandwidthTimeMs

public final long totalBandwidthTimeMs

The total time for which bandwidth measurement data is available, in milliseconds.

totalDroppedFrames

public final long totalDroppedFrames

The total number of dropped video frames.

totalInitialAudioFormatBitrate

public final long totalInitialAudioFormatBitrate

The total initial audio format bitrate for all playbacks, in bits per second, or LENGTH_UNSET if no initial audio format data is available.

totalInitialVideoFormatBitrate

public final long totalInitialVideoFormatBitrate

The total initial video format bitrate for all playbacks, in bits per second, or LENGTH_UNSET if no initial video format data is available.

totalInitialVideoFormatHeight

public final int totalInitialVideoFormatHeight

The total initial video format height for all playbacks, in pixels, or LENGTH_UNSET if no initial video format data is available.

totalPauseBufferCount

public final int totalPauseBufferCount

The total number of times a playback has been paused while rebuffering.

totalPauseCount

public final int totalPauseCount

The total number of times a playback has been paused.

totalRebufferCount

public final int totalRebufferCount

The total number of times a rebuffer occurred. This excludes initial joining and buffering after seek.

totalSeekCount

public final int totalSeekCount

The total number of times a seek occurred. This includes seeks happening before playback resumed after another seek.

totalValidJoinTimeMs

public final long totalValidJoinTimeMs

The total time spent joining the playback, in milliseconds, or TIME_UNSET if no valid join time could be determined.

Note that this does not include background joining time. A join time may be invalid if the playback never reached PLAYBACK_STATE_PLAYING or PLAYBACK_STATE_PAUSED, or joining was interrupted by a seek, stop, or error state.

totalVideoFormatBitrateTimeMs

public final long totalVideoFormatBitrateTimeMs

The total media time for which video format bitrate data is available, in milliseconds.

totalVideoFormatBitrateTimeProduct

public final long totalVideoFormatBitrateTimeProduct

The accumulated sum of all video format bitrates, in bits per second, times the time the format was used for playback, in milliseconds.

totalVideoFormatHeightTimeMs

public final long totalVideoFormatHeightTimeMs

The total media time for which video format height data is available, in milliseconds.

totalVideoFormatHeightTimeProduct

public final long totalVideoFormatHeightTimeProduct

The accumulated sum of all video format heights, in pixels, times the time the format was used for playback, in milliseconds.

validJoinTimeCount

public final int validJoinTimeCount

The number of playbacks with a valid join time as documented in totalValidJoinTimeMs.

videoFormatHistory

public final List<PlaybackStats.EventTimeAndFormatvideoFormatHistory

The video format history as EventTimeAndFormats ordered by EventTime.realTimeMs. The Format may be null if no video format was used.

Public constructors

PlaybackStats

public PlaybackStats()

Public methods

getAbandonedBeforeReadyRatio

public float getAbandonedBeforeReadyRatio()

Returns the ratio of foreground playbacks which were abandoned before they were ready to play, or 0.0 if no playback has been in foreground.

getAudioUnderrunRate

public float getAudioUnderrunRate()

Returns the mean rate at which audio underruns occurred, in underruns per play time second, or 0.0 if no time was spent playing.

getDroppedFramesRate

public float getDroppedFramesRate()

Returns the mean rate at which video frames are dropped, in dropped frames per play time second, or 0.0 if no time was spent playing.

getEndedRatio

public float getEndedRatio()

Returns the ratio of foreground playbacks which reached the ended state at least once, or 0.0 if no playback has been in foreground.

getFatalErrorRate

public float getFatalErrorRate()

Returns the rate of fatal errors, in errors per play time second, or 0.0 if no time was spend playing. This is equivalent to 1.0 / getMeanTimeBetweenFatalErrors.

getFatalErrorRatio

public float getFatalErrorRatio()

Returns the ratio of foreground playbacks which experienced fatal errors, or 0.0 if no playback has been in foreground.

getJoinTimeRatio

public float getJoinTimeRatio()

Returns the ratio of foreground join time to the total time spent playing and waiting, or 0.0 if no time was spend playing or waiting. This is equivalent to getTotalJoinTimeMs / getTotalPlayAndWaitTimeMs.

getMeanAudioFormatBitrate

public int getMeanAudioFormatBitrate()

Returns the mean audio format bitrate, in bits per second, or LENGTH_UNSET if no audio format data is available. This is a weighted average taking the time the format was used for playback into account.

getMeanBandwidth

public int getMeanBandwidth()

Returns the mean network bandwidth based on transfer measurements, in bits per second, or LENGTH_UNSET if no transfer data is available.

getMeanElapsedTimeMs

public long getMeanElapsedTimeMs()

Returns the mean time covered by any playback state per playback, in milliseconds, or TIME_UNSET if no playback was recorded.

getMeanInitialAudioFormatBitrate

public int getMeanInitialAudioFormatBitrate()

Returns the mean initial audio format bitrate, in bits per second, or LENGTH_UNSET if no audio format data is available.

getMeanInitialVideoFormatBitrate

public int getMeanInitialVideoFormatBitrate()

Returns the mean initial video format bitrate, in bits per second, or LENGTH_UNSET if no video format data is available.

getMeanInitialVideoFormatHeight

public int getMeanInitialVideoFormatHeight()

Returns the mean initial video format height, in pixels, or LENGTH_UNSET if no video format data is available.

getMeanJoinTimeMs

public long getMeanJoinTimeMs()

Returns the mean time spent joining the playback, in milliseconds, or TIME_UNSET if no valid join time is available. Only includes playbacks with valid join times as documented in totalValidJoinTimeMs.

getMeanNonFatalErrorCount

public float getMeanNonFatalErrorCount()

Returns the mean number of non-fatal errors per foreground playback, or 0.0 if no playback has been in foreground.

getMeanPauseBufferCount

public float getMeanPauseBufferCount()

Returns the mean number of times a playback has been paused while rebuffering per foreground playback, or 0.0 if no playback has been in foreground.

getMeanPauseCount

public float getMeanPauseCount()

Returns the mean number of times a playback has been paused per foreground playback, or 0.0 if no playback has been in foreground.

getMeanPausedTimeMs

public long getMeanPausedTimeMs()

Returns the mean time spent in a paused state per foreground playback, in milliseconds, or TIME_UNSET if no playback has been in foreground.

getMeanPlayAndWaitTimeMs

public long getMeanPlayAndWaitTimeMs()

Returns the mean time spent playing or actively waiting for playback per foreground playback, in milliseconds, or TIME_UNSET if no playback has been in foreground.

getMeanPlayTimeMs

public long getMeanPlayTimeMs()

Returns the mean time spent actively playing per foreground playback, in milliseconds, or TIME_UNSET if no playback has been in foreground.

getMeanRebufferCount

public float getMeanRebufferCount()

Returns the mean number of times a rebuffer occurred per foreground playback, or 0.0 if no playback has been in foreground. This excludes initial joining and buffering after seek.

getMeanRebufferTimeMs

public long getMeanRebufferTimeMs()

Returns the mean time spent rebuffering per foreground playback, in milliseconds, or TIME_UNSET if no playback has been in foreground. This excludes initial join times, buffer times after a seek and buffering while paused.

getMeanSeekCount

public float getMeanSeekCount()

Returns the mean number of times a seek occurred per foreground playback, or 0.0 if no playback has been in foreground. This includes seeks happening before playback resumed after another seek.

getMeanSeekTimeMs

public long getMeanSeekTimeMs()

Returns the mean time spent per foreground playback from the start of a seek until playback is ready again, in milliseconds, or TIME_UNSET if no playback has been in foreground.

getMeanSingleRebufferTimeMs

public long getMeanSingleRebufferTimeMs()

Returns the mean time spent during a single rebuffer, in milliseconds, or TIME_UNSET if no rebuffer was recorded. This excludes initial join times and buffer times after a seek.

getMeanSingleSeekTimeMs

public long getMeanSingleSeekTimeMs()

Returns the mean time spent from the start of a single seek until playback is ready again, in milliseconds, or TIME_UNSET if no seek occurred.

getMeanTimeBetweenFatalErrors

public float getMeanTimeBetweenFatalErrors()

Returns the mean play time between fatal errors, in seconds. This is equivalent to 1.0 / getFatalErrorRate. Note that this may return POSITIVE_INFINITY.

getMeanTimeBetweenNonFatalErrors

public float getMeanTimeBetweenNonFatalErrors()

Returns the mean play time between non-fatal errors, in seconds. This is equivalent to 1.0 / getNonFatalErrorRate. Note that this may return POSITIVE_INFINITY.

getMeanTimeBetweenRebuffers

public float getMeanTimeBetweenRebuffers()

Returns the mean play time between rebuffer events, in seconds. This is equivalent to 1.0 / getRebufferRate. Note that this may return POSITIVE_INFINITY.

getMeanVideoFormatBitrate

public int getMeanVideoFormatBitrate()

Returns the mean video format bitrate, in bits per second, or LENGTH_UNSET if no video format data is available. This is a weighted average taking the time the format was used for playback into account.

getMeanVideoFormatHeight

public int getMeanVideoFormatHeight()

Returns the mean video format height, in pixels, or LENGTH_UNSET if no video format data is available. This is a weighted average taking the time the format was used for playback into account.

getMeanWaitTimeMs

public long getMeanWaitTimeMs()

Returns the mean time spent actively waiting for playback per foreground playback, in milliseconds, or TIME_UNSET if no playback has been in foreground. This includes all join times, rebuffer times and seek times, but excludes times without user intention to play, e.g. all paused states.

getMediaTimeMsAtRealtimeMs

public long getMediaTimeMsAtRealtimeMs(long realtimeMs)

Returns the estimated media time at the given realtime, in milliseconds, or TIME_UNSET if the media time history is unknown.

Parameters
long realtimeMs

The realtime as returned by elapsedRealtime.

Returns
long

The estimated media time in milliseconds at this realtime, TIME_UNSET if no estimate can be given.

getNonFatalErrorRate

public float getNonFatalErrorRate()

Returns the rate of non-fatal errors, in errors per play time second, or 0.0 if no time was spend playing. This is equivalent to 1.0 / getMeanTimeBetweenNonFatalErrors.

getPlaybackStateAtTime

@PlaybackStats.PlaybackState
public int getPlaybackStateAtTime(long realtimeMs)

Returns the PlaybackState at the given time.

Parameters
long realtimeMs

The time as returned by elapsedRealtime.

Returns
int

The PlaybackState at that time, or PLAYBACK_STATE_NOT_STARTED if the given time is before the first known playback state in the history.

getPlaybackStateDurationMs

public long getPlaybackStateDurationMs(
    @PlaybackStats.PlaybackState int playbackState
)

Returns the total time spent in a given PlaybackState, in milliseconds.

Parameters
@PlaybackStats.PlaybackState int playbackState

A PlaybackState.

Returns
long

Total spent in the given playback state, in milliseconds

getRebufferRate

public float getRebufferRate()

Returns the rate of rebuffer events, in rebuffers per play time second, or 0.0 if no time was spend playing. This is equivalent to 1.0 / getMeanTimeBetweenRebuffers.

getRebufferTimeRatio

public float getRebufferTimeRatio()

Returns the ratio of rebuffer time to the total time spent playing and waiting, or 0.0 if no time was spend playing or waiting. This is equivalent to getTotalRebufferTimeMs / getTotalPlayAndWaitTimeMs.

getSeekTimeRatio

public float getSeekTimeRatio()

Returns the ratio of seek time to the total time spent playing and waiting, or 0.0 if no time was spend playing or waiting. This is equivalent to getTotalSeekTimeMs / getTotalPlayAndWaitTimeMs.

getTotalElapsedTimeMs

public long getTotalElapsedTimeMs()

Returns the total time covered by any playback state, in milliseconds.

getTotalJoinTimeMs

public long getTotalJoinTimeMs()

Returns the total time spent joining the playback in foreground, in milliseconds. This does include invalid join times where the playback never reached PLAYBACK_STATE_PLAYING or PLAYBACK_STATE_PAUSED, or joining was interrupted by a seek, stop, or error state.

getTotalPausedTimeMs

public long getTotalPausedTimeMs()

Returns the total time spent in a paused state, in milliseconds.

getTotalPlayAndWaitTimeMs

public long getTotalPlayAndWaitTimeMs()

Returns the total time spent playing or actively waiting for playback, in milliseconds.

getTotalPlayTimeMs

public long getTotalPlayTimeMs()

Returns the total time spent actively playing, in milliseconds.

getTotalRebufferTimeMs

public long getTotalRebufferTimeMs()

Returns the total time spent rebuffering, in milliseconds. This excludes initial join times, buffer times after a seek and buffering while paused.

getTotalSeekTimeMs

public long getTotalSeekTimeMs()

Returns the total time spent from the start of a seek until playback is ready again, in milliseconds.

getTotalWaitTimeMs

public long getTotalWaitTimeMs()

Returns the total time spent actively waiting for playback, in milliseconds. This includes all join times, rebuffer times and seek times, but excludes times without user intention to play, e.g. all paused states.

getWaitTimeRatio

public float getWaitTimeRatio()

Returns the ratio of wait times to the total time spent playing and waiting, or 0.0 if no time was spend playing or waiting. This is equivalent to getTotalWaitTimeMs / getTotalPlayAndWaitTimeMs and also to getJoinTimeRatio + getRebufferTimeRatio + getSeekTimeRatio.

merge

public static PlaybackStats merge(PlaybackStats[] playbackStats)

Returns the combined PlaybackStats for all input PlaybackStats.

Note that the full history of events is not kept as the history only makes sense in the context of a single playback.

Parameters
PlaybackStats[] playbackStats

Array of PlaybackStats to combine.

Returns
PlaybackStats

The combined PlaybackStats.