Search in sources :

Example 1 with ApicFrame

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

the class Id3DecoderTest method testDecodeApicFrame.

public void testDecodeApicFrame() throws MetadataDecoderException {
    byte[] rawId3 = new byte[] { 73, 68, 51, 4, 0, 0, 0, 0, 0, 45, 65, 80, 73, 67, 0, 0, 0, 35, 0, 0, 3, 105, 109, 97, 103, 101, 47, 106, 112, 101, 103, 0, 16, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
    Id3Decoder decoder = new Id3Decoder();
    Metadata metadata = decoder.decode(rawId3, rawId3.length);
    assertEquals(1, metadata.length());
    ApicFrame apicFrame = (ApicFrame) metadata.get(0);
    assertEquals("image/jpeg", apicFrame.mimeType);
    assertEquals(16, apicFrame.pictureType);
    assertEquals("Hello World", apicFrame.description);
    assertEquals(10, apicFrame.pictureData.length);
    MoreAsserts.assertEquals(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }, apicFrame.pictureData);
}
Also used : Metadata(com.google.android.exoplayer2.metadata.Metadata)

Example 2 with ApicFrame

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

the class SimpleExoPlayerView method setArtworkFromMetadata.

private boolean setArtworkFromMetadata(Metadata metadata) {
    for (int i = 0; i < metadata.length(); i++) {
        Metadata.Entry metadataEntry = metadata.get(i);
        if (metadataEntry instanceof ApicFrame) {
            byte[] bitmapData = ((ApicFrame) metadataEntry).pictureData;
            Bitmap bitmap = BitmapFactory.decodeByteArray(bitmapData, 0, bitmapData.length);
            return setArtworkFromBitmap(bitmap);
        }
    }
    return false;
}
Also used : Bitmap(android.graphics.Bitmap) ApicFrame(com.google.android.exoplayer2.metadata.id3.ApicFrame) Metadata(com.google.android.exoplayer2.metadata.Metadata)

Example 3 with ApicFrame

use of com.google.android.exoplayer2.metadata.id3.ApicFrame 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)

Aggregations

Metadata (com.google.android.exoplayer2.metadata.Metadata)3 ApicFrame (com.google.android.exoplayer2.metadata.id3.ApicFrame)2 Bitmap (android.graphics.Bitmap)1 EventMessage (com.google.android.exoplayer2.metadata.emsg.EventMessage)1 CommentFrame (com.google.android.exoplayer2.metadata.id3.CommentFrame)1 GeobFrame (com.google.android.exoplayer2.metadata.id3.GeobFrame)1 Id3Frame (com.google.android.exoplayer2.metadata.id3.Id3Frame)1 PrivFrame (com.google.android.exoplayer2.metadata.id3.PrivFrame)1 TextInformationFrame (com.google.android.exoplayer2.metadata.id3.TextInformationFrame)1 UrlLinkFrame (com.google.android.exoplayer2.metadata.id3.UrlLinkFrame)1