mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Change TransformerInternal durationMs to durationUs.
Follow-up CLs will use this duration for silent audio. PiperOrigin-RevId: 491670359
This commit is contained in:
parent
4033013ff8
commit
a8e9d158cd
2 changed files with 7 additions and 8 deletions
|
|
@ -32,7 +32,6 @@ import androidx.media3.common.Player;
|
||||||
import androidx.media3.common.Timeline;
|
import androidx.media3.common.Timeline;
|
||||||
import androidx.media3.common.Tracks;
|
import androidx.media3.common.Tracks;
|
||||||
import androidx.media3.common.util.Clock;
|
import androidx.media3.common.util.Clock;
|
||||||
import androidx.media3.common.util.Util;
|
|
||||||
import androidx.media3.exoplayer.DefaultLoadControl;
|
import androidx.media3.exoplayer.DefaultLoadControl;
|
||||||
import androidx.media3.exoplayer.ExoPlayer;
|
import androidx.media3.exoplayer.ExoPlayer;
|
||||||
import androidx.media3.exoplayer.Renderer;
|
import androidx.media3.exoplayer.Renderer;
|
||||||
|
|
@ -48,7 +47,7 @@ import androidx.media3.exoplayer.video.VideoRendererEventListener;
|
||||||
|
|
||||||
public interface Listener {
|
public interface Listener {
|
||||||
|
|
||||||
void onDurationMs(long durationMs);
|
void onDurationUs(long durationUs);
|
||||||
|
|
||||||
void onTrackRegistered();
|
void onTrackRegistered();
|
||||||
|
|
||||||
|
|
@ -174,7 +173,7 @@ import androidx.media3.exoplayer.video.VideoRendererEventListener;
|
||||||
Timeline.Window window = new Timeline.Window();
|
Timeline.Window window = new Timeline.Window();
|
||||||
timeline.getWindow(/* windowIndex= */ 0, window);
|
timeline.getWindow(/* windowIndex= */ 0, window);
|
||||||
if (!window.isPlaceholder) {
|
if (!window.isPlaceholder) {
|
||||||
listener.onDurationMs(Util.usToMs(window.durationUs));
|
listener.onDurationUs(window.durationUs);
|
||||||
hasSentDuration = true;
|
hasSentDuration = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
private boolean isDrainingPipelines;
|
private boolean isDrainingPipelines;
|
||||||
private @Transformer.ProgressState int progressState;
|
private @Transformer.ProgressState int progressState;
|
||||||
private long progressPositionMs;
|
private long progressPositionMs;
|
||||||
private long durationMs;
|
private long durationUs;
|
||||||
private @MonotonicNonNull RuntimeException cancelException;
|
private @MonotonicNonNull RuntimeException cancelException;
|
||||||
|
|
||||||
private volatile boolean released;
|
private volatile boolean released;
|
||||||
|
|
@ -189,7 +189,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
|
|
||||||
public @Transformer.ProgressState int getProgress(ProgressHolder progressHolder) {
|
public @Transformer.ProgressState int getProgress(ProgressHolder progressHolder) {
|
||||||
if (progressState == PROGRESS_STATE_AVAILABLE) {
|
if (progressState == PROGRESS_STATE_AVAILABLE) {
|
||||||
progressHolder.progress = min((int) (progressPositionMs * 100 / durationMs), 99);
|
progressHolder.progress = min((int) (progressPositionMs * 100 / Util.usToMs(durationUs)), 99);
|
||||||
}
|
}
|
||||||
return progressState;
|
return progressState;
|
||||||
}
|
}
|
||||||
|
|
@ -371,17 +371,17 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
// ExoPlayerAssetLoader.Listener implementation.
|
// ExoPlayerAssetLoader.Listener implementation.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDurationMs(long durationMs) {
|
public void onDurationUs(long durationUs) {
|
||||||
applicationHandler.post(
|
applicationHandler.post(
|
||||||
() -> {
|
() -> {
|
||||||
// Make progress permanently unavailable if the duration is unknown, so that it doesn't
|
// Make progress permanently unavailable if the duration is unknown, so that it doesn't
|
||||||
// jump to a high value at the end of the transformation if the duration is set once the
|
// jump to a high value at the end of the transformation if the duration is set once the
|
||||||
// media is entirely loaded.
|
// media is entirely loaded.
|
||||||
progressState =
|
progressState =
|
||||||
durationMs <= 0 || durationMs == C.TIME_UNSET
|
durationUs <= 0 || durationUs == C.TIME_UNSET
|
||||||
? PROGRESS_STATE_UNAVAILABLE
|
? PROGRESS_STATE_UNAVAILABLE
|
||||||
: PROGRESS_STATE_AVAILABLE;
|
: PROGRESS_STATE_AVAILABLE;
|
||||||
TransformerInternal.this.durationMs = durationMs;
|
TransformerInternal.this.durationUs = durationUs;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue