Search in sources :

Example 6 with TextInformationFrame

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

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(androidx.media3.common.MediaMetadata) Metadata(androidx.media3.common.Metadata) MediaMetadata(androidx.media3.common.MediaMetadata) Test(org.junit.Test)

Example 7 with TextInformationFrame

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

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)

Example 8 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)

Example 9 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 10 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)

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