本文整理汇总了Java中com.google.android.exoplayer2.trackselection.MappingTrackSelector.SelectionOverride方法的典型用法代码示例。如果您正苦于以下问题:Java MappingTrackSelector.SelectionOverride方法的具体用法?Java MappingTrackSelector.SelectionOverride怎么用?Java MappingTrackSelector.SelectionOverride使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.exoplayer2.trackselection.MappingTrackSelector
的用法示例。
在下文中一共展示了MappingTrackSelector.SelectionOverride方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSelectedTrackIndex
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入方法依赖的package包/类
public int getSelectedTrackIndex(@NonNull RendererType type) {
// Retrieves the available tracks
int exoPlayerTrackIndex = getExoPlayerTrackType(type);
MappingTrackSelector.MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo();
TrackGroupArray trackGroupArray = mappedTrackInfo == null ? null : mappedTrackInfo.getTrackGroups(exoPlayerTrackIndex);
if (trackGroupArray == null || trackGroupArray.length == 0) {
return -1;
}
// Verifies the track selection has been overridden
MappingTrackSelector.SelectionOverride selectionOverride = trackSelector.getSelectionOverride(exoPlayerTrackIndex, trackGroupArray);
if (selectionOverride == null || selectionOverride.groupIndex != exoPlayerTrackIndex || selectionOverride.length <= 0) {
return -1;
}
return selectionOverride.tracks[0];
}
示例2: setSelectedTrack
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入方法依赖的package包/类
public void setSelectedTrack(@NonNull RendererType type, int index) {
// Retrieves the available tracks
int exoPlayerTrackIndex = getExoPlayerTrackType(type);
MappingTrackSelector.MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo();
TrackGroupArray trackGroupArray = mappedTrackInfo == null ? null : mappedTrackInfo.getTrackGroups(exoPlayerTrackIndex);
if (trackGroupArray == null || trackGroupArray.length == 0) {
return;
}
// Creates the track selection override
int[] tracks = new int[] {index};
TrackSelection.Factory factory = tracks.length == 1 ? new FixedTrackSelection.Factory() : adaptiveTrackSelectionFactory;
MappingTrackSelector.SelectionOverride selectionOverride = new MappingTrackSelector.SelectionOverride(factory, exoPlayerTrackIndex, tracks);
// Specifies the correct track to use
trackSelector.setSelectionOverride(exoPlayerTrackIndex, trackGroupArray, selectionOverride);
}
示例3: getTracksRemoving
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入方法依赖的package包/类
private static int[] getTracksRemoving(@NonNull MappingTrackSelector.SelectionOverride override, int removedTrack) {
int[] tracks = new int[override.length - 1];
int trackCount = 0;
for (int i = 0; i < tracks.length + 1; i++) {
int track = override.tracks[i];
if (track != removedTrack) {
tracks[trackCount++] = track;
}
}
return tracks;
}
示例4: selectAudioTrack
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入方法依赖的package包/类
public boolean selectAudioTrack(PlayerAudioTrack audioTrack, RendererTypeRequester rendererTypeRequester) {
TrackGroupArray trackGroups = trackSelector.trackGroups(AUDIO, rendererTypeRequester);
MappingTrackSelector.SelectionOverride selectionOverride = new MappingTrackSelector.SelectionOverride(
trackSelectionFactory,
audioTrack.groupIndex(),
audioTrack.formatIndex()
);
return trackSelector.setSelectionOverride(AUDIO, rendererTypeRequester, trackGroups, selectionOverride);
}
示例5: setSelectionOverride
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入方法依赖的package包/类
boolean setSelectionOverride(TrackType trackType,
RendererTypeRequester rendererTypeRequester,
TrackGroupArray trackGroups,
MappingTrackSelector.SelectionOverride selectionOverride) {
Optional<Integer> rendererIndex = rendererTrackIndexExtractor.extract(trackType, mappedTrackInfoLength(), rendererTypeRequester);
if (rendererIndex.isPresent()) {
trackSelector.setSelectionOverride(rendererIndex.get(), trackGroups, selectionOverride);
return true;
} else {
return false;
}
}
示例6: selectVideoTrack
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入方法依赖的package包/类
public boolean selectVideoTrack(PlayerVideoTrack videoTrack, RendererTypeRequester rendererTypeRequester) {
TrackGroupArray trackGroups = trackSelector.trackGroups(VIDEO, rendererTypeRequester);
MappingTrackSelector.SelectionOverride selectionOverride = new MappingTrackSelector.SelectionOverride(
trackSelectionFactory,
videoTrack.groupIndex(),
videoTrack.formatIndex()
);
return trackSelector.setSelectionOverride(VIDEO, rendererTypeRequester, trackGroups, selectionOverride);
}
示例7: selectTextTrack
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入方法依赖的package包/类
public boolean selectTextTrack(PlayerSubtitleTrack subtitleTrack, RendererTypeRequester rendererTypeRequester) {
TrackGroupArray trackGroups = trackSelector.trackGroups(TEXT, rendererTypeRequester);
MappingTrackSelector.SelectionOverride selectionOverride = new MappingTrackSelector.SelectionOverride(
trackSelectionFactory,
subtitleTrack.groupIndex(),
subtitleTrack.formatIndex()
);
return trackSelector.setSelectionOverride(TEXT, rendererTypeRequester, trackGroups, selectionOverride);
}
示例8: givenTrackSelectorContainsTracks_whenSelectingAudioTrack_thenSelectsTrack
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入方法依赖的package包/类
@Test
public void givenTrackSelectorContainsTracks_whenSelectingAudioTrack_thenSelectsTrack() {
TrackGroupArray trackGroups = givenTrackSelectorContainsTracks();
ArgumentCaptor<MappingTrackSelector.SelectionOverride> argumentCaptor = whenSelectingAudioTrack(trackGroups);
MappingTrackSelector.SelectionOverride selectionOverride = argumentCaptor.getValue();
assertThat(selectionOverride.factory).isEqualTo(trackSelectionFactory);
assertThat(selectionOverride.groupIndex).isEqualTo(SECOND_GROUP);
assertThat(selectionOverride.tracks).contains(THIRD_TRACK);
}
示例9: whenSelectingAudioTrack
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入方法依赖的package包/类
private ArgumentCaptor<MappingTrackSelector.SelectionOverride> whenSelectingAudioTrack(TrackGroupArray trackGroups) {
exoPlayerAudioTrackSelector.selectAudioTrack(AUDIO_TRACK, rendererTypeRequester);
ArgumentCaptor<MappingTrackSelector.SelectionOverride> argumentCaptor = ArgumentCaptor.forClass(MappingTrackSelector.SelectionOverride.class);
verify(trackSelector).setSelectionOverride(eq(TrackType.AUDIO), any(RendererTypeRequester.class), eq(trackGroups), argumentCaptor.capture());
return argumentCaptor;
}
示例10: givenTrackSelectorContainsTracks_whenSelectingVideoTrack_thenSelectsTrack
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入方法依赖的package包/类
@Test
public void givenTrackSelectorContainsTracks_whenSelectingVideoTrack_thenSelectsTrack() {
givenTrackSelectorContainsTracks();
ArgumentCaptor<MappingTrackSelector.SelectionOverride> argumentCaptor = whenSelectingVideoTrack(ADDITIONAL_PLAYER_VIDEO_TRACK);
MappingTrackSelector.SelectionOverride selectionOverride = argumentCaptor.getValue();
assertThat(selectionOverride.factory).isEqualTo(trackSelectionFactory);
assertThat(selectionOverride.groupIndex).isEqualTo(FIRST_GROUP);
assertThat(selectionOverride.tracks).contains(SECOND_TRACK);
}
示例11: whenSelectingVideoTrack
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入方法依赖的package包/类
private ArgumentCaptor<MappingTrackSelector.SelectionOverride> whenSelectingVideoTrack(PlayerVideoTrack videoTrack) {
exoPlayerVideoTrackSelector.selectVideoTrack(videoTrack, rendererTypeRequester);
ArgumentCaptor<MappingTrackSelector.SelectionOverride> argumentCaptor = ArgumentCaptor.forClass(MappingTrackSelector.SelectionOverride.class);
verify(trackSelector).setSelectionOverride(eq(TrackType.VIDEO), any(RendererTypeRequester.class), any(TrackGroupArray.class), argumentCaptor.capture());
return argumentCaptor;
}
示例12: onClick
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入方法依赖的package包/类
@Override
public void onClick(View view) {
if (view == qualityAutoView) {
isDisabled = false;
override = null;
} else {
isDisabled = false;
@SuppressWarnings("unchecked")
Pair<Integer, Integer> tag = (Pair<Integer, Integer>) view.getTag();
if(tag==null){
Toast.makeText(getContext(),"this format is not supported ",Toast.LENGTH_SHORT).show();
return;
}
int groupIndex = tag.first;
int trackIndex = tag.second;
if (!trackGroupsAdaptive[groupIndex] || override == null
|| override.groupIndex != groupIndex) {
override = new MappingTrackSelector.SelectionOverride(FIXED_FACTORY, groupIndex, trackIndex);
} else {
// The group being modified is adaptive and we already have a non-null override.
boolean isEnabled = ((TubiRadioButton) view).isChecked();
int overrideLength = override.length;
if (isEnabled) {
// Remove the track from the override.
if (overrideLength == 1) {
// The last track is being removed, so the override becomes empty.
override = null;
isDisabled = true;
} else {
setOverride(groupIndex, getTracksRemoving(override, trackIndex));
}
} else {
// Add the track to the override.
setOverride(groupIndex, getTracksAdding(override, trackIndex));
}
}
}
// Update the views with the new state.
updateViews();
}
示例13: setOverride
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入方法依赖的package包/类
private void setOverride(int group, int[] tracks) {
TrackSelection.Factory factory = tracks.length == 1 ? FIXED_FACTORY
: adaptiveTrackSelectionFactory;
override = new MappingTrackSelector.SelectionOverride(factory, group, tracks);
}
示例14: getTracksAdding
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入方法依赖的package包/类
private static int[] getTracksAdding(@NonNull MappingTrackSelector.SelectionOverride override, int addedTrack) {
int[] tracks = override.tracks;
tracks = Arrays.copyOf(tracks, tracks.length + 1);
tracks[tracks.length - 1] = addedTrack;
return tracks;
}