use of com.google.android.exoplayer2.ExoPlayer in project ExoPlayer by google.
the class WavPlaybackTest method test.
@Test
public void test() throws Exception {
Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory = new CapturingRenderersFactory(applicationContext);
ExoPlayer player = new ExoPlayer.Builder(applicationContext, capturingRenderersFactory).setClock(new FakeClock(/* isAutoAdvancing= */
true)).build();
PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory);
player.setMediaItem(MediaItem.fromUri("asset:///media/wav/" + inputFile));
player.prepare();
player.play();
TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED);
player.release();
DumpFileAsserts.assertOutput(ApplicationProvider.getApplicationContext(), playbackOutput, "playbackdumps/wav/" + inputFile + ".dump");
}
use of com.google.android.exoplayer2.ExoPlayer 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.ExoPlayer in project ExoPlayer by google.
the class SilencePlaybackTest method test_0ms.
@Test
public void test_0ms() throws Exception {
Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory = new CapturingRenderersFactory(applicationContext);
ExoPlayer player = new ExoPlayer.Builder(applicationContext, capturingRenderersFactory).setClock(new FakeClock(/* isAutoAdvancing= */
true)).build();
PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory);
player.setMediaSource(new SilenceMediaSource(/* durationUs= */
0));
player.prepare();
player.play();
TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED);
player.release();
DumpFileAsserts.assertOutput(applicationContext, playbackOutput, "playbackdumps/silence/0ms.dump");
}
use of com.google.android.exoplayer2.ExoPlayer in project ExoPlayer by google.
the class Vp9PlaybackTest method test.
@Test
public void test() throws Exception {
Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory = new CapturingRenderersFactory(applicationContext);
ExoPlayer player = new ExoPlayer.Builder(applicationContext, capturingRenderersFactory).setClock(new FakeClock(/* isAutoAdvancing= */
true)).build();
player.setVideoSurface(new Surface(new SurfaceTexture(/* texName= */
1)));
PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory);
player.setMediaItem(MediaItem.fromUri("asset:///media/vp9/" + inputFile));
player.prepare();
player.play();
TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED);
player.release();
DumpFileAsserts.assertOutput(applicationContext, playbackOutput, "playbackdumps/vp9/" + inputFile + ".dump");
}
use of com.google.android.exoplayer2.ExoPlayer in project ExoPlayer by google.
the class DashMediaSource method getAvailableStartTimeInManifestUs.
private static long getAvailableStartTimeInManifestUs(Period period, long periodDurationUs, long nowUnixTimeUs) {
long periodStartTimeInManifestUs = Util.msToUs(period.startMs);
long availableStartTimeInManifestUs = periodStartTimeInManifestUs;
boolean haveAudioVideoAdaptationSets = hasVideoOrAudioAdaptationSets(period);
for (int i = 0; i < period.adaptationSets.size(); i++) {
AdaptationSet adaptationSet = period.adaptationSets.get(i);
List<Representation> representations = adaptationSet.representations;
// or video adaptation set. See: https://github.com/google/ExoPlayer/issues/4029
if ((haveAudioVideoAdaptationSets && adaptationSet.type == C.TRACK_TYPE_TEXT) || representations.isEmpty()) {
continue;
}
@Nullable DashSegmentIndex index = representations.get(0).getIndex();
if (index == null) {
return periodStartTimeInManifestUs;
}
long availableSegmentCount = index.getAvailableSegmentCount(periodDurationUs, nowUnixTimeUs);
if (availableSegmentCount == 0) {
return periodStartTimeInManifestUs;
}
long firstAvailableSegmentNum = index.getFirstAvailableSegmentNum(periodDurationUs, nowUnixTimeUs);
long adaptationSetAvailableStartTimeInManifestUs = periodStartTimeInManifestUs + index.getTimeUs(firstAvailableSegmentNum);
availableStartTimeInManifestUs = max(availableStartTimeInManifestUs, adaptationSetAvailableStartTimeInManifestUs);
}
return availableStartTimeInManifestUs;
}
Aggregations