use of androidx.media3.exoplayer.RenderersFactory in project media by androidx.
the class SampleChooserActivity method onSampleDownloadButtonClicked.
private void onSampleDownloadButtonClicked(PlaylistHolder playlistHolder) {
int downloadUnsupportedStringId = getDownloadUnsupportedStringId(playlistHolder);
if (downloadUnsupportedStringId != 0) {
Toast.makeText(getApplicationContext(), downloadUnsupportedStringId, Toast.LENGTH_LONG).show();
} else {
RenderersFactory renderersFactory = DemoUtil.buildRenderersFactory(/* context= */
this, isNonNullAndChecked(preferExtensionDecodersMenuItem));
downloadTracker.toggleDownload(getSupportFragmentManager(), playlistHolder.mediaItems.get(0), renderersFactory);
}
}
use of androidx.media3.exoplayer.RenderersFactory in project media by androidx.
the class DownloadHelper method getRendererCapabilities.
/**
* Extracts renderer capabilities for the renderers created by the provided renderers factory.
*
* @param renderersFactory A {@link RenderersFactory}.
* @return The {@link RendererCapabilities} for each renderer created by the {@code
* renderersFactory}.
*/
public static RendererCapabilities[] getRendererCapabilities(RenderersFactory renderersFactory) {
Renderer[] renderers = renderersFactory.createRenderers(Util.createHandlerForCurrentOrMainLooper(), new VideoRendererEventListener() {
}, new AudioRendererEventListener() {
}, (cues) -> {
}, (metadata) -> {
});
RendererCapabilities[] capabilities = new RendererCapabilities[renderers.length];
for (int i = 0; i < renderers.length; i++) {
capabilities[i] = renderers[i].getCapabilities();
}
return capabilities;
}
use of androidx.media3.exoplayer.RenderersFactory in project media by androidx.
the class DefaultAnalyticsCollectorTest method onPlayerError_thrownDuringRenderAtPeriodTransition_isReportedForNewPeriod.
@Test
public void onPlayerError_thrownDuringRenderAtPeriodTransition_isReportedForNewPeriod() throws Exception {
FakeMediaSource source0 = new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT);
FakeMediaSource source1 = new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.AUDIO_FORMAT);
RenderersFactory renderersFactory = (eventHandler, videoListener, audioListener, textOutput, metadataOutput) -> new Renderer[] { new FakeRenderer(C.TRACK_TYPE_VIDEO), new FakeRenderer(C.TRACK_TYPE_AUDIO) {
@Override
public void render(long positionUs, long realtimeUs) throws ExoPlaybackException {
// transition.
throw createRendererException(new IllegalStateException(), ExoPlayerTestRunner.AUDIO_FORMAT, PlaybackException.ERROR_CODE_UNSPECIFIED);
}
} };
TestAnalyticsListener listener = runAnalyticsTest(new ConcatenatingMediaSource(source0, source1), /* actionSchedule= */
null, renderersFactory);
populateEventIds(listener.lastReportedTimeline);
assertThat(listener.getEvents(EVENT_PLAYER_ERROR)).containsExactly(period1);
}
use of androidx.media3.exoplayer.RenderersFactory in project media by androidx.
the class DefaultAnalyticsCollectorTest method runAnalyticsTest.
private static TestAnalyticsListener runAnalyticsTest(MediaSource mediaSource, @Nullable ActionSchedule actionSchedule, RenderersFactory renderersFactory) throws Exception {
Surface surface = new Surface(new SurfaceTexture(/* texName= */
0));
TestAnalyticsListener listener = new TestAnalyticsListener();
try {
new ExoPlayerTestRunner.Builder(ApplicationProvider.getApplicationContext()).setMediaSources(mediaSource).setRenderersFactory(renderersFactory).setVideoSurface(surface).setAnalyticsListener(listener).setActionSchedule(actionSchedule).build().start().blockUntilActionScheduleFinished(TIMEOUT_MS).blockUntilEnded(TIMEOUT_MS);
} catch (ExoPlaybackException e) {
// Ignore ExoPlaybackException as these may be expected.
} finally {
surface.release();
}
return listener;
}
use of androidx.media3.exoplayer.RenderersFactory in project media by androidx.
the class DefaultAnalyticsCollectorTest method onPlayerError_thrownDuringRendererEnableAtPeriodTransition_isReportedForNewPeriod.
@Test
public void onPlayerError_thrownDuringRendererEnableAtPeriodTransition_isReportedForNewPeriod() throws Exception {
FakeMediaSource source0 = new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT);
FakeMediaSource source1 = new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.AUDIO_FORMAT);
RenderersFactory renderersFactory = (eventHandler, videoListener, audioListener, textOutput, metadataOutput) -> new Renderer[] { new FakeRenderer(C.TRACK_TYPE_VIDEO), new FakeRenderer(C.TRACK_TYPE_AUDIO) {
@Override
protected void onEnabled(boolean joining, boolean mayRenderStartOfStream) throws ExoPlaybackException {
// Fail when enabling the renderer. This will happen during the period transition.
throw createRendererException(new IllegalStateException(), ExoPlayerTestRunner.AUDIO_FORMAT, PlaybackException.ERROR_CODE_UNSPECIFIED);
}
} };
TestAnalyticsListener listener = runAnalyticsTest(new ConcatenatingMediaSource(source0, source1), /* actionSchedule= */
null, renderersFactory);
populateEventIds(listener.lastReportedTimeline);
assertThat(listener.getEvents(EVENT_PLAYER_ERROR)).containsExactly(period1);
}
Aggregations