Search in sources :

Example 6 with TextInformationFrame

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

the class Id3DecoderTest method decodeTxxxFrame.

@Test
public void decodeTxxxFrame() {
    // Test UTF-8.
    byte[] rawId3 = buildSingleFrameTag("TXXX", new byte[] { 3, 0, 109, 100, 105, 97, 108, 111, 103, 95, 86, 73, 78, 68, 73, 67, 79, 49, 53, 50, 55, 54, 54, 52, 95, 115, 116, 97, 114, 116, 0 });
    Id3Decoder decoder = new Id3Decoder();
    Metadata metadata = decoder.decode(rawId3, rawId3.length);
    assertThat(metadata.length()).isEqualTo(1);
    TextInformationFrame textInformationFrame = (TextInformationFrame) metadata.get(0);
    assertThat(textInformationFrame.id).isEqualTo("TXXX");
    assertThat(textInformationFrame.description).isEmpty();
    assertThat(textInformationFrame.value).isEqualTo("mdialog_VINDICO1527664_start");
    // Test UTF-16.
    rawId3 = buildSingleFrameTag("TXXX", new byte[] { 1, 0, 72, 0, 101, 0, 108, 0, 108, 0, 111, 0, 32, 0, 87, 0, 111, 0, 114, 0, 108, 0, 100, 0, 0 });
    metadata = decoder.decode(rawId3, rawId3.length);
    assertThat(metadata.length()).isEqualTo(1);
    textInformationFrame = (TextInformationFrame) metadata.get(0);
    assertThat(textInformationFrame.id).isEqualTo("TXXX");
    assertThat(textInformationFrame.description).isEqualTo("Hello World");
    assertThat(textInformationFrame.value).isEmpty();
    // Test empty.
    rawId3 = buildSingleFrameTag("TXXX", new byte[0]);
    metadata = decoder.decode(rawId3, rawId3.length);
    assertThat(metadata.length()).isEqualTo(0);
    // Test encoding byte only.
    rawId3 = buildSingleFrameTag("TXXX", new byte[] { ID3_TEXT_ENCODING_UTF_8 });
    metadata = decoder.decode(rawId3, rawId3.length);
    assertThat(metadata.length()).isEqualTo(1);
    textInformationFrame = (TextInformationFrame) metadata.get(0);
    assertThat(textInformationFrame.id).isEqualTo("TXXX");
    assertThat(textInformationFrame.description).isEmpty();
    assertThat(textInformationFrame.value).isEmpty();
}
Also used : Metadata(com.google.android.exoplayer2.metadata.Metadata) Test(org.junit.Test)

Example 7 with TextInformationFrame

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

the class TextInformationFrameTest method populateMediaMetadata_setsBuilderValues.

