Update CompositionPlayer state for volume.
PiperOrigin-RevId: 646071591
This commit is contained in:
parent
ada4dc982f
commit
938fac4161
@ -283,6 +283,7 @@ public final class CompositionPlayer extends SimpleBasePlayer
|
|||||||
private long compositionDurationUs;
|
private long compositionDurationUs;
|
||||||
private boolean playWhenReady;
|
private boolean playWhenReady;
|
||||||
private @PlayWhenReadyChangeReason int playWhenReadyChangeReason;
|
private @PlayWhenReadyChangeReason int playWhenReadyChangeReason;
|
||||||
|
private float volume;
|
||||||
private boolean renderedFirstFrame;
|
private boolean renderedFirstFrame;
|
||||||
@Nullable private Object videoOutput;
|
@Nullable private Object videoOutput;
|
||||||
@Nullable private PlaybackException playbackException;
|
@Nullable private PlaybackException playbackException;
|
||||||
@ -303,6 +304,7 @@ public final class CompositionPlayer extends SimpleBasePlayer
|
|||||||
players = new ArrayList<>();
|
players = new ArrayList<>();
|
||||||
compositionDurationUs = C.TIME_UNSET;
|
compositionDurationUs = C.TIME_UNSET;
|
||||||
playbackState = STATE_IDLE;
|
playbackState = STATE_IDLE;
|
||||||
|
volume = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -425,6 +427,7 @@ public final class CompositionPlayer extends SimpleBasePlayer
|
|||||||
.setPlaybackState(playbackState)
|
.setPlaybackState(playbackState)
|
||||||
.setPlayerError(playbackException)
|
.setPlayerError(playbackException)
|
||||||
.setPlayWhenReady(playWhenReady, playWhenReadyChangeReason)
|
.setPlayWhenReady(playWhenReady, playWhenReadyChangeReason)
|
||||||
|
.setVolume(volume)
|
||||||
.setContentPositionMs(this::getContentPositionMs)
|
.setContentPositionMs(this::getContentPositionMs)
|
||||||
.setContentBufferedPositionMs(this::getBufferedPositionMs)
|
.setContentBufferedPositionMs(this::getBufferedPositionMs)
|
||||||
.setTotalBufferedDurationMs(this::getTotalBufferedDurationMs)
|
.setTotalBufferedDurationMs(this::getTotalBufferedDurationMs)
|
||||||
@ -525,8 +528,8 @@ public final class CompositionPlayer extends SimpleBasePlayer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ListenableFuture<?> handleSetVolume(float volume) {
|
protected ListenableFuture<?> handleSetVolume(float volume) {
|
||||||
volume = Util.constrainValue(volume, /* min= */ 0, /* max= */ 1);
|
this.volume = Util.constrainValue(volume, /* min= */ 0.0f, /* max= */ 1.0f);
|
||||||
finalAudioSink.setVolume(volume);
|
finalAudioSink.setVolume(this.volume);
|
||||||
return Futures.immediateVoidFuture();
|
return Futures.immediateVoidFuture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user