implementation 'com.google.android.exoplayer:exoplayer:2.12.0'
创建一个 res/raw 目录(如果没有),并将 .m3u8 或 .mpd 播放列表文件放入该目录中。
创建一个播放列表对象,例如:
MediaItem firstItem = MediaItem.fromUri("asset:///test1.mp4");
MediaItem secondItem = MediaItem.fromUri("asset:///test2.mp4");
List mediaItems = new ArrayList<>();
mediaItems.add(firstItem);
mediaItems.add(secondItem);
ConcatenatingMediaSource mediaSource = new ConcatenatingMediaSource();
mediaSource.addMediaSources(mediaItems);
SimpleExoPlayer player = new SimpleExoPlayer.Builder(context).build();
player.setMediaSource(mediaSource);
player.prepare();
PlayerView playerView = findViewById(R.id.player_view);
playerView.setPlayer(player);
DefaultHttpDataSourceFactory factory =
new DefaultHttpDataSourceFactory(Util.getUserAgent(context, "your-application-name"));
DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(context, null, factory);
Uri uri = Uri.parse("http://example.com/video.mp4");
MediaSource mediaSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(uri);
MergingMediaSource mergedSource =
new MergingMediaSource(mediaSource,