Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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