Search in sources :

Example 1 with MediaMetadata

use of com.sonos.services._1.MediaMetadata in project ExoPlayer by google.

the class DefaultMediaDescriptionAdapterTest method getters_returnMediaMetadataValues.

@Test
public void getters_returnMediaMetadataValues() {
    Context context = ApplicationProvider.getApplicationContext();
    Player player = mock(Player.class);
    MediaMetadata mediaMetadata = new MediaMetadata.Builder().setDisplayTitle("display title").setArtist("artist").build();
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, new Intent(), PendingIntent.FLAG_IMMUTABLE);
    DefaultMediaDescriptionAdapter adapter = new DefaultMediaDescriptionAdapter(pendingIntent);
    when(player.getMediaMetadata()).thenReturn(mediaMetadata);
    assertThat(adapter.createCurrentContentIntent(player)).isEqualTo(pendingIntent);
    assertThat(adapter.getCurrentContentTitle(player).toString()).isEqualTo(mediaMetadata.displayTitle.toString());
    assertThat(adapter.getCurrentContentText(player).toString()).isEqualTo(mediaMetadata.artist.toString());
}
Also used : Context(android.content.Context) Player(com.google.android.exoplayer2.Player) MediaMetadata(com.google.android.exoplayer2.MediaMetadata) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) Test(org.junit.Test)

Example 2 with MediaMetadata

use of com.sonos.services._1.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);
}
Also used : MediaMetadata(com.google.android.exoplayer2.MediaMetadata) Metadata(com.google.android.exoplayer2.metadata.Metadata) MediaMetadata(com.google.android.exoplayer2.MediaMetadata) Test(org.junit.Test)

Example 3 with MediaMetadata

use of com.sonos.services._1.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);
}
Also used : MediaMetadata(com.google.android.exoplayer2.MediaMetadata) Metadata(com.google.android.exoplayer2.metadata.Metadata) MediaMetadata(com.google.android.exoplayer2.MediaMetadata) Test(org.junit.Test)

Example 4 with MediaMetadata

use of com.sonos.services._1.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);
}
Also used : MediaMetadata(com.google.android.exoplayer2.MediaMetadata) Metadata(com.google.android.exoplayer2.metadata.Metadata) MediaMetadata(com.google.android.exoplayer2.MediaMetadata) Test(org.junit.Test)

Example 5 with MediaMetadata

use of com.sonos.services._1.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;
}
Also used : MediaMetadata(com.google.android.exoplayer2.MediaMetadata)

Aggregations

MediaMetadata (com.google.android.exoplayer2.MediaMetadata)9 Test (org.junit.Test)6 Metadata (com.google.android.exoplayer2.metadata.Metadata)4 PendingIntent (android.app.PendingIntent)1 Context (android.content.Context)1 Intent (android.content.Intent)1 Player (com.google.android.exoplayer2.Player)1 AlbumArtUrl (com.sonos.services._1.AlbumArtUrl)1 GetMediaMetadata (com.sonos.services._1.GetMediaMetadata)1 MediaMetadata (com.sonos.services._1.MediaMetadata)1 TrackMetadata (com.sonos.services._1.TrackMetadata)1