use of com.google.android.exoplayer2.trackselection.TrackSelector in project PreviewSeekBar by rubensousa.
the class ExoPlayerManager method createFullPlayer.
private SimpleExoPlayer createFullPlayer() {
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
LoadControl loadControl = new DefaultLoadControl();
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(new DefaultRenderersFactory(playerView.getContext()), trackSelector, loadControl);
player.setPlayWhenReady(true);
player.prepare(mediaSourceBuilder.getMediaSource(false));
player.addListener(eventListener);
return player;
}
use of com.google.android.exoplayer2.trackselection.TrackSelector in project ExoPlayer by google.
the class ExoHostedTest method buildExoPlayer.
protected ExoPlayer buildExoPlayer(HostActivity host, Surface surface, MappingTrackSelector trackSelector) {
DefaultRenderersFactory renderersFactory = new DefaultRenderersFactory(host);
renderersFactory.setExtensionRendererMode(DefaultRenderersFactory.EXTENSION_RENDERER_MODE_OFF);
renderersFactory.setAllowedVideoJoiningTimeMs(/* allowedVideoJoiningTimeMs= */
0);
ExoPlayer player = new ExoPlayer.Builder(host, renderersFactory).setTrackSelector(trackSelector).build();
player.setVideoSurface(surface);
return player;
}
use of com.google.android.exoplayer2.trackselection.TrackSelector in project ExoPlayer by google.
the class ExoHostedTest method onStart.
// HostedTest implementation
@Override
public final void onStart(HostActivity host, Surface surface, FrameLayout overlayFrameLayout) {
this.surface = surface;
// Build the player.
trackSelector = buildTrackSelector(host);
player = buildExoPlayer(host, surface, trackSelector);
player.play();
player.addAnalyticsListener(this);
player.addAnalyticsListener(new EventLogger(trackSelector, tag));
// Schedule any pending actions.
actionHandler = Clock.DEFAULT.createHandler(Util.getCurrentOrMainLooper(), /* callback= */
null);
if (pendingSchedule != null) {
pendingSchedule.start(player, trackSelector, surface, actionHandler, /* callback= */
null);
pendingSchedule = null;
}
DrmSessionManager drmSessionManager = buildDrmSessionManager();
player.setMediaSource(buildSource(host, drmSessionManager, overlayFrameLayout));
player.prepare();
}
use of com.google.android.exoplayer2.trackselection.TrackSelector in project ExoPlayer by google.
the class ExoPlayerTest method allActivatedTrackSelectionAreReleasedForMultiPeriods.
@Test
public void allActivatedTrackSelectionAreReleasedForMultiPeriods() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */
2);
MediaSource mediaSource = new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT, ExoPlayerTestRunner.AUDIO_FORMAT);
FakeRenderer videoRenderer = new FakeRenderer(C.TRACK_TYPE_VIDEO);
FakeRenderer audioRenderer = new FakeRenderer(C.TRACK_TYPE_AUDIO);
FakeTrackSelector trackSelector = new FakeTrackSelector();
new ExoPlayerTestRunner.Builder(context).setMediaSources(mediaSource).setRenderers(videoRenderer, audioRenderer).setTrackSelector(trackSelector).build().start().blockUntilEnded(TIMEOUT_MS);
List<FakeTrackSelection> createdTrackSelections = trackSelector.getAllTrackSelections();
int numSelectionsEnabled = 0;
// Assert that all tracks selection are disabled at the end of the playback.
for (FakeTrackSelection trackSelection : createdTrackSelections) {
assertThat(trackSelection.isEnabled).isFalse();
numSelectionsEnabled += trackSelection.enableCount;
}
// There are 2 renderers, and track selections are made twice (2 periods).
assertThat(createdTrackSelections).hasSize(4);
assertThat(numSelectionsEnabled).isEqualTo(4);
}
use of com.google.android.exoplayer2.trackselection.TrackSelector in project ExoPlayer by google.
the class Transformer method startTransformation.
private void startTransformation(MediaItem mediaItem, Muxer muxer) {
verifyApplicationThread();
if (player != null) {
throw new IllegalStateException("There is already a transformation in progress.");
}
MuxerWrapper muxerWrapper = new MuxerWrapper(muxer, muxerFactory, containerMimeType);
this.muxerWrapper = muxerWrapper;
DefaultTrackSelector trackSelector = new DefaultTrackSelector(context);
trackSelector.setParameters(new DefaultTrackSelector.ParametersBuilder(context).setForceHighestSupportedBitrate(true).build());
// Arbitrarily decrease buffers for playback so that samples start being sent earlier to the
// muxer (rebuffers are less problematic for the transformation use case).
DefaultLoadControl loadControl = new DefaultLoadControl.Builder().setBufferDurationsMs(DEFAULT_MIN_BUFFER_MS, DEFAULT_MAX_BUFFER_MS, DEFAULT_BUFFER_FOR_PLAYBACK_MS / 10, DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS / 10).build();
ExoPlayer.Builder playerBuilder = new ExoPlayer.Builder(context, new TransformerRenderersFactory(context, muxerWrapper, removeAudio, removeVideo, transformationRequest, encoderFactory, decoderFactory, new FallbackListener(mediaItem, listeners, transformationRequest), debugViewProvider)).setMediaSourceFactory(mediaSourceFactory).setTrackSelector(trackSelector).setLoadControl(loadControl).setLooper(looper);
if (clock != Clock.DEFAULT) {
// Transformer.Builder#setClock is also @VisibleForTesting, so if we're using a non-default
// clock we must be in a test context.
@SuppressWarnings("VisibleForTests") ExoPlayer.Builder unusedForAnnotation = playerBuilder.setClock(clock);
}
player = playerBuilder.build();
player.setMediaItem(mediaItem);
player.addListener(new TransformerPlayerListener(mediaItem, muxerWrapper));
player.prepare();
progressState = PROGRESS_STATE_WAITING_FOR_AVAILABILITY;
}
Aggregations