Commit 78204970 by andrewlewis Committed by Oliver Woodman

Add speed-only constructor for PlaybackParameters

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190927811
parent 1d2d777f
...@@ -22,9 +22,11 @@ import com.google.android.exoplayer2.util.Assertions; ...@@ -22,9 +22,11 @@ import com.google.android.exoplayer2.util.Assertions;
*/ */
public final class PlaybackParameters { public final class PlaybackParameters {
/** The default playback parameters: real-time playback with no pitch modification. */ /**
public static final PlaybackParameters DEFAULT = * The default playback parameters: real-time playback with no pitch modification or silence
new PlaybackParameters(/* speed= */ 1f, /* pitch= */ 1f, /* skipSilence= */ false); * skipping.
*/
public static final PlaybackParameters DEFAULT = new PlaybackParameters(/* speed= */ 1f);
/** The factor by which playback will be sped up. */ /** The factor by which playback will be sped up. */
public final float speed; public final float speed;
...@@ -38,7 +40,16 @@ public final class PlaybackParameters { ...@@ -38,7 +40,16 @@ public final class PlaybackParameters {
private final int scaledUsPerMs; 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 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. * @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 { ...@@ -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 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. * @param pitch The factor by which the audio pitch will be scaled. Must be greater than zero.
......
...@@ -40,7 +40,7 @@ public class DefaultMediaClockTest { ...@@ -40,7 +40,7 @@ public class DefaultMediaClockTest {
private static final long TEST_POSITION_US = 123456789012345678L; private static final long TEST_POSITION_US = 123456789012345678L;
private static final long SLEEP_TIME_MS = 1_000; private static final long SLEEP_TIME_MS = 1_000;
private static final PlaybackParameters TEST_PLAYBACK_PARAMETERS = private static final PlaybackParameters TEST_PLAYBACK_PARAMETERS =
new PlaybackParameters(2.0f, 1.0f); new PlaybackParameters(/* speed= */ 2f);
@Mock private PlaybackParameterListener listener; @Mock private PlaybackParameterListener listener;
private FakeClock fakeClock; private FakeClock fakeClock;
......
...@@ -914,7 +914,7 @@ public final class ExoPlayerTest { ...@@ -914,7 +914,7 @@ public final class ExoPlayerTest {
} }
}) })
// Set playback parameters (while the fake media period is not yet prepared). // 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. // Complete preparation of the fake media period.
.executeRunnable( .executeRunnable(
new Runnable() { new Runnable() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment