當前位置: 首頁>>代碼示例>>Java>>正文


Java TrackGroupArray類代碼示例

本文整理匯總了Java中com.google.android.exoplayer2.source.TrackGroupArray的典型用法代碼示例。如果您正苦於以下問題:Java TrackGroupArray類的具體用法?Java TrackGroupArray怎麽用?Java TrackGroupArray使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TrackGroupArray類屬於com.google.android.exoplayer2.source包,在下文中一共展示了TrackGroupArray類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: selectTracks

import com.google.android.exoplayer2.source.TrackGroupArray; //導入依賴的package包/類
@Override
protected TrackSelection[] selectTracks(RendererCapabilities[] rendererCapabilities,
    TrackGroupArray[] rendererTrackGroupArrays, int[][][] rendererFormatSupports)
    throws ExoPlaybackException {
  Assertions.checkState(rendererCapabilities[VIDEO_RENDERER_INDEX].getTrackType()
      == C.TRACK_TYPE_VIDEO);
  Assertions.checkState(rendererCapabilities[AUDIO_RENDERER_INDEX].getTrackType()
      == C.TRACK_TYPE_AUDIO);
  Assertions.checkState(rendererTrackGroupArrays[VIDEO_RENDERER_INDEX].length == 1);
  Assertions.checkState(rendererTrackGroupArrays[AUDIO_RENDERER_INDEX].length == 1);
  TrackSelection[] selections = new TrackSelection[rendererCapabilities.length];
  selections[VIDEO_RENDERER_INDEX] = new RandomTrackSelection(
      rendererTrackGroupArrays[VIDEO_RENDERER_INDEX].get(0),
      getVideoTrackIndices(rendererTrackGroupArrays[VIDEO_RENDERER_INDEX].get(0),
          rendererFormatSupports[VIDEO_RENDERER_INDEX][0], videoFormatIds,
          canIncludeAdditionalVideoFormats),
      0 /* seed */);
  selections[AUDIO_RENDERER_INDEX] = new FixedTrackSelection(
      rendererTrackGroupArrays[AUDIO_RENDERER_INDEX].get(0),
      getTrackIndex(rendererTrackGroupArrays[AUDIO_RENDERER_INDEX].get(0), audioFormatId));
  includedAdditionalVideoFormats =
      selections[VIDEO_RENDERER_INDEX].length() > videoFormatIds.length;
  return selections;
}
 
開發者ID:ashwanijanghu,項目名稱:ExoPlayer-Offline,代碼行數:25,代碼來源:DashTest.java

示例2: selectVideoTrack

import com.google.android.exoplayer2.source.TrackGroupArray; //導入依賴的package包/類
protected TrackSelection selectVideoTrack(RendererCapabilities rendererCapabilities,
    TrackGroupArray groups, int[][] formatSupport, int maxVideoWidth, int maxVideoHeight,
    int maxVideoBitrate, boolean allowNonSeamlessAdaptiveness, boolean allowMixedMimeAdaptiveness,
    int viewportWidth, int viewportHeight, boolean orientationMayChange,
    TrackSelection.Factory adaptiveTrackSelectionFactory, boolean exceedConstraintsIfNecessary,
    boolean exceedRendererCapabilitiesIfNecessary) throws ExoPlaybackException {
  TrackSelection selection = null;
  if (adaptiveTrackSelectionFactory != null) {
    selection = selectAdaptiveVideoTrack(rendererCapabilities, groups, formatSupport,
        maxVideoWidth, maxVideoHeight, maxVideoBitrate, allowNonSeamlessAdaptiveness,
        allowMixedMimeAdaptiveness, viewportWidth, viewportHeight,
        orientationMayChange, adaptiveTrackSelectionFactory);
  }
  if (selection == null) {
    selection = selectFixedVideoTrack(groups, formatSupport, maxVideoWidth, maxVideoHeight,
        maxVideoBitrate, viewportWidth, viewportHeight, orientationMayChange,
        exceedConstraintsIfNecessary, exceedRendererCapabilitiesIfNecessary);
  }
  return selection;
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:21,代碼來源:DefaultTrackSelector.java

示例3: selectAdaptiveVideoTrack

import com.google.android.exoplayer2.source.TrackGroupArray; //導入依賴的package包/類
private static TrackSelection selectAdaptiveVideoTrack(RendererCapabilities rendererCapabilities,
    TrackGroupArray groups, int[][] formatSupport, int maxVideoWidth, int maxVideoHeight,
    int maxVideoBitrate, boolean allowNonSeamlessAdaptiveness, boolean allowMixedMimeAdaptiveness,
    int viewportWidth, int viewportHeight, boolean orientationMayChange,
    TrackSelection.Factory adaptiveTrackSelectionFactory) throws ExoPlaybackException {
  int requiredAdaptiveSupport = allowNonSeamlessAdaptiveness
      ? (RendererCapabilities.ADAPTIVE_NOT_SEAMLESS | RendererCapabilities.ADAPTIVE_SEAMLESS)
      : RendererCapabilities.ADAPTIVE_SEAMLESS;
  boolean allowMixedMimeTypes = allowMixedMimeAdaptiveness
      && (rendererCapabilities.supportsMixedMimeTypeAdaptation() & requiredAdaptiveSupport) != 0;
  for (int i = 0; i < groups.length; i++) {
    TrackGroup group = groups.get(i);
    int[] adaptiveTracks = getAdaptiveVideoTracksForGroup(group, formatSupport[i],
        allowMixedMimeTypes, requiredAdaptiveSupport, maxVideoWidth, maxVideoHeight,
        maxVideoBitrate, viewportWidth, viewportHeight, orientationMayChange);
    if (adaptiveTracks.length > 0) {
      return adaptiveTrackSelectionFactory.createTrackSelection(group, adaptiveTracks);
    }
  }
  return null;
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:22,代碼來源:DefaultTrackSelector.java

示例4: rendererSupportsTunneling

import com.google.android.exoplayer2.source.TrackGroupArray; //導入依賴的package包/類
/**
 * Returns whether a renderer supports tunneling for a {@link TrackSelection}.
 *
 * @param formatSupport The result of {@link RendererCapabilities#supportsFormat} for each
 *     track, indexed by group index and track index (in that order).
 * @param trackGroups The {@link TrackGroupArray}s for the renderer.
 * @param selection The track selection.
 * @return Whether the renderer supports tunneling for the {@link TrackSelection}.
 */
private static boolean rendererSupportsTunneling(int[][] formatSupport,
    TrackGroupArray trackGroups, TrackSelection selection) {
  if (selection == null) {
    return false;
  }
  int trackGroupIndex = trackGroups.indexOf(selection.getTrackGroup());
  for (int i = 0; i < selection.length(); i++) {
    int trackFormatSupport = formatSupport[trackGroupIndex][selection.getIndexInTrackGroup(i)];
    if ((trackFormatSupport & RendererCapabilities.TUNNELING_SUPPORT_MASK)
        != RendererCapabilities.TUNNELING_SUPPORTED) {
      return false;
    }
  }
  return true;
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:25,代碼來源:MappingTrackSelector.java

示例5: getSubtitleTracks

import com.google.android.exoplayer2.source.TrackGroupArray; //導入依賴的package包/類
public List<PlayerSubtitleTrack> getSubtitleTracks(RendererTypeRequester rendererTypeRequester) {
    TrackGroupArray trackGroups = trackSelector.trackGroups(TEXT, rendererTypeRequester);

    List<PlayerSubtitleTrack> subtitleTracks = new ArrayList<>();

    for (int groupIndex = 0; groupIndex < trackGroups.length; groupIndex++) {
        TrackGroup trackGroup = trackGroups.get(groupIndex);

        for (int formatIndex = 0; formatIndex < trackGroup.length; formatIndex++) {
            Format format = trackGroup.getFormat(formatIndex);
            PlayerSubtitleTrack playerSubtitleTrack = new PlayerSubtitleTrack(
                    groupIndex,
                    formatIndex,
                    format.id,
                    format.language,
                    format.sampleMimeType,
                    format.channelCount,
                    format.bitrate
            );
            subtitleTracks.add(playerSubtitleTrack);
        }
    }

    return subtitleTracks;
}
 
開發者ID:novoda,項目名稱:no-player,代碼行數:26,代碼來源:ExoPlayerSubtitleTrackSelector.java

示例6: selectVideoTrack

import com.google.android.exoplayer2.source.TrackGroupArray; //導入依賴的package包/類
protected TrackSelection selectVideoTrack(RendererCapabilities rendererCapabilities,
    TrackGroupArray groups, int[][] formatSupport, int maxVideoWidth, int maxVideoHeight,
    int maxVideoBitrate, boolean allowNonSeamlessAdaptiveness, boolean allowMixedMimeAdaptiveness,
    int viewportWidth, int viewportHeight, boolean orientationMayChange,
    TrackSelection.Factory adaptiveVideoTrackSelectionFactory,
    boolean exceedConstraintsIfNecessary, boolean exceedRendererCapabilitiesIfNecessary)
    throws ExoPlaybackException {
  TrackSelection selection = null;
  if (adaptiveVideoTrackSelectionFactory != null) {
    selection = selectAdaptiveVideoTrack(rendererCapabilities, groups, formatSupport,
        maxVideoWidth, maxVideoHeight, maxVideoBitrate, allowNonSeamlessAdaptiveness,
        allowMixedMimeAdaptiveness, viewportWidth, viewportHeight,
        orientationMayChange, adaptiveVideoTrackSelectionFactory);
  }
  if (selection == null) {
    selection = selectFixedVideoTrack(groups, formatSupport, maxVideoWidth, maxVideoHeight,
        maxVideoBitrate, viewportWidth, viewportHeight, orientationMayChange,
        exceedConstraintsIfNecessary, exceedRendererCapabilitiesIfNecessary);
  }
  return selection;
}
 
開發者ID:jcodeing,項目名稱:K-Sonic,代碼行數:22,代碼來源:DefaultTrackSelector.java

示例7: selectAdaptiveVideoTrack

import com.google.android.exoplayer2.source.TrackGroupArray; //導入依賴的package包/類
private static TrackSelection selectAdaptiveVideoTrack(RendererCapabilities rendererCapabilities,
    TrackGroupArray groups, int[][] formatSupport, int maxVideoWidth, int maxVideoHeight,
    int maxVideoBitrate, boolean allowNonSeamlessAdaptiveness, boolean allowMixedMimeAdaptiveness,
    int viewportWidth, int viewportHeight, boolean orientationMayChange,
    TrackSelection.Factory adaptiveVideoTrackSelectionFactory) throws ExoPlaybackException {
  int requiredAdaptiveSupport = allowNonSeamlessAdaptiveness
      ? (RendererCapabilities.ADAPTIVE_NOT_SEAMLESS | RendererCapabilities.ADAPTIVE_SEAMLESS)
      : RendererCapabilities.ADAPTIVE_SEAMLESS;
  boolean allowMixedMimeTypes = allowMixedMimeAdaptiveness
      && (rendererCapabilities.supportsMixedMimeTypeAdaptation() & requiredAdaptiveSupport) != 0;
  for (int i = 0; i < groups.length; i++) {
    TrackGroup group = groups.get(i);
    int[] adaptiveTracks = getAdaptiveTracksForGroup(group, formatSupport[i],
        allowMixedMimeTypes, requiredAdaptiveSupport, maxVideoWidth, maxVideoHeight,
        maxVideoBitrate, viewportWidth, viewportHeight, orientationMayChange);
    if (adaptiveTracks.length > 0) {
      return adaptiveVideoTrackSelectionFactory.createTrackSelection(group, adaptiveTracks);
    }
  }
  return null;
}
 
開發者ID:jcodeing,項目名稱:K-Sonic,代碼行數:22,代碼來源:DefaultTrackSelector.java

示例8: DashMediaPeriod

import com.google.android.exoplayer2.source.TrackGroupArray; //導入依賴的package包/類
public DashMediaPeriod(int id, DashManifest manifest, int periodIndex,
    DashChunkSource.Factory chunkSourceFactory,  int minLoadableRetryCount,
    EventDispatcher eventDispatcher, long elapsedRealtimeOffset,
    LoaderErrorThrower manifestLoaderErrorThrower, Allocator allocator) {
  this.id = id;
  this.manifest = manifest;
  this.periodIndex = periodIndex;
  this.chunkSourceFactory = chunkSourceFactory;
  this.minLoadableRetryCount = minLoadableRetryCount;
  this.eventDispatcher = eventDispatcher;
  this.elapsedRealtimeOffset = elapsedRealtimeOffset;
  this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
  this.allocator = allocator;
  sampleStreams = newSampleStreamArray(0);
  sequenceableLoader = new CompositeSequenceableLoader(sampleStreams);
  adaptationSets = manifest.getPeriod(periodIndex).adaptationSets;
  Pair<TrackGroupArray, EmbeddedTrackInfo[]> result = buildTrackGroups(adaptationSets);
  trackGroups = result.first;
  embeddedTrackInfos = result.second;
}
 
開發者ID:jcodeing,項目名稱:K-Sonic,代碼行數:21,代碼來源:DashMediaPeriod.java

示例9: ExoPlayerImpl

import com.google.android.exoplayer2.source.TrackGroupArray; //導入依賴的package包/類
/**
 * Constructs an instance. Must be called from a thread that has an associated {@link Looper}.
 *
 * @param renderers The {@link Renderer}s that will be used by the instance.
 * @param trackSelector The {@link TrackSelector} that will be used by the instance.
 * @param loadControl The {@link LoadControl} that will be used by the instance.
 */
@SuppressLint("HandlerLeak")
public ExoPlayerImpl(Renderer[] renderers, TrackSelector trackSelector, LoadControl loadControl) {
  Log.i(TAG, "Init " + ExoPlayerLibraryInfo.VERSION + " [" + Util.DEVICE_DEBUG_INFO + "]");
  Assertions.checkState(renderers.length > 0);
  this.renderers = Assertions.checkNotNull(renderers);
  this.trackSelector = Assertions.checkNotNull(trackSelector);
  this.playWhenReady = false;
  this.playbackState = STATE_IDLE;
  this.listeners = new CopyOnWriteArraySet<>();
  emptyTrackSelections = new TrackSelectionArray(new TrackSelection[renderers.length]);
  timeline = Timeline.EMPTY;
  window = new Timeline.Window();
  period = new Timeline.Period();
  trackGroups = TrackGroupArray.EMPTY;
  trackSelections = emptyTrackSelections;
  eventHandler = new Handler() {
    @Override
    public void handleMessage(Message msg) {
      ExoPlayerImpl.this.handleEvent(msg);
    }
  };
  playbackInfo = new ExoPlayerImplInternal.PlaybackInfo(0, 0);
  internalPlayer = new ExoPlayerImplInternal(renderers, trackSelector, loadControl, playWhenReady,
      eventHandler, playbackInfo, this);
}
 
開發者ID:jcodeing,項目名稱:K-Sonic,代碼行數:33,代碼來源:ExoPlayerImpl.java

示例10: selectVideoTrack

import com.google.android.exoplayer2.source.TrackGroupArray; //導入依賴的package包/類
protected TrackSelection selectVideoTrack(RendererCapabilities rendererCapabilities,
    TrackGroupArray groups, int[][] formatSupport, int maxVideoWidth, int maxVideoHeight,
    boolean allowNonSeamlessAdaptiveness, boolean allowMixedMimeAdaptiveness, int viewportWidth,
    int viewportHeight, boolean orientationMayChange,
    TrackSelection.Factory adaptiveVideoTrackSelectionFactory,
    boolean exceedConstraintsIfNecessary) throws ExoPlaybackException {
  TrackSelection selection = null;
  if (adaptiveVideoTrackSelectionFactory != null) {
    selection = selectAdaptiveVideoTrack(rendererCapabilities, groups, formatSupport,
        maxVideoWidth, maxVideoHeight, allowNonSeamlessAdaptiveness,
        allowMixedMimeAdaptiveness, viewportWidth, viewportHeight,
        orientationMayChange, adaptiveVideoTrackSelectionFactory);
  }
  if (selection == null) {
    selection = selectFixedVideoTrack(groups, formatSupport, maxVideoWidth, maxVideoHeight,
        viewportWidth, viewportHeight, orientationMayChange, exceedConstraintsIfNecessary);
  }
  return selection;
}
 
開發者ID:zhanglibin123488,項目名稱:videoPickPlayer,代碼行數:20,代碼來源:DefaultTrackSelector.java

示例11: selectAdaptiveVideoTrack

import com.google.android.exoplayer2.source.TrackGroupArray; //導入依賴的package包/類
private static TrackSelection selectAdaptiveVideoTrack(RendererCapabilities rendererCapabilities,
    TrackGroupArray groups, int[][] formatSupport, int maxVideoWidth, int maxVideoHeight,
    boolean allowNonSeamlessAdaptiveness, boolean allowMixedMimeAdaptiveness, int viewportWidth,
    int viewportHeight, boolean orientationMayChange,
    TrackSelection.Factory adaptiveVideoTrackSelectionFactory) throws ExoPlaybackException {
  int requiredAdaptiveSupport = allowNonSeamlessAdaptiveness
      ? (RendererCapabilities.ADAPTIVE_NOT_SEAMLESS | RendererCapabilities.ADAPTIVE_SEAMLESS)
      : RendererCapabilities.ADAPTIVE_SEAMLESS;
  boolean allowMixedMimeTypes = allowMixedMimeAdaptiveness
      && (rendererCapabilities.supportsMixedMimeTypeAdaptation() & requiredAdaptiveSupport) != 0;
  for (int i = 0; i < groups.length; i++) {
    TrackGroup group = groups.get(i);
    int[] adaptiveTracks = getAdaptiveTracksForGroup(group, formatSupport[i],
        allowMixedMimeTypes, requiredAdaptiveSupport, maxVideoWidth, maxVideoHeight,
        viewportWidth, viewportHeight, orientationMayChange);
    if (adaptiveTracks.length > 0) {
      return adaptiveVideoTrackSelectionFactory.createTrackSelection(group, adaptiveTracks);
    }
  }
  return null;
}
 
開發者ID:zhanglibin123488,項目名稱:videoPickPlayer,代碼行數:22,代碼來源:DefaultTrackSelector.java

示例12: selectOtherTrack

import com.google.android.exoplayer2.source.TrackGroupArray; //導入依賴的package包/類
protected TrackSelection selectOtherTrack(int trackType, TrackGroupArray groups,
    int[][] formatSupport) {
  TrackGroup selectedGroup = null;
  int selectedTrackIndex = 0;
  int selectedTrackScore = 0;
  for (int groupIndex = 0; groupIndex < groups.length; groupIndex++) {
    TrackGroup trackGroup = groups.get(groupIndex);
    int[] trackFormatSupport = formatSupport[groupIndex];
    for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
      if (isSupported(trackFormatSupport[trackIndex])) {
        Format format = trackGroup.getFormat(trackIndex);
        boolean isDefault = (format.selectionFlags & C.SELECTION_FLAG_DEFAULT) != 0;
        int trackScore = isDefault ? 2 : 1;
        if (trackScore > selectedTrackScore) {
          selectedGroup = trackGroup;
          selectedTrackIndex = trackIndex;
          selectedTrackScore = trackScore;
        }
      }
    }
  }
  return selectedGroup == null ? null
      : new FixedTrackSelection(selectedGroup, selectedTrackIndex);
}
 
開發者ID:zhanglibin123488,項目名稱:videoPickPlayer,代碼行數:25,代碼來源:DefaultTrackSelector.java

示例13: setSelectionOverride

import com.google.android.exoplayer2.source.TrackGroupArray; //導入依賴的package包/類
/**
 * Overrides the track selection for the renderer at a specified index.
 * <p>
 * When the {@link TrackGroupArray} available to the renderer at the specified index matches the
 * one provided, the override is applied. When the {@link TrackGroupArray} does not match, the
 * override has no effect. The override replaces any previous override for the renderer and the
 * provided {@link TrackGroupArray}.
 * <p>
 * Passing a {@code null} override will explicitly disable the renderer. To remove overrides use
 * {@link #clearSelectionOverride(int, TrackGroupArray)}, {@link #clearSelectionOverrides(int)}
 * or {@link #clearSelectionOverrides()}.
 *
 * @param rendererIndex The renderer index.
 * @param groups The {@link TrackGroupArray} for which the override should be applied.
 * @param override The override.
 */
// TODO - Don't allow overrides that select unsupported tracks, unless some flag has been
// explicitly set by the user to indicate that they want this.
public final void setSelectionOverride(int rendererIndex, TrackGroupArray groups,
    SelectionOverride override) {
  Map<TrackGroupArray, SelectionOverride> overrides = selectionOverrides.get(rendererIndex);
  if (overrides == null) {
    overrides = new HashMap<>();
    selectionOverrides.put(rendererIndex, overrides);
  }
  if (overrides.containsKey(groups) && Util.areEqual(overrides.get(groups), override)) {
    // The override is unchanged.
    return;
  }
  overrides.put(groups, override);
  invalidate();
}
 
開發者ID:zhanglibin123488,項目名稱:videoPickPlayer,代碼行數:33,代碼來源:MappingTrackSelector.java

示例14: onTracksSelected

import com.google.android.exoplayer2.source.TrackGroupArray; //導入依賴的package包/類
@Override
public void onTracksSelected(Renderer[] renderers, TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
    targetBufferSize = 0;
    for (int i = 0; i < renderers.length; i++) {
        if (trackSelections.get(i) != null) {
            targetBufferSize += Util.getDefaultBufferSize(renderers[i].getTrackType());
        }
    }
    allocator.setTargetBufferSize(targetBufferSize);
}
 
開發者ID:yangchaojiang,項目名稱:yjPlay,代碼行數:11,代碼來源:BufferingLoadControl.java

示例15: onTracksChanged

import com.google.android.exoplayer2.source.TrackGroupArray; //導入依賴的package包/類
@Override
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
    Log.d(TAG, "onTracksChanged:" + currentWindowIndex + "_:" + player.getCurrentTimeline().getWindowCount());
    if (getWindowCount() > 1) {
        if (isRemove) {
            isRemove = false;
            mediaSourceBuilder.removeMediaSource(resumeWindow);
            return;
        }
        if (windowListener != null) {
            windowListener.onCurrentIndex(currentWindowIndex, getWindowCount());
            currentWindowIndex += 1;
        }
        if (mediaSourceBuilder.getIndexType() < 0) {
            return;
        }
        GestureVideoPlayer gestureVideoPlayer = null;
        if (ExoUserPlayer.this instanceof GestureVideoPlayer) {
            gestureVideoPlayer = (GestureVideoPlayer) ExoUserPlayer.this;
        }
        boolean setOpenSeek = !(mediaSourceBuilder.getIndexType() == currentWindowIndex && mediaSourceBuilder.getIndexType() > 0);
        if (gestureVideoPlayer != null) {
            gestureVideoPlayer.setPlayerGestureOnTouch(setOpenSeek);
        }
        getPlayerViewListener().setOpenSeek(setOpenSeek);
    }
}
 
開發者ID:yangchaojiang,項目名稱:yjPlay,代碼行數:28,代碼來源:ExoUserPlayer.java


注:本文中的com.google.android.exoplayer2.source.TrackGroupArray類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。