use of com.google.android.exoplayer2.MediaItem in project ExoPlayer by google.
the class MetadataRetrieverTest method retrieveMetadata_singleMediaItem_outputsExpectedMetadata.
@Test
public void retrieveMetadata_singleMediaItem_outputsExpectedMetadata() throws Exception {
MediaItem mediaItem = MediaItem.fromUri(Uri.parse("asset://android_asset/media/mp4/sample.mp4"));
ListenableFuture<TrackGroupArray> trackGroupsFuture = retrieveMetadata(context, mediaItem, clock);
ShadowLooper.idleMainLooper();
TrackGroupArray trackGroups = trackGroupsFuture.get(TEST_TIMEOUT_SEC, TimeUnit.SECONDS);
assertThat(trackGroups.length).isEqualTo(2);
// Video group.
assertThat(trackGroups.get(0).length).isEqualTo(1);
assertThat(trackGroups.get(0).getFormat(0).sampleMimeType).isEqualTo(MimeTypes.VIDEO_H264);
// Audio group.
assertThat(trackGroups.get(1).length).isEqualTo(1);
assertThat(trackGroups.get(1).getFormat(0).sampleMimeType).isEqualTo(MimeTypes.AUDIO_AAC);
}
use of com.google.android.exoplayer2.MediaItem in project ExoPlayer by google.
the class WebvttPlaybackTest method test.
@Test
public void test() throws Exception {
Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory = new CapturingRenderersFactory(applicationContext);
MediaSource.Factory mediaSourceFactory = new DefaultMediaSourceFactory(applicationContext).experimentalUseProgressiveMediaSourceForSubtitles(true);
ExoPlayer player = new ExoPlayer.Builder(applicationContext, capturingRenderersFactory).setClock(new FakeClock(/* isAutoAdvancing= */
true)).setMediaSourceFactory(mediaSourceFactory).build();
player.setVideoSurface(new Surface(new SurfaceTexture(/* texName= */
1)));
PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory);
MediaItem mediaItem = new MediaItem.Builder().setUri("asset:///media/mp4/preroll-5s.mp4").setSubtitleConfigurations(ImmutableList.of(new MediaItem.SubtitleConfiguration.Builder(Uri.parse("asset:///media/webvtt/" + inputFile)).setMimeType(MimeTypes.TEXT_VTT).setLanguage("en").setSelectionFlags(C.SELECTION_FLAG_DEFAULT).build())).build();
player.setMediaItem(mediaItem);
player.prepare();
player.play();
TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED);
player.release();
DumpFileAsserts.assertOutput(applicationContext, playbackOutput, "playbackdumps/webvtt/" + inputFile + ".dump");
}
use of com.google.android.exoplayer2.MediaItem in project ExoPlayer by google.
the class DashMediaSourceTest method prepare_withCompleteServiceDescription_withMediaItemLiveProperties_usesMediaItem.
@Test
public void prepare_withCompleteServiceDescription_withMediaItemLiveProperties_usesMediaItem() throws InterruptedException {
MediaItem mediaItem = new MediaItem.Builder().setUri(Uri.EMPTY).setLiveConfiguration(new MediaItem.LiveConfiguration.Builder().setTargetOffsetMs(876L).setMinPlaybackSpeed(23f).setMaxPlaybackSpeed(42f).setMinOffsetMs(100L).setMaxOffsetMs(999L).build()).build();
DashMediaSource mediaSource = new DashMediaSource.Factory(() -> createSampleMpdDataSource(SAMPLE_MPD_LIVE_WITH_COMPLETE_SERVICE_DESCRIPTION)).setFallbackTargetLiveOffsetMs(1234L).createMediaSource(mediaItem);
MediaItem.LiveConfiguration liveConfiguration = prepareAndWaitForTimelineRefresh(mediaSource).liveConfiguration;
assertThat(liveConfiguration.targetOffsetMs).isEqualTo(876L);
assertThat(liveConfiguration.minOffsetMs).isEqualTo(100L);
assertThat(liveConfiguration.maxOffsetMs).isEqualTo(999L);
assertThat(liveConfiguration.minPlaybackSpeed).isEqualTo(23f);
assertThat(liveConfiguration.maxPlaybackSpeed).isEqualTo(42f);
}
use of com.google.android.exoplayer2.MediaItem in project ExoPlayer by google.
the class DashMediaSourceTest method prepare_withoutLiveConfiguration_withMediaItemLiveProperties_usesMediaItem.
@Test
public void prepare_withoutLiveConfiguration_withMediaItemLiveProperties_usesMediaItem() throws InterruptedException {
MediaItem mediaItem = new MediaItem.Builder().setUri(Uri.EMPTY).setLiveConfiguration(new MediaItem.LiveConfiguration.Builder().setTargetOffsetMs(876L).setMinPlaybackSpeed(23f).setMaxPlaybackSpeed(42f).setMinOffsetMs(500L).setMaxOffsetMs(20_000L).build()).build();
DashMediaSource mediaSource = new DashMediaSource.Factory(() -> createSampleMpdDataSource(SAMPLE_MPD_LIVE_WITHOUT_LIVE_CONFIGURATION)).setFallbackTargetLiveOffsetMs(1234L).createMediaSource(mediaItem);
MediaItem.LiveConfiguration liveConfiguration = prepareAndWaitForTimelineRefresh(mediaSource).liveConfiguration;
assertThat(liveConfiguration).isEqualTo(mediaItem.liveConfiguration);
}
use of com.google.android.exoplayer2.MediaItem in project ExoPlayer by google.
the class DashMediaSourceTest method factorySetFallbackTargetLiveOffsetMs_doesNotChangeMediaItem.
@Test
public void factorySetFallbackTargetLiveOffsetMs_doesNotChangeMediaItem() {
DashMediaSource.Factory factory = new DashMediaSource.Factory(new FileDataSource.Factory()).setFallbackTargetLiveOffsetMs(2000L);
MediaItem dashMediaItem = factory.createMediaSource(MediaItem.fromUri(Uri.EMPTY)).getMediaItem();
assertThat(dashMediaItem.liveConfiguration.targetOffsetMs).isEqualTo(C.TIME_UNSET);
}
Aggregations