use of com.google.android.exoplayer2.MediaMetadata 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.MediaMetadata in project ExoPlayer by google.
the class VorbisCommentTest method populateMediaMetadata_setsMediaMetadataValues.
@Test
public void populateMediaMetadata_setsMediaMetadataValues() {
String title = "the title";
String artist = "artist";
String albumTitle = "album title";
String albumArtist = "album Artist";
String description = "a description about the audio.";
List<Metadata.Entry> entries = ImmutableList.of(new VorbisComment("TITLE", title), new VorbisComment("ARTIST", artist), new VorbisComment("ALBUM", albumTitle), new VorbisComment("ALBUMARTIST", albumArtist), new VorbisComment("DESCRIPTION", description));
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.description.toString()).isEqualTo(description);
}
use of com.google.android.exoplayer2.MediaMetadata in project ExoPlayer by google.
the class ApicFrameTest method populateMediaMetadata_setsBuilderValues.
@Test
public void populateMediaMetadata_setsBuilderValues() {
byte[] pictureData = new byte[] { -12, 52, 33, 85, 34, 22, 1, -55 };
@MediaMetadata.PictureType int pictureType = MediaMetadata.PICTURE_TYPE_LEAFLET_PAGE;
Metadata.Entry entry = new ApicFrame(/* mimeType= */
MimeTypes.BASE_TYPE_IMAGE, /* description= */
"an image", pictureType, pictureData);
MediaMetadata.Builder builder = MediaMetadata.EMPTY.buildUpon();
entry.populateMediaMetadata(builder);
MediaMetadata mediaMetadata = builder.build();
assertThat(mediaMetadata.artworkData).isEqualTo(pictureData);
assertThat(mediaMetadata.artworkDataType).isEqualTo(pictureType);
}
use of com.google.android.exoplayer2.MediaMetadata in project ExoPlayer by google.
the class ExoPlayerTest method playingMedia_withNoMetadata_doesNotUpdateMediaMetadata.
@Test
public void playingMedia_withNoMetadata_doesNotUpdateMediaMetadata() throws Exception {
MediaMetadata mediaMetadata = new MediaMetadata.Builder().setTitle("the title").build();
ExoPlayer player = new TestExoPlayerBuilder(context).build();
MediaItem mediaItem = new MediaItem.Builder().setMediaId("id").setUri(Uri.parse("asset://android_asset/media/mp4/sample.mp4")).setMediaMetadata(mediaMetadata).build();
player.setMediaItem(mediaItem);
assertThat(player.getMediaMetadata()).isEqualTo(mediaMetadata);
player.prepare();
TestPlayerRunHelper.playUntilPosition(player, /* mediaItemIndex= */
0, /* positionMs= */
5 * C.MILLIS_PER_SECOND);
player.stop();
shadowOf(Looper.getMainLooper()).idle();
assertThat(player.getMediaMetadata()).isEqualTo(mediaMetadata);
}
use of com.google.android.exoplayer2.MediaMetadata in project Signal-Android by WhisperSystems.
the class VoiceNotePlaybackPreparer method indexAfter.
private int indexAfter(@NonNull MediaItem target) {
int size = player.getMediaItemCount();
long targetMessageId = target.mediaMetadata.extras.getLong(VoiceNoteMediaItemFactory.EXTRA_MESSAGE_ID);
for (int i = 0; i < size; i++) {
MediaMetadata mediaMetadata = player.getMediaItemAt(i).mediaMetadata;
long messageId = mediaMetadata.extras.getLong(VoiceNoteMediaItemFactory.EXTRA_MESSAGE_ID);
if (messageId > targetMessageId) {
return i;
}
}
return size;
}
Aggregations