@Test
public void populateMediaMetadata_setsBuilderValues() {
    String title = "the title";
    String artist = "artist";
    String albumTitle = "album title";
    String albumArtist = "album Artist";
    String trackNumberInfo = "11/17";
    String recordingYear = "2000";
    String recordingMonth = "07";
    String recordingDay = "10";
    String releaseDate = "2001-01-02T00:00:00";
    String composer = "composer";
    String conductor = "conductor";
    String writer = "writer";
    List<Metadata.Entry> entries = ImmutableList.of(new TextInformationFrame(/* id= */
    "TT2", /* description= */
    null, /* value= */
    title), new TextInformationFrame(/* id= */
    "TP1", /* description= */
    null, /* value= */
    artist), new TextInformationFrame(/* id= */
    "TAL", /* description= */
    null, /* value= */
    albumTitle), new TextInformationFrame(/* id= */
    "TP2", /* description= */
    null, /* value= */
    albumArtist), new TextInformationFrame(/* id= */
    "TRK", /* description= */
    null, /* value= */
    trackNumberInfo), new TextInformationFrame(/* id= */
    "TYE", /* description= */
    null, /* value= */
    recordingYear), new TextInformationFrame(/* id= */
    "TDA", /* description= */
    null, /* value= */
    recordingDay + recordingMonth), new TextInformationFrame(/* id= */
    "TDRL", /* description= */
    null, /* value= */
    releaseDate), new TextInformationFrame(/* id= */
    "TCM", /* description= */
    null, /* value= */
    composer), new TextInformationFrame(/* id= */
    "TP3", /* description= */
    null, /* value= */
    conductor), new TextInformationFrame(/* id= */
    "TXT", /* description= */
    null, /* value= */
    writer));
    MediaMetadata.Builder builder = MediaMetadata.EMPTY.buildUpon();
    for (Metadata.Entry entry : entries) {
        entry.populateMediaMetadata(builder);
    }
    MediaMetadata mediaMetadata = builder.build();
    assertThat(mediaMetadata.title.toString()).isEqualTo(title);
    assertThat(mediaMetadata.artist.toString()).isEqualTo(artist);
    assertThat(mediaMetadata.albumTitle.toString()).isEqualTo(albumTitle);
    assertThat(mediaMetadata.albumArtist.toString()).isEqualTo(albumArtist);
    assertThat(mediaMetadata.trackNumber).isEqualTo(11);
    assertThat(mediaMetadata.totalTrackCount).isEqualTo(17);
    assertThat(mediaMetadata.recordingYear).isEqualTo(2000);
    assertThat(mediaMetadata.recordingMonth).isEqualTo(7);
    assertThat(mediaMetadata.recordingDay).isEqualTo(10);
    assertThat(mediaMetadata.releaseYear).isEqualTo(2001);
    assertThat(mediaMetadata.releaseMonth).isEqualTo(1);
    assertThat(mediaMetadata.releaseDay).isEqualTo(2);
    assertThat(mediaMetadata.composer.toString()).isEqualTo(composer);
    assertThat(mediaMetadata.conductor.toString()).isEqualTo(conductor);
    assertThat(mediaMetadata.writer.toString()).isEqualTo(writer);
}
Also used : MediaMetadata(com.google.android.exoplayer2.MediaMetadata) Metadata(com.google.android.exoplayer2.metadata.Metadata) MediaMetadata(com.google.android.exoplayer2.MediaMetadata) Test(org.junit.Test)

Example 8 with TextInformationFrame

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

the class EventLogger method printMetadata.

private void printMetadata(Metadata metadata, String prefix) {
    for (int i = 0; i < metadata.length(); i++) {
        Metadata.Entry entry = metadata.get(i);
        if (entry instanceof TextInformationFrame) {
            TextInformationFrame textInformationFrame = (TextInformationFrame) entry;
            Log.d(TAG, prefix + String.format("%s: value=%s", textInformationFrame.id, textInformationFrame.value));
        } else if (entry instanceof UrlLinkFrame) {
            UrlLinkFrame urlLinkFrame = (UrlLinkFrame) entry;
            Log.d(TAG, prefix + String.format("%s: url=%s", urlLinkFrame.id, urlLinkFrame.url));
        } else if (entry instanceof PrivFrame) {
            PrivFrame privFrame = (PrivFrame) entry;
            Log.d(TAG, prefix + String.format("%s: owner=%s", privFrame.id, privFrame.owner));
        } else if (entry instanceof GeobFrame) {
            GeobFrame geobFrame = (GeobFrame) entry;
            Log.d(TAG, prefix + String.format("%s: mimeType=%s, filename=%s, description=%s", geobFrame.id, geobFrame.mimeType, geobFrame.filename, geobFrame.description));
        } else if (entry instanceof ApicFrame) {
            ApicFrame apicFrame = (ApicFrame) entry;
            Log.d(TAG, prefix + String.format("%s: mimeType=%s, description=%s", apicFrame.id, apicFrame.mimeType, apicFrame.description));
        } else if (entry instanceof CommentFrame) {
            CommentFrame commentFrame = (CommentFrame) entry;
            Log.d(TAG, prefix + String.format("%s: language=%s, description=%s", commentFrame.id, commentFrame.language, commentFrame.description));
        } else if (entry instanceof Id3Frame) {
            Id3Frame id3Frame = (Id3Frame) entry;
            Log.d(TAG, prefix + String.format("%s", id3Frame.id));
        } else if (entry instanceof EventMessage) {
            EventMessage eventMessage = (EventMessage) entry;
            Log.d(TAG, prefix + String.format("EMSG: scheme=%s, id=%d, value=%s", eventMessage.schemeIdUri, eventMessage.id, eventMessage.value));
        }
    }
}
Also used : GeobFrame(com.google.android.exoplayer2.metadata.id3.GeobFrame) EventMessage(com.google.android.exoplayer2.metadata.emsg.EventMessage) ApicFrame(com.google.android.exoplayer2.metadata.id3.ApicFrame) Metadata(com.google.android.exoplayer2.metadata.Metadata) CommentFrame(com.google.android.exoplayer2.metadata.id3.CommentFrame) UrlLinkFrame(com.google.android.exoplayer2.metadata.id3.UrlLinkFrame) PrivFrame(com.google.android.exoplayer2.metadata.id3.PrivFrame) Id3Frame(com.google.android.exoplayer2.metadata.id3.Id3Frame) TextInformationFrame(com.google.android.exoplayer2.metadata.id3.TextInformationFrame)

