Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class DashTestActivity extends AppCompatActivity {
public static final String DASH_SAMPLE = "http://www.bok.net/dash/tears_of_steel/cleartext/stream.mpd";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dash_test);
SimpleExoPlayerView exoPlayerView = findViewById(R.id.exoPlayerView);
// 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);
exoPlayerView.setPlayer(exoPlayer);
Uri uri = Uri.parse(DASH_SAMPLE);
DashMediaSource dashMediaSource = new DashMediaSource(uri, mDataSourceFactory,
new DefaultDashChunkSource.Factory(mDataSourceFactory), null, null);
exoPlayer.prepare(dashMediaSource);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment