MediaPlaybackTimeInfo

data class MediaPlaybackTimeInfo(    val duration: Duration? = null,     val position: Duration? = null,     val playbackSpeed: Float = INVALID_PLAYBACK_SPEED,     val lastPositionUpdateTime: Duration = getElapsedTime()) : Parcelable

Information about a media timeline, such as duration, playing position, and playback speed.

Parameters

duration

Total length of a media item. null if unavailable or infinite, otherwise a positive Duration.

position

The playback position in the media item. null if unavailable, otherwise a zero or positive Duration.

playbackSpeed

The speed of playback as a multiple of normal playback. INVALID_PLAYBACK_SPEED when playback is not active (paused, buffering, or idle). When negative, playback is in reverse.

lastPositionUpdateTime

Elapsed real time since boot of the moment when position was last updated. Comparison with this value can be done by converting it to milliseconds and by using getElapsedTime.

Constructors

Link copied to clipboard
fun MediaPlaybackTimeInfo(    duration: Duration? = null,     position: Duration? = null,     playbackSpeed: Float = INVALID_PLAYBACK_SPEED,     lastPositionUpdateTime: Duration = getElapsedTime())

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val duration: Duration? = null
Link copied to clipboard
val lastPositionUpdateTime: Duration
Link copied to clipboard
val playbackSpeed: Float
Link copied to clipboard
val position: Duration? = null

Functions

Link copied to clipboard
fun durationOrZero(): Duration

Returns duration if it has a valid duration (see hasDuration), otherwise returns Duration.ZERO.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Custom equals method returns true if this object's duration, position and speed match those of other.

Link copied to clipboard
fun hasDuration(): Boolean

Returns true if a duration is not null and is greater than 0.

Link copied to clipboard
open override fun hashCode(): Int

Custom hashCode method needed when customizing equals.

Link copied to clipboard
fun hasPosition(): Boolean

Returns true if a position is not null and is equal or greater than 0.

Link copied to clipboard
fun isPlaying(): Boolean

Returns whether playback is active by looking at the playback speed of a MediaPlaybackTimeInfo.

Link copied to clipboard
fun positionOrZero(): Duration

Returns position if it has a valid position (see hasPosition), otherwise returns Duration.ZERO.

Inherited functions

Link copied to clipboard
abstract fun describeContents(): Int
Link copied to clipboard
abstract fun writeToParcel(p0: Parcel, p1: Int)