Search in sources :

Example 1 with TextInformationFrame

use of androidx.media3.extractor.metadata.id3.TextInformationFrame in project ExoPlayer by google.

the class FormatTest method testParcelable.

public void testParcelable() {
    DrmInitData.SchemeData DRM_DATA_1 = new DrmInitData.SchemeData(WIDEVINE_UUID, VIDEO_MP4, TestUtil.buildTestData(128, 1));
    DrmInitData.SchemeData DRM_DATA_2 = new DrmInitData.SchemeData(C.UUID_NIL, VIDEO_WEBM, TestUtil.buildTestData(128, 1));
    DrmInitData drmInitData = new DrmInitData(DRM_DATA_1, DRM_DATA_2);
    byte[] projectionData = new byte[] { 1, 2, 3 };
    Metadata metadata = new Metadata(new TextInformationFrame("id1", "description1", "value1"), new TextInformationFrame("id2", "description2", "value2"));
    Format formatToParcel = new Format("id", MimeTypes.VIDEO_MP4, MimeTypes.VIDEO_H264, null, 1024, 2048, 1920, 1080, 24, 90, 2, projectionData, C.STEREO_MODE_TOP_BOTTOM, 6, 44100, C.ENCODING_PCM_24BIT, 1001, 1002, 0, "und", Format.NO_VALUE, Format.OFFSET_SAMPLE_RELATIVE, INIT_DATA, drmInitData, metadata);
    Parcel parcel = Parcel.obtain();
    formatToParcel.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    Format formatFromParcel = Format.CREATOR.createFromParcel(parcel);
    assertEquals(formatToParcel, formatFromParcel);
    parcel.recycle();
}
Also used : DrmInitData(com.google.android.exoplayer2.drm.DrmInitData) MediaFormat(android.media.MediaFormat) Parcel(android.os.Parcel) Metadata(com.google.android.exoplayer2.metadata.Metadata) TextInformationFrame(com.google.android.exoplayer2.metadata.id3.TextInformationFrame)

Example 2 with TextInformationFrame

use of androidx.media3.extractor.metadata.id3.TextInformationFrame in project ExoPlayer by google.

the class MetadataRendererTest method decodeMetadata_handlesId3WrappedInEmsg.

@Test
public void decodeMetadata_handlesId3WrappedInEmsg() throws Exception {
    EventMessage emsg = new EventMessage(EventMessage.ID3_SCHEME_ID_AOM, /* value= */
    "", /* durationMs= */
    1, /* id= */
    0, encodeTxxxId3Frame("Test description", "Test value"));
    List<Metadata> metadata = runRenderer(eventMessageEncoder.encode(emsg));
    assertThat(metadata).hasSize(1);
    assertThat(metadata.get(0).length()).isEqualTo(1);
    TextInformationFrame expectedId3Frame = new TextInformationFrame("TXXX", "Test description", "Test value");
    assertThat(metadata.get(0).get(0)).isEqualTo(expectedId3Frame);
}
Also used : EventMessage(com.google.android.exoplayer2.metadata.emsg.EventMessage) TextInformationFrame(com.google.android.exoplayer2.metadata.id3.TextInformationFrame) Test(org.junit.Test)

Example 3 with TextInformationFrame

use of androidx.media3.extractor.metadata.id3.TextInformationFrame in project ExoPlayer by google.

the class MetadataUtil method parseUint8Attribute.

@Nullable
private static Id3Frame parseUint8Attribute(int type, String id, ParsableByteArray data, boolean isTextInformationFrame, boolean isBoolean) {
    int value = parseUint8AttributeValue(data);
    if (isBoolean) {
        value = min(1, value);
    }
    if (value >= 0) {
        return isTextInformationFrame ? new TextInformationFrame(id, /* description= */
        null, Integer.toString(value)) : new CommentFrame(C.LANGUAGE_UNDETERMINED, id, Integer.toString(value));
    }
    Log.w(TAG, "Failed to parse uint8 attribute: " + Atom.getAtomTypeString(type));
    return null;
}
Also used : CommentFrame(com.google.android.exoplayer2.metadata.id3.CommentFrame) TextInformationFrame(com.google.android.exoplayer2.metadata.id3.TextInformationFrame) Nullable(androidx.annotation.Nullable)

Example 4 with TextInformationFrame

use of androidx.media3.extractor.metadata.id3.TextInformationFrame in project react-native-track-player by react-native-kit.

the class SourceMetadata method handleId3Metadata.

/**
 * ID3 Metadata (MP3)
 *
 * https://en.wikipedia.org/wiki/ID3
 */
