use of com.google.android.exoplayer2.metadata.mp4.SlowMotionData in project ExoPlayer by google.
the class SegmentSpeedProviderTest method getSpeed_returnsCorrectSpeed.
@Test
public void getSpeed_returnsCorrectSpeed() {
List<Segment> segments = ImmutableList.of(new Segment(/* startTimeMs= */
500, /* endTimeMs= */
1000, /* speedDivisor= */
8), new Segment(/* startTimeMs= */
1500, /* endTimeMs= */
2000, /* speedDivisor= */
4), new Segment(/* startTimeMs= */
2000, /* endTimeMs= */
2500, /* speedDivisor= */
2));
SegmentSpeedProvider provider = new SegmentSpeedProvider(new Format.Builder().setMetadata(new Metadata(new SlowMotionData(segments), SMTA_SPEED_8)).build());
assertThat(provider.getSpeed(Util.msToUs(0))).isEqualTo(8);
assertThat(provider.getSpeed(Util.msToUs(500))).isEqualTo(1);
assertThat(provider.getSpeed(Util.msToUs(800))).isEqualTo(1);
assertThat(provider.getSpeed(Util.msToUs(1000))).isEqualTo(8);
assertThat(provider.getSpeed(Util.msToUs(1250))).isEqualTo(8);
assertThat(provider.getSpeed(Util.msToUs(1500))).isEqualTo(2);
assertThat(provider.getSpeed(Util.msToUs(1650))).isEqualTo(2);
assertThat(provider.getSpeed(Util.msToUs(2000))).isEqualTo(4);
assertThat(provider.getSpeed(Util.msToUs(2400))).isEqualTo(4);
assertThat(provider.getSpeed(Util.msToUs(2500))).isEqualTo(8);
assertThat(provider.getSpeed(Util.msToUs(3000))).isEqualTo(8);
}
Aggregations