本文整理汇总了Java中com.google.android.exoplayer2.trackselection.MappingTrackSelector类的典型用法代码示例。如果您正苦于以下问题:Java MappingTrackSelector类的具体用法?Java MappingTrackSelector怎么用?Java MappingTrackSelector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MappingTrackSelector类属于com.google.android.exoplayer2.trackselection包,在下文中一共展示了MappingTrackSelector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSelector
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入依赖的package包/类
private void setSelector(MappingTrackSelector selector) {
this.selector = selector;
setTrackInfo(selector.getCurrentMappedTrackInfo());
setTrackGroups(trackInfo.getTrackGroups(rendererIndex));
setOverride(selector.getSelectionOverride(rendererIndex, trackGroups));
trackGroupsAdaptive = new boolean[trackGroups.length];
for (int i = 0; i < trackGroups.length; i++) {
trackGroupsAdaptive[i] = adaptiveTrackSelectionFactory != null
&& trackInfo.getAdaptiveSupport(rendererIndex, i, false)
!= RendererCapabilities.ADAPTIVE_NOT_SUPPORTED
&& trackGroups.get(i).length > 1;
}
// isDisabled = selector.getRendererDisabled(rendererIndex);
// override = selector.getSelectionOverride(rendererIndex, trackGroups);
}
示例2: getAvailableTracks
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入依赖的package包/类
/**
* Retrieves a list of available tracks
*
* @return A list of available tracks associated with each type
*/
@Nullable
public Map<RendererType, TrackGroupArray> getAvailableTracks() {
if (getPlaybackState() == Player.STATE_IDLE) {
return null;
}
// Retrieves the available tracks
Map<RendererType, TrackGroupArray> trackMap = new ArrayMap<>();
MappingTrackSelector.MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo();
if (mappedTrackInfo == null) {
return trackMap;
}
// Maps the available tracks
RendererType[] types = new RendererType[] {RendererType.AUDIO, RendererType.VIDEO, RendererType.CLOSED_CAPTION, RendererType.METADATA};
for (RendererType type : types) {
int exoPlayerTrackIndex = getExoPlayerTrackType(type);
if (mappedTrackInfo.length > exoPlayerTrackIndex) {
trackMap.put(type, mappedTrackInfo.getTrackGroups(exoPlayerTrackIndex));
}
}
return trackMap;
}
示例3: 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];
}
示例4: 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);
}
示例5: doActionAndScheduleNextImpl
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入依赖的package包/类
@Override
protected void doActionAndScheduleNextImpl(final SimpleExoPlayer player,
final MappingTrackSelector trackSelector, final Surface surface, final Handler handler,
final ActionNode nextAction) {
if (nextAction == null) {
return;
}
Player.EventListener listener = new Player.DefaultEventListener() {
@Override
public void onTimelineChanged(Timeline timeline, Object manifest) {
if (timeline.equals(expectedTimeline)) {
player.removeListener(this);
nextAction.schedule(player, trackSelector, surface, handler);
}
}
};
player.addListener(listener);
if (player.getCurrentTimeline().equals(expectedTimeline)) {
player.removeListener(listener);
nextAction.schedule(player, trackSelector, surface, handler);
}
}
示例6: ExoPlayerTestRunner
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入依赖的package包/类
private ExoPlayerTestRunner(PlayerFactory playerFactory, MediaSource mediaSource,
RenderersFactory renderersFactory, MappingTrackSelector trackSelector,
LoadControl loadControl, ActionSchedule actionSchedule, Player.EventListener eventListener) {
this.playerFactory = playerFactory;
this.mediaSource = mediaSource;
this.renderersFactory = renderersFactory;
this.trackSelector = trackSelector;
this.loadControl = loadControl;
this.actionSchedule = actionSchedule;
this.eventListener = eventListener;
this.timelines = new LinkedList<>();
this.manifests = new LinkedList<>();
this.periodIndices = new LinkedList<>();
this.endedCountDownLatch = new CountDownLatch(1);
this.playerThread = new HandlerThread("ExoPlayerTest thread");
playerThread.start();
this.handler = new Handler(playerThread.getLooper());
}
示例7: onQualityTrackToggle
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入依赖的package包/类
@Override
public void onQualityTrackToggle(boolean enabled) {
if (mTrackSelectionHelper != null && mActivity != null) {
MappingTrackSelector.MappedTrackInfo mappedTrackInfo = mTrackSelectionHelper.getSelector().getCurrentMappedTrackInfo();
if (mappedTrackInfo != null) {
mTrackSelectionHelper.showSelectionDialog(0, controller);
}
}
}
示例8: buildQualityDialog
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入依赖的package包/类
/**
* Builds the quality selection list based on the media tracks
*
* @param selector The selector to get all the available tracks
* @param rendererIndex The render index
* @return The selection view
*/
public View buildQualityDialog(@NonNull MappingTrackSelector selector, int rendererIndex) {
setRendererIndex(rendererIndex);
setSelector(selector);
// View for clearing the override to allow the selector to use its default selection logic.
qualityAutoView = new TubiRadioButton(getContext());
qualityAutoView.setText(R.string.track_selector_alert_auto);
qualityAutoView.setFocusable(true);
qualityAutoView.setOnClickListener(this);
mBinding.viewTubiQualityDialogLl.addView(qualityAutoView);
// Per-track views.
trackViews = new TubiRadioButton[trackGroups.length][];
for (int groupIndex = 0; groupIndex < trackGroups.length; groupIndex++) {
TrackGroup group = trackGroups.get(groupIndex);
trackViews[groupIndex] = new TubiRadioButton[group.length];
for (int trackIndex = 0; trackIndex < group.length; trackIndex++) {
TubiRadioButton trackView = new TubiRadioButton(getContext());
trackView.setText(buildTrackName(group.getFormat(trackIndex)));
if (trackInfo.getTrackFormatSupport(rendererIndex, groupIndex, trackIndex)
== RendererCapabilities.FORMAT_HANDLED) {
trackView.setFocusable(true);
trackView.setTag(Pair.create(groupIndex, trackIndex));
} else {
trackView.setFocusable(false);
trackView.setEnabled(false);
}
trackView.setOnClickListener(this);
trackViews[groupIndex][trackIndex] = trackView;
mBinding.viewTubiQualityDialogLl.addView(trackView);
}
}
updateViews();
return this;
}
示例9: 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;
}
示例10: buildExoPlayer
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入依赖的package包/类
@SuppressWarnings("unused")
protected SimpleExoPlayer buildExoPlayer(HostActivity host, Surface surface,
MappingTrackSelector trackSelector,
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager) {
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(host, trackSelector,
new DefaultLoadControl(), drmSessionManager, SimpleExoPlayer.EXTENSION_RENDERER_MODE_OFF,
0);
player.setVideoSurface(surface);
return player;
}
示例11: buildExoPlayer
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; //导入依赖的package包/类
@Override
protected SimpleExoPlayer buildExoPlayer(HostActivity host, Surface surface,
MappingTrackSelector trackSelector,
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager) {
SimpleExoPlayer player = new DebugSimpleExoPlayer(host, trackSelector,
new DefaultLoadControl(), drmSessionManager);
player.setVideoSurface(surface);
return player;
}
示例12: 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);
}
示例13: 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;
}
}
示例14: 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);
}
示例15: 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);
}