private static void handleId3Metadata(MusicManager manager, Metadata metadata) {
    String title = null, url = null, artist = null, album = null, date = null, genre = null;
    for (int i = 0; i < metadata.length(); i++) {
        Metadata.Entry entry = metadata.get(i);
        if (entry instanceof TextInformationFrame) {
            // ID3 text tag
            TextInformationFrame id3 = (TextInformationFrame) entry;
            String id = id3.id.toUpperCase();
            if (id.equals("TIT2") || id.equals("TT2")) {
                title = id3.value;
            } else if (id.equals("TALB") || id.equals("TOAL") || id.equals("TAL")) {
                album = id3.value;
            } else if (id.equals("TOPE") || id.equals("TPE1") || id.equals("TP1")) {
                artist = id3.value;
            } else if (id.equals("TDRC") || id.equals("TOR")) {
                date = id3.value;
            } else if (id.equals("TCON") || id.equals("TCO")) {
                genre = id3.value;
            }
        } else if (entry instanceof UrlLinkFrame) {
            // ID3 URL tag
            UrlLinkFrame id3 = (UrlLinkFrame) entry;
            String id = id3.id.toUpperCase();
            if (id.equals("WOAS") || id.equals("WOAF") || id.equals("WOAR") || id.equals("WAR")) {
                url = id3.url;
            }
        }
    }
    if (title != null || url != null || artist != null || album != null || date != null || genre != null) {
        manager.onMetadataReceived("id3", title, url, artist, album, date, genre);
    }
}
Also used : Metadata(com.google.android.exoplayer2.metadata.Metadata) UrlLinkFrame(com.google.android.exoplayer2.metadata.id3.UrlLinkFrame) TextInformationFrame(com.google.android.exoplayer2.metadata.id3.TextInformationFrame)

Example 5 with TextInformationFrame

use of androidx.media3.extractor.metadata.id3.TextInformationFrame in project react-native-video by react-native-community.

the class VideoEventEmitter method timedMetadata.

void timedMetadata(Metadata metadata) {
    WritableArray metadataArray = Arguments.createArray();
    for (int i = 0; i < metadata.length(); i++) {
        Metadata.Entry entry = metadata.get(i);
        if (entry instanceof Id3Frame) {
            Id3Frame frame = (Id3Frame) entry;
            String value = "";
            if (frame instanceof TextInformationFrame) {
                TextInformationFrame txxxFrame = (TextInformationFrame) frame;
                value = txxxFrame.value;
            }
            String identifier = frame.id;
            WritableMap map = Arguments.createMap();
            map.putString("identifier", identifier);
            map.putString("value", value);
            metadataArray.pushMap(map);
        } else if (entry instanceof EventMessage) {
            EventMessage eventMessage = (EventMessage) entry;
            WritableMap map = Arguments.createMap();
            map.putString("identifier", eventMessage.schemeIdUri);
            map.putString("value", eventMessage.value);
            metadataArray.pushMap(map);
        }
    }
    WritableMap event = Arguments.createMap();
    event.putArray(EVENT_PROP_TIMED_METADATA, metadataArray);
    receiveEvent(EVENT_TIMED_METADATA, event);
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) EventMessage(com.google.android.exoplayer2.metadata.emsg.EventMessage) WritableArray(com.facebook.react.bridge.WritableArray) Metadata(com.google.android.exoplayer2.metadata.Metadata) Id3Frame(com.google.android.exoplayer2.metadata.id3.Id3Frame) TextInformationFrame(com.google.android.exoplayer2.metadata.id3.TextInformationFrame)

Aggregations

TextInformationFrame (com.google.android.exoplayer2.metadata.id3.TextInformationFrame)9 Test (org.junit.Test)7 Metadata (com.google.android.exoplayer2.metadata.Metadata)6 Metadata (androidx.media3.common.Metadata)5 EventMessage (com.google.android.exoplayer2.metadata.emsg.EventMessage)4 Nullable (androidx.annotation.Nullable)3 TextInformationFrame (androidx.media3.extractor.metadata.id3.TextInformationFrame)3 CommentFrame (com.google.android.exoplayer2.metadata.id3.CommentFrame)3 Id3Frame (com.google.android.exoplayer2.metadata.id3.Id3Frame)3 MediaMetadata (androidx.media3.common.MediaMetadata)2 WritableArray (com.facebook.react.bridge.WritableArray)2 WritableMap (com.facebook.react.bridge.WritableMap)2 UrlLinkFrame (com.google.android.exoplayer2.metadata.id3.UrlLinkFrame)2 MediaFormat (android.media.MediaFormat)1 Parcel (android.os.Parcel)1 Format (androidx.media3.common.Format)1 PlaybackParameters (androidx.media3.common.PlaybackParameters)1 Player (androidx.media3.common.Player)1 Listener (androidx.media3.common.Player.Listener)1 EventMessage (androidx.media3.extractor.metadata.emsg.EventMessage)1