Search in sources :

Example 6 with VorbisComment

use of com.google.android.exoplayer2.metadata.vorbis.VorbisComment in project ExoPlayer by google.

the class FlacMetadataReaderTest method readMetadataBlock_vorbisCommentBlock_updatesStreamMetadata.

@Test
public void readMetadataBlock_vorbisCommentBlock_updatesStreamMetadata() throws Exception {
    ExtractorInput input = buildExtractorInput("media/flac/bear_with_vorbis_comments.flac");
    // Skip to Vorbis comment block.
    input.skipFully(640);
    FlacStreamMetadataHolder metadataHolder = new FlacStreamMetadataHolder(buildStreamMetadata());
    long originalSampleRate = metadataHolder.flacStreamMetadata.sampleRate;
    FlacMetadataReader.readMetadataBlock(input, metadataHolder);
    assertThat(metadataHolder.flacStreamMetadata).isNotNull();
    // Check that metadata passed has not been erased.
    assertThat(metadataHolder.flacStreamMetadata.sampleRate).isEqualTo(originalSampleRate);
    Metadata metadata = metadataHolder.flacStreamMetadata.getMetadataCopyWithAppendedEntriesFrom(null);
    assertThat(metadata).isNotNull();
    VorbisComment vorbisComment = (VorbisComment) metadata.get(0);
    assertThat(vorbisComment.key).isEqualTo("TITLE");
    assertThat(vorbisComment.value).isEqualTo("test title");
}
Also used : FlacStreamMetadataHolder(com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder) FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) Metadata(com.google.android.exoplayer2.metadata.Metadata) VorbisComment(com.google.android.exoplayer2.metadata.vorbis.VorbisComment) Test(org.junit.Test)

Aggregations

Metadata (com.google.android.exoplayer2.metadata.Metadata)6 VorbisComment (com.google.android.exoplayer2.metadata.vorbis.VorbisComment)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 Nullable (androidx.annotation.Nullable)1 MediaMetadata (com.google.android.exoplayer2.MediaMetadata)1 FlacStreamMetadataHolder (com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder)1 Entry (com.google.android.exoplayer2.metadata.Metadata.Entry)1 FakeExtractorInput (com.google.android.exoplayer2.testutil.FakeExtractorInput)1 ParsableByteArray (com.google.android.exoplayer2.util.ParsableByteArray)1