雕·不懒惰 Android  03月31日
exoplayer2音轨切换MappedTrackInfo.getTrackGroups(int)' on a null object reference

private void initializePlayer() {
trackSelector = new DefaultTrackSelector();
MappingTrackSelector.MappedTrackInfo trackInfo = trackSelector.getCurrentMappedTrackInfo();
if (trackInfo == null)
return;

DefaultTrackSelector.Parameters parameters = trackSelector.getParameters().buildUpon()
.setSelectionOverride(1, trackInfo.getTrackGroups(1),
new DefaultTrackSelector.SelectionOverride(1, 1))
.build();
trackSelector.setParameters(parameters);

player = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
playerView.setPlayer(player);
player.setPlayWhenReady(true);
player.seekTo(currentWindow, playbackPosition);
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this,
Util.getUserAgent(this, "ExoPlayer"));
Uri uri = Uri.parse(Environment.getExternalStorageDirectory() + "/Movies/3dall.mp4");
MediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
.createMediaSource(uri);
player.prepare(videoSource);
}

第一次用ExoPlayer
实现视频的语言切换,trackInfo 一直是null
new DefaultTrackSelector.SelectionOverride(int groupIndex, int... tracks)中的参数一直没搞明白是什么
第一个是语言索引?第二个是什么
...全文
100 点赞 收藏 3
写回复
3 条回复

还没有回复,快来抢沙发~

发动态
发帖子
Android
创建于2009-10-09

4.6w+

社区成员

9.0w+

社区内容

移动平台 Android
社区公告
暂无公告