Java Code Examples for com.google.android.exoplayer2.DefaultLoadControl#Builder
The following examples show how to use
com.google.android.exoplayer2.DefaultLoadControl#Builder .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExoPlayerHelper.java From ExoPlayer-Wrapper with Apache License 2.0 | 6 votes |
private void init() { // Measures bandwidth during playback. Can be null if not required. DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter.Builder(mContext).build(); // Produces DataSource instances through which media data is loaded. mDataSourceFactory = new DefaultDataSourceFactory(mContext, Util.getUserAgent(mContext, mContext.getString(R.string.app_name)), bandwidthMeter); // LoadControl that controls when the MediaSource buffers more media, and how much media is buffered. // LoadControl is injected when the player is created. //removed deprecated DefaultLoadControl creation method DefaultLoadControl.Builder builder = new DefaultLoadControl.Builder(); builder.setAllocator(new DefaultAllocator(true, 2 * 1024 * 1024)); builder.setBufferDurationsMs(5000, 5000, 5000, 5000); builder.setPrioritizeTimeOverSizeThresholds(true); mLoadControl = builder.createDefaultLoadControl(); }
Example 2
Source File: BufferSizeAdaptationBuilder.java From MediaSDK with Apache License 2.0 | 4 votes |
/** * Builds player components for buffer size based track adaptation. * * @return A pair of a {@link TrackSelection.Factory} and a {@link LoadControl}, which should be * used to construct the player. */ public Pair<TrackSelection.Factory, LoadControl> buildPlayerComponents() { Assertions.checkArgument(hysteresisBufferMs < maxBufferMs - minBufferMs); Assertions.checkState(!buildCalled); buildCalled = true; DefaultLoadControl.Builder loadControlBuilder = new DefaultLoadControl.Builder() .setTargetBufferBytes(/* targetBufferBytes = */ Integer.MAX_VALUE) .setBufferDurationsMs( /* minBufferMs= */ maxBufferMs, maxBufferMs, bufferForPlaybackMs, bufferForPlaybackAfterRebufferMs); if (allocator != null) { loadControlBuilder.setAllocator(allocator); } TrackSelection.Factory trackSelectionFactory = new TrackSelection.Factory() { @Override public @NullableType TrackSelection[] createTrackSelections( @NullableType Definition[] definitions, BandwidthMeter bandwidthMeter) { return TrackSelectionUtil.createTrackSelectionsForDefinitions( definitions, definition -> new BufferSizeAdaptiveTrackSelection( definition.group, definition.tracks, bandwidthMeter, minBufferMs, maxBufferMs, hysteresisBufferMs, startUpBandwidthFraction, startUpMinBufferForQualityIncreaseMs, dynamicFormatFilter, clock)); } }; return Pair.create(trackSelectionFactory, loadControlBuilder.createDefaultLoadControl()); }
Example 3
Source File: BufferSizeAdaptationBuilder.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
/** * Builds player components for buffer size based track adaptation. * * @return A pair of a {@link TrackSelection.Factory} and a {@link LoadControl}, which should be * used to construct the player. */ public Pair<TrackSelection.Factory, LoadControl> buildPlayerComponents() { Assertions.checkArgument(hysteresisBufferMs < maxBufferMs - minBufferMs); Assertions.checkState(!buildCalled); buildCalled = true; DefaultLoadControl.Builder loadControlBuilder = new DefaultLoadControl.Builder() .setTargetBufferBytes(/* targetBufferBytes = */ Integer.MAX_VALUE) .setBufferDurationsMs( /* minBufferMs= */ maxBufferMs, maxBufferMs, bufferForPlaybackMs, bufferForPlaybackAfterRebufferMs); if (allocator != null) { loadControlBuilder.setAllocator(allocator); } TrackSelection.Factory trackSelectionFactory = new TrackSelection.Factory() { @Override public @NullableType TrackSelection[] createTrackSelections( @NullableType Definition[] definitions, BandwidthMeter bandwidthMeter) { return TrackSelectionUtil.createTrackSelectionsForDefinitions( definitions, definition -> new BufferSizeAdaptiveTrackSelection( definition.group, definition.tracks, bandwidthMeter, minBufferMs, maxBufferMs, hysteresisBufferMs, startUpBandwidthFraction, startUpMinBufferForQualityIncreaseMs, dynamicFormatFilter, clock)); } }; return Pair.create(trackSelectionFactory, loadControlBuilder.createDefaultLoadControl()); }
Example 4
Source File: BufferSizeAdaptationBuilder.java From Telegram with GNU General Public License v2.0 | 4 votes |
/** * Builds player components for buffer size based track adaptation. * * @return A pair of a {@link TrackSelection.Factory} and a {@link LoadControl}, which should be * used to construct the player. */ public Pair<TrackSelection.Factory, LoadControl> buildPlayerComponents() { Assertions.checkArgument(hysteresisBufferMs < maxBufferMs - minBufferMs); Assertions.checkState(!buildCalled); buildCalled = true; DefaultLoadControl.Builder loadControlBuilder = new DefaultLoadControl.Builder() .setTargetBufferBytes(/* targetBufferBytes = */ Integer.MAX_VALUE) .setBufferDurationsMs( /* minBufferMs= */ maxBufferMs, maxBufferMs, bufferForPlaybackMs, bufferForPlaybackAfterRebufferMs); if (allocator != null) { loadControlBuilder.setAllocator(allocator); } TrackSelection.Factory trackSelectionFactory = new TrackSelection.Factory() { @Override public @NullableType TrackSelection[] createTrackSelections( @NullableType Definition[] definitions, BandwidthMeter bandwidthMeter) { return TrackSelectionUtil.createTrackSelectionsForDefinitions( definitions, definition -> new BufferSizeAdaptiveTrackSelection( definition.group, definition.tracks, bandwidthMeter, minBufferMs, maxBufferMs, hysteresisBufferMs, startUpBandwidthFraction, startUpMinBufferForQualityIncreaseMs, dynamicFormatFilter, clock)); } }; return Pair.create(trackSelectionFactory, loadControlBuilder.createDefaultLoadControl()); }