mirror of
https://github.com/samsonjs/media.git
synced 2026-04-13 12:35:48 +00:00
Add speed-only constructor for PlaybackParameters
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=190927811
This commit is contained in:
parent
1d2d777f66
commit
7820497006
3 changed files with 19 additions and 7 deletions
|
|
@ -22,9 +22,11 @@ import com.google.android.exoplayer2.util.Assertions;
|
|||
*/
|
||||
public final class PlaybackParameters {
|
||||
|
||||
/** The default playback parameters: real-time playback with no pitch modification. */
|
||||
public static final PlaybackParameters DEFAULT =
|
||||
new PlaybackParameters(/* speed= */ 1f, /* pitch= */ 1f, /* skipSilence= */ false);
|
||||
/**
|
||||
* The default playback parameters: real-time playback with no pitch modification or silence
|
||||
* skipping.
|
||||
*/
|
||||
public static final PlaybackParameters DEFAULT = new PlaybackParameters(/* speed= */ 1f);
|
||||
|
||||
/** The factor by which playback will be sped up. */
|
||||
public final float speed;
|
||||
|
|
@ -38,7 +40,16 @@ public final class PlaybackParameters {
|
|||
private final int scaledUsPerMs;
|
||||
|
||||
/**
|
||||
* Creates new playback parameters.
|
||||
* Creates new playback parameters that set the playback speed.
|
||||
*
|
||||
* @param speed The factor by which playback will be sped up. Must be greater than zero.
|
||||
*/
|
||||
public PlaybackParameters(float speed) {
|
||||
this(speed, /* pitch= */ 1f, /* skipSilence= */ false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new playback parameters that set the playback speed and audio pitch scaling factor.
|
||||
*
|
||||
* @param speed The factor by which playback will be sped up. Must be greater than zero.
|
||||
* @param pitch The factor by which the audio pitch will be scaled. Must be greater than zero.
|
||||
|
|
@ -48,7 +59,8 @@ public final class PlaybackParameters {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates new playback parameters.
|
||||
* Creates new playback parameters that set the playback speed, audio pitch scaling factor and
|
||||
* whether to skip silence in the audio stream.
|
||||
*
|
||||
* @param speed The factor by which playback will be sped up. Must be greater than zero.
|
||||
* @param pitch The factor by which the audio pitch will be scaled. Must be greater than zero.
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class DefaultMediaClockTest {
|
|||
private static final long TEST_POSITION_US = 123456789012345678L;
|
||||
private static final long SLEEP_TIME_MS = 1_000;
|
||||
private static final PlaybackParameters TEST_PLAYBACK_PARAMETERS =
|
||||
new PlaybackParameters(2.0f, 1.0f);
|
||||
new PlaybackParameters(/* speed= */ 2f);
|
||||
|
||||
@Mock private PlaybackParameterListener listener;
|
||||
private FakeClock fakeClock;
|
||||
|
|
|
|||
|
|
@ -914,7 +914,7 @@ public final class ExoPlayerTest {
|
|||
}
|
||||
})
|
||||
// Set playback parameters (while the fake media period is not yet prepared).
|
||||
.setPlaybackParameters(new PlaybackParameters(2f, 2f))
|
||||
.setPlaybackParameters(new PlaybackParameters(/* speed= */ 2f, /* pitch= */ 2f))
|
||||
// Complete preparation of the fake media period.
|
||||
.executeRunnable(
|
||||
new Runnable() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue