Ответ 1
Вот простой пример игры с тире, который будет воспроизводить содержимое вашего потока в SimpleExoPlayerView
от exoplayer-ui
.
Добавьте SimpleExoPlayerView
в свой макет и используйте код ниже
SimpleExoPlayerView exoPlayerView = (SimpleExoPlayerView) findViewById(R.id.exo_player_view);
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "ExoPlayer"));
Uri uri = Uri.parse("http://your_host/dash/stream.mpd");
DashMediaSource dashMediaSource = new DashMediaSource(uri, dataSourceFactory,
new DefaultDashChunkSource.Factory(dataSourceFactory), null, null);
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelector trackSelector = new DefaultTrackSelector(new AdaptiveTrackSelection.Factory(bandwidthMeter));
SimpleExoPlayer simpleExoPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
exoPlayerView.setPlayer(simpleExoPlayer);
simpleExoPlayer.prepare(dashMediaSource);
Также добавьте зависимости к вашему build.gradle
compile 'com.google.android.exoplayer:exoplayer-core:r2.4.0'
compile 'com.google.android.exoplayer:exoplayer-dash:r2.4.0'
compile 'com.google.android.exoplayer:exoplayer-hls:r2.4.0'
compile 'com.google.android.exoplayer:exoplayer-smoothstreaming:r2.4.0'
compile 'com.google.android.exoplayer:exoplayer-ui:r2.4.0'