use of com.google.android.exoplayer2.MediaMetadata in project Signal-Android by signalapp.
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;
}
use of com.google.android.exoplayer2.MediaMetadata in project ExoPlayer by google.
the class SessionCallbackBuilderTest method setMediaItemProvider_withMediaItemProvider_receivesOnCreateMediaItem.
@Test
public void setMediaItemProvider_withMediaItemProvider_receivesOnCreateMediaItem() throws Exception {
Uri testMediaUri = RawResourceDataSource.buildRawResourceUri(R.raw.audio);
CountDownLatch providerLatch = new CountDownLatch(1);
SessionCallbackBuilder.MediaIdMediaItemProvider mediaIdMediaItemProvider = new SessionCallbackBuilder.MediaIdMediaItemProvider();
SessionCallbackBuilder.MediaItemProvider provider = (session, controllerInfo, mediaId) -> {
assertThat(mediaId).isEqualTo(testMediaUri.toString());
providerLatch.countDown();
return mediaIdMediaItemProvider.onCreateMediaItem(session, controllerInfo, mediaId);
};
CountDownLatch currentMediaItemChangedLatch = new CountDownLatch(1);
sessionPlayerConnector.registerPlayerCallback(executor, new SessionPlayer.PlayerCallback() {
@Override
public void onCurrentMediaItemChanged(SessionPlayer player, MediaItem item) {
MediaMetadata metadata = item.getMetadata();
assertThat(metadata.getString(MediaMetadata.METADATA_KEY_MEDIA_ID)).isEqualTo(testMediaUri.toString());
currentMediaItemChangedLatch.countDown();
}
});
try (MediaSession session = createMediaSession(sessionPlayerConnector, new SessionCallbackBuilder(context, sessionPlayerConnector).setMediaItemProvider(provider).build())) {
try (MediaController controller = createConnectedController(session)) {
assertSessionResultSuccess(controller.setMediaItem(testMediaUri.toString()), PLAYER_STATE_CHANGE_OVER_SESSION_WAIT_TIME_MS);
assertThat(providerLatch.await(0, MILLISECONDS)).isTrue();
assertThat(currentMediaItemChangedLatch.await(CONTROLLER_COMMAND_WAIT_TIME_MS, MILLISECONDS)).isTrue();
}
}
}
use of com.google.android.exoplayer2.MediaMetadata in project ExoPlayer by google.
the class DefaultAnalyticsCollector method onPlaylistMetadataChanged.
@Override
public void onPlaylistMetadataChanged(MediaMetadata playlistMetadata) {
EventTime eventTime = generateCurrentPlayerMediaPeriodEventTime();
sendEvent(eventTime, AnalyticsListener.EVENT_PLAYLIST_METADATA_CHANGED, listener -> listener.onPlaylistMetadataChanged(eventTime, playlistMetadata));
}
use of com.google.android.exoplayer2.MediaMetadata in project ExoPlayer by google.
the class ExoPlayerTest method onPlaylistMetadataChanged_calledWhenPlaylistMetadataSet.
@Test
public void onPlaylistMetadataChanged_calledWhenPlaylistMetadataSet() {
ExoPlayer player = new TestExoPlayerBuilder(ApplicationProvider.getApplicationContext()).build();
Player.Listener playerListener = mock(Player.Listener.class);
player.addListener(playerListener);
AnalyticsListener analyticsListener = mock(AnalyticsListener.class);
player.addAnalyticsListener(analyticsListener);
MediaMetadata mediaMetadata = new MediaMetadata.Builder().setTitle("test").build();
player.setPlaylistMetadata(mediaMetadata);
verify(playerListener).onPlaylistMetadataChanged(mediaMetadata);
verify(analyticsListener).onPlaylistMetadataChanged(any(), eq(mediaMetadata));
}
use of com.google.android.exoplayer2.MediaMetadata in project ExoPlayer by google.
the class PictureFrameTest method populateMediaMetadata_setsBuilderValues.
@Test
public void populateMediaMetadata_setsBuilderValues() {
byte[] pictureData = new byte[] { -12, 52, 33, 85, 34, 22, 1, -55 };
Metadata.Entry entry = new PictureFrame(/* pictureType= */
MediaMetadata.PICTURE_TYPE_FRONT_COVER, /* mimeType= */
MimeTypes.IMAGE_JPEG, /* description= */
"an image", /* width= */
4, /* height= */
2, /* depth= */
1, /* colors= */
1, pictureData);
MediaMetadata.Builder builder = MediaMetadata.EMPTY.buildUpon();
entry.populateMediaMetadata(builder);
MediaMetadata mediaMetadata = builder.build();
assertThat(mediaMetadata.artworkData).isEqualTo(pictureData);
assertThat(mediaMetadata.artworkDataType).isEqualTo(MediaMetadata.PICTURE_TYPE_FRONT_COVER);
}
Aggregations