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);
}
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);
}
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);
}
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);
}
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;
}
Aggregations