Search in sources :

Example 6 with SlowMotionData

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);
}
Also used : Format(com.google.android.exoplayer2.Format) SlowMotionData(com.google.android.exoplayer2.metadata.mp4.SlowMotionData) Metadata(com.google.android.exoplayer2.metadata.Metadata) Segment(com.google.android.exoplayer2.metadata.mp4.SlowMotionData.Segment) Test(org.junit.Test)

Aggregations

SlowMotionData (com.google.android.exoplayer2.metadata.mp4.SlowMotionData)6 Metadata (com.google.android.exoplayer2.metadata.Metadata)4 SmtaMetadataEntry (com.google.android.exoplayer2.metadata.mp4.SmtaMetadataEntry)3 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 Format (com.google.android.exoplayer2.Format)2 Segment (com.google.android.exoplayer2.metadata.mp4.SlowMotionData.Segment)2 Parcel (android.os.Parcel)1 Nullable (androidx.annotation.Nullable)1 MdtaMetadataEntry (com.google.android.exoplayer2.metadata.mp4.MdtaMetadataEntry)1 TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)1