mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-26 17:12:31 -06:00
69 lines
2.1 KiB
Java
69 lines
2.1 KiB
Java
package androidx.media3.exoplayer;
|
|
|
|
import androidx.media3.common.PlaybackParameters;
|
|
import androidx.media3.common.util.Clock;
|
|
import androidx.media3.common.util.Util;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class StandaloneMediaClock implements MediaClock {
|
|
private long baseElapsedMs;
|
|
private long baseUs;
|
|
private final Clock clock;
|
|
private PlaybackParameters playbackParameters = PlaybackParameters.DEFAULT;
|
|
private boolean started;
|
|
|
|
@Override // androidx.media3.exoplayer.MediaClock
|
|
public PlaybackParameters getPlaybackParameters() {
|
|
return this.playbackParameters;
|
|
}
|
|
|
|
public StandaloneMediaClock(Clock clock) {
|
|
this.clock = clock;
|
|
}
|
|
|
|
public void start() {
|
|
if (this.started) {
|
|
return;
|
|
}
|
|
this.baseElapsedMs = this.clock.elapsedRealtime();
|
|
this.started = true;
|
|
}
|
|
|
|
public void stop() {
|
|
if (this.started) {
|
|
resetPosition(getPositionUs());
|
|
this.started = false;
|
|
}
|
|
}
|
|
|
|
public void resetPosition(long j) {
|
|
this.baseUs = j;
|
|
if (this.started) {
|
|
this.baseElapsedMs = this.clock.elapsedRealtime();
|
|
}
|
|
}
|
|
|
|
@Override // androidx.media3.exoplayer.MediaClock
|
|
public long getPositionUs() {
|
|
long mediaTimeUsForPlayoutTimeMs;
|
|
long j = this.baseUs;
|
|
if (!this.started) {
|
|
return j;
|
|
}
|
|
long elapsedRealtime = this.clock.elapsedRealtime() - this.baseElapsedMs;
|
|
if (this.playbackParameters.speed == 1.0f) {
|
|
mediaTimeUsForPlayoutTimeMs = Util.msToUs(elapsedRealtime);
|
|
} else {
|
|
mediaTimeUsForPlayoutTimeMs = this.playbackParameters.getMediaTimeUsForPlayoutTimeMs(elapsedRealtime);
|
|
}
|
|
return j + mediaTimeUsForPlayoutTimeMs;
|
|
}
|
|
|
|
@Override // androidx.media3.exoplayer.MediaClock
|
|
public void setPlaybackParameters(PlaybackParameters playbackParameters) {
|
|
if (this.started) {
|
|
resetPosition(getPositionUs());
|
|
}
|
|
this.playbackParameters = playbackParameters;
|
|
}
|
|
}
|