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