Search in sources :

Example 16 with Id3Decoder

use of com.google.android.exoplayer2.metadata.id3.Id3Decoder in project ExoPlayer by google.

the class Id3DecoderTest method decodeFailsIfPositionNonZero.

@Test
public void decodeFailsIfPositionNonZero() {
    Id3Decoder decoder = new Id3Decoder();
    MetadataInputBuffer buffer = createMetadataInputBuffer(createByteArray(1, 2, 3));
    buffer.data.position(1);
    assertThrows(IllegalArgumentException.class, () -> decoder.decode(buffer));
}
Also used : MetadataInputBuffer(com.google.android.exoplayer2.metadata.MetadataInputBuffer) Test(org.junit.Test)

Example 17 with Id3Decoder

use of com.google.android.exoplayer2.metadata.id3.Id3Decoder in project ExoPlayer by google.

the class Id3DecoderTest method decodeWxxxFrame.

@Test
public void decodeWxxxFrame() {
    byte[] rawId3 = buildSingleFrameTag("WXXX", new byte[] { ID3_TEXT_ENCODING_UTF_8, 116, 101, 115, 116, 0, 104, 116, 116, 112, 115, 58, 47, 47, 116, 101, 115, 116, 46, 99, 111, 109, 47, 97, 98, 99, 63, 100, 101, 102 });
    Id3Decoder decoder = new Id3Decoder();
    Metadata metadata = decoder.decode(rawId3, rawId3.length);
    assertThat(metadata.length()).isEqualTo(1);
    UrlLinkFrame urlLinkFrame = (UrlLinkFrame) metadata.get(0);
    assertThat(urlLinkFrame.id).isEqualTo("WXXX");
    assertThat(urlLinkFrame.description).isEqualTo("test");
    assertThat(urlLinkFrame.url).isEqualTo("https://test.com/abc?def");
    // Test empty.
    rawId3 = buildSingleFrameTag("WXXX", new byte[0]);
    metadata = decoder.decode(rawId3, rawId3.length);
    assertThat(metadata.length()).isEqualTo(0);
    // Test encoding byte only.
    rawId3 = buildSingleFrameTag("WXXX", new byte[] { ID3_TEXT_ENCODING_UTF_8 });
    metadata = decoder.decode(rawId3, rawId3.length);
    assertThat(metadata.length()).isEqualTo(1);
    urlLinkFrame = (UrlLinkFrame) metadata.get(0);
    assertThat(urlLinkFrame.id).isEqualTo("WXXX");
    assertThat(urlLinkFrame.description).isEmpty();
    assertThat(urlLinkFrame.url).isEmpty();
}
Also used : Metadata(com.google.android.exoplayer2.metadata.Metadata) Test(org.junit.Test)

Aggregations

Metadata (com.google.android.exoplayer2.metadata.Metadata)13 Test (org.junit.Test)11 MetadataInputBuffer (com.google.android.exoplayer2.metadata.MetadataInputBuffer)3 Nullable (androidx.annotation.Nullable)2 Id3Decoder (com.google.android.exoplayer2.metadata.id3.Id3Decoder)2 Uri (android.net.Uri)1 HlsMediaPlaylist (com.google.android.exoplayer2.source.hls.playlist.HlsMediaPlaylist)1 DataSource (com.google.android.exoplayer2.upstream.DataSource)1 DataSpec (com.google.android.exoplayer2.upstream.DataSpec)1 ParsableByteArray (com.google.android.exoplayer2.util.ParsableByteArray)1 EOFException (java.io.EOFException)1