我正在尝试在单击按钮时实现 exoplayer 将播放连接列表中的下一个视频 但它只播放第一个视频而不播放其他四个我做错了什么
next_button.setOnClickListener(v ->
{
releasePlayer();
DefaultDataSourceFactory defaultDataSourceFactory = new DefaultDataSourceFactory(this, userAgent);
MediaSource firstSource =
new HlsMediaSource.Factory(defaultDataSourceFactory).createMediaSource(MediaItem.fromUri(firstVideoUri));
MediaSource secondSource =
new HlsMediaSource.Factory(defaultDataSourceFactory).createMediaSource(MediaItem.fromUri(secondVideoUri));
MediaSource third =
new HlsMediaSource.Factory(defaultDataSourceFactory).createMediaSource(MediaItem.fromUri(third_url));
MediaSource fourth =
new HlsMediaSource.Factory(defaultDataSourceFactory).createMediaSource(MediaItem.fromUri(fourth_url));
ConcatenatingMediaSource concatenatedSource =
new ConcatenatingMediaSource(firstSource, secondSource, third, fourth);
initializePlayer_concate(concatenatedSource);
});
添加我的 initilizeplayer 方法
void initializePlayer_concate(MediaSource concatenatedSource) {
ExoTrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory();
trackSelector = new DefaultTrackSelector(Player.this, videoTrackSelectionFactory);
DefaultRenderersFactory renderersFactory = new DefaultRenderersFactory(this);
renderersFactory.setExtensionRendererMode(DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER);
simpleExoPlayer = new SimpleExoPlayer.Builder(this, renderersFactory).setTrackSelector(trackSelector).setSeekForwardIncrementMs(10000).setSeekBackIncrementMs(10000).build();
playerView.setPlayer(simpleExoPlayer);
simpleExoPlayer.setMediaSource(concatenatedSource);
playerView.setKeepScreenOn(true);
simpleExoPlayer.prepare();
simpleExoPlayer.setPlayWhenReady(true);
}
如果有人告诉我我做错了什么就好了