Skip to content

Instantly share code, notes, and snippets.

Created January 8, 2018 07:49
Show Gist options
  • Save Pulimet/3d6658a2c442c7e0dcf18a2f16518248 to your computer and use it in GitHub Desktop.
Save Pulimet/3d6658a2c442c7e0dcf18a2f16518248 to your computer and use it in GitHub Desktop.
public class DashTestActivity extends AppCompatActivity {
public static final String DASH_SAMPLE = "";
protected void onCreate(Bundle savedInstanceState) {
SimpleExoPlayerView exoPlayerView = findViewById(;
// Measures bandwidth during playback. Can be null if not required.
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
// Produces DataSource instances through which media data is loaded.
DefaultDataSourceFactory mDataSourceFactory = new DefaultDataSourceFactory(this,
Util.getUserAgent(this, getString(R.string.app_name)), bandwidthMeter);
// TrackSelector that selects tracks provided by the MediaSource to be consumed by each of the available Renderer's.
// A TrackSelector is injected when the exoPlayer is created.
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
DefaultTrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
DefaultRenderersFactory renderersFactory = new DefaultRenderersFactory(this,
null, DefaultRenderersFactory.EXTENSION_RENDERER_MODE_OFF);
SimpleExoPlayer exoPlayer = ExoPlayerFactory.newSimpleInstance(renderersFactory, trackSelector);
Uri uri = Uri.parse(DASH_SAMPLE);
DashMediaSource dashMediaSource = new DashMediaSource(uri, mDataSourceFactory,
new DefaultDashChunkSource.Factory(mDataSourceFactory), null, null);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment