StandaloneMediaClock


@UnstableApi
public final class StandaloneMediaClock implements MediaClock


A MediaClock whose position advances with real time based on the playback parameters when started.

Summary

Public constructors

Creates a new standalone media clock using the given Clock implementation.

Public methods

PlaybackParameters

Returns the active playback parameters.

long

Returns the current media position in microseconds.

void
resetPosition(long positionUs)

Resets the clock's position.

void

Attempts to set the playback parameters.

void

Starts the clock.

void

Stops the clock.

Inherited methods

From androidx.media3.exoplayer.MediaClock
boolean

Returns whether there is a skipped silence since the last call to this method.

Public fields

playbackParameters

public PlaybackParameters playbackParameters

Public constructors

StandaloneMediaClock

public StandaloneMediaClock(Clock clock)

Creates a new standalone media clock using the given Clock implementation.

Parameters
Clock clock

A Clock.

Public methods

getPlaybackParameters

public PlaybackParameters getPlaybackParameters()

Returns the active playback parameters.

getPositionUs

public long getPositionUs()

Returns the current media position in microseconds.

resetPosition

public void resetPosition(long positionUs)

Resets the clock's position.

Parameters
long positionUs

The position to set in microseconds.

setPlaybackParameters

public void setPlaybackParameters(PlaybackParameters playbackParameters)

Attempts to set the playback parameters. The media clock may override the speed if changing the playback parameters is not supported.

Parameters
PlaybackParameters playbackParameters

The playback parameters to attempt to set.

start

public void start()

Starts the clock. Does nothing if the clock is already started.

stop

public void stop()

Stops the clock. Does nothing if the clock is already stopped.