在ExoPlayer 2.18.5中,getSelectedTrack函数已被删除。取而代之的是使用getSelectedFormat函数来获取当前选中的Track的Format。这个函数返回当前选中的Track的Format,如果没有选中的Track,则返回null。

要判断一个TrackGroup是否被选中,可以使用以下代码:

TrackGroupArray trackGroups = trackSelector.getCurrentMappedTrackInfo().getTrackGroups(rendererIndex);
TrackGroup trackGroup = trackGroups.get(groupIndex);
int selectedIndex = trackSelector.getCurrentMappedTrackInfo().getSelectedTrackIndex(rendererIndex, groupIndex);
boolean isSelected = (selectedIndex != C.INDEX_UNSET && trackGroup.length > 0 && trackGroup.getFormat(selectedIndex) != null);

其中,rendererIndex是渲染器的索引,groupIndex是TrackGroup的索引。isSelected变量将会是true,如果选中了该TrackGroup,否则为false

exoplayer2185 getSelectedTrack函数被删除了 如何替代如何判断trackGroup 是否被选中

原文地址: http://www.cveoy.top/t/topic/ciKk 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录