Example 9 with TextInformationFrame

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

the class Id3DecoderTest method testDecodeTextInformationFrame.

public void testDecodeTextInformationFrame() throws MetadataDecoderException {
    byte[] rawId3 = new byte[] { 73, 68, 51, 4, 0, 0, 0, 0, 0, 23, 84, 73, 84, 50, 0, 0, 0, 13, 0, 0, 3, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 0 };
    Id3Decoder decoder = new Id3Decoder();
    Metadata metadata = decoder.decode(rawId3, rawId3.length);
    assertEquals(1, metadata.length());
    TextInformationFrame textInformationFrame = (TextInformationFrame) metadata.get(0);
    assertEquals("TIT2", textInformationFrame.id);
    assertNull(textInformationFrame.description);
    assertEquals("Hello World", textInformationFrame.value);
}
Also used : Metadata(com.google.android.exoplayer2.metadata.Metadata)

Example 10 with TextInformationFrame

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

the class Id3DecoderTest method decodeTextInformationFrame.

@Test
public void decodeTextInformationFrame() {
    byte[] rawId3 = buildSingleFrameTag("TIT2", new byte[] { 3, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 0 });
    Id3Decoder decoder = new Id3Decoder();
    Metadata metadata = decoder.decode(rawId3, rawId3.length);
    assertThat(metadata.length()).isEqualTo(1);
    TextInformationFrame textInformationFrame = (TextInformationFrame) metadata.get(0);
    assertThat(textInformationFrame.id).isEqualTo("TIT2");
    assertThat(textInformationFrame.description).isNull();
    assertThat(textInformationFrame.value).isEqualTo("Hello World");
    // Test empty.
    rawId3 = buildSingleFrameTag("TIT2", new byte[0]);
    metadata = decoder.decode(rawId3, rawId3.length);
    assertThat(metadata.length()).isEqualTo(0);
    // Test encoding byte only.
    rawId3 = buildSingleFrameTag("TIT2", new byte[] { ID3_TEXT_ENCODING_UTF_8 });
    metadata = decoder.decode(rawId3, rawId3.length);
    assertThat(metadata.length()).isEqualTo(1);
    textInformationFrame = (TextInformationFrame) metadata.get(0);
    assertThat(textInformationFrame.id).isEqualTo("TIT2");
    assertThat(textInformationFrame.description).isNull();
    assertThat(textInformationFrame.value).isEmpty();
}
Also used : Metadata(com.google.android.exoplayer2.metadata.Metadata) Test(org.junit.Test)

Aggregations

Metadata (com.google.android.exoplayer2.metadata.Metadata)8 TextInformationFrame (com.google.android.exoplayer2.metadata.id3.TextInformationFrame)6 Test (org.junit.Test)5 EventMessage (com.google.android.exoplayer2.metadata.emsg.EventMessage)2 CommentFrame (com.google.android.exoplayer2.metadata.id3.CommentFrame)2 Id3Frame (com.google.android.exoplayer2.metadata.id3.Id3Frame)2 MediaFormat (android.media.MediaFormat)1 Parcel (android.os.Parcel)1 Nullable (androidx.annotation.Nullable)1 WritableArray (com.facebook.react.bridge.WritableArray)1 WritableMap (com.facebook.react.bridge.WritableMap)1 MediaMetadata (com.google.android.exoplayer2.MediaMetadata)1 Listener (com.google.android.exoplayer2.Player.Listener)1 DrmInitData (com.google.android.exoplayer2.drm.DrmInitData)1 ApicFrame (com.google.android.exoplayer2.metadata.id3.ApicFrame)1 BinaryFrame (com.google.android.exoplayer2.metadata.id3.BinaryFrame)1 GeobFrame (com.google.android.exoplayer2.metadata.id3.GeobFrame)1 PrivFrame (com.google.android.exoplayer2.metadata.id3.PrivFrame)1 UrlLinkFrame (com.google.android.exoplayer2.metadata.id3.UrlLinkFrame)1 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)1