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


Java TrackSelection.length方法代碼示例

本文整理匯總了Java中com.google.android.exoplayer2.trackselection.TrackSelection.length方法的典型用法代碼示例。如果您正苦於以下問題:Java TrackSelection.length方法的具體用法?Java TrackSelection.length怎麽用?Java TrackSelection.length使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.android.exoplayer2.trackselection.TrackSelection的用法示例。


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

示例1: DefaultDashChunkSource

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的package包/類
/**
 * @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
 * @param manifest The initial manifest.
 * @param periodIndex The index of the period in the manifest.
 * @param adaptationSetIndex The index of the adaptation set in the period.
 * @param trackSelection The track selection.
 * @param dataSource A {@link DataSource} suitable for loading the media data.
 * @param elapsedRealtimeOffsetMs If known, an estimate of the instantaneous difference between
 *     server-side unix time and {@link SystemClock#elapsedRealtime()} in milliseconds, specified
 *     as the server's unix time minus the local elapsed time. If unknown, set to 0.
 * @param maxSegmentsPerLoad The maximum number of segments to combine into a single request.
 *     Note that segments will only be combined if their {@link Uri}s are the same and if their
 *     data ranges are adjacent.
 * @param enableEventMessageTrack Whether the chunks generated by the source may output an event
 *     message track.
 * @param enableEventMessageTrack Whether the chunks generated by the source may output a CEA-608
 *     track.
 */
public DefaultDashChunkSource(LoaderErrorThrower manifestLoaderErrorThrower,
    DashManifest manifest, int periodIndex, int adaptationSetIndex, TrackSelection trackSelection,
    DataSource dataSource, long elapsedRealtimeOffsetMs, int maxSegmentsPerLoad,
    boolean enableEventMessageTrack, boolean enableCea608Track) {
  this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
  this.manifest = manifest;
  this.adaptationSetIndex = adaptationSetIndex;
  this.trackSelection = trackSelection;
  this.dataSource = dataSource;
  this.periodIndex = periodIndex;
  this.elapsedRealtimeOffsetMs = elapsedRealtimeOffsetMs;
  this.maxSegmentsPerLoad = maxSegmentsPerLoad;

  long periodDurationUs = manifest.getPeriodDurationUs(periodIndex);
  AdaptationSet adaptationSet = getAdaptationSet();
  List<Representation> representations = adaptationSet.representations;
  representationHolders = new RepresentationHolder[trackSelection.length()];
  for (int i = 0; i < representationHolders.length; i++) {
    Representation representation = representations.get(trackSelection.getIndexInTrackGroup(i));
    representationHolders[i] = new RepresentationHolder(periodDurationUs, representation,
        enableEventMessageTrack, enableCea608Track, adaptationSet.type);
  }
}
 
開發者ID:jcodeing,項目名稱:K-Sonic,代碼行數:42,代碼來源:DefaultDashChunkSource.java

示例2: DefaultSsChunkSource

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的package包/類
/**
 * @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
 * @param manifest The initial manifest.
 * @param elementIndex The index of the stream element in the manifest.
 * @param trackSelection The track selection.
 * @param dataSource A {@link DataSource} suitable for loading the media data.
 * @param trackEncryptionBoxes Track encryption boxes for the stream.
 */
public DefaultSsChunkSource(LoaderErrorThrower manifestLoaderErrorThrower, SsManifest manifest,
    int elementIndex, TrackSelection trackSelection, DataSource dataSource,
    TrackEncryptionBox[] trackEncryptionBoxes) {
  this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
  this.manifest = manifest;
  this.elementIndex = elementIndex;
  this.trackSelection = trackSelection;
  this.dataSource = dataSource;

  StreamElement streamElement = manifest.streamElements[elementIndex];

  extractorWrappers = new ChunkExtractorWrapper[trackSelection.length()];
  for (int i = 0; i < extractorWrappers.length; i++) {
    int manifestTrackIndex = trackSelection.getIndexInTrackGroup(i);
    Format format = streamElement.formats[manifestTrackIndex];
    int nalUnitLengthFieldLength = streamElement.type == C.TRACK_TYPE_VIDEO ? 4 : 0;
    Track track = new Track(manifestTrackIndex, streamElement.type, streamElement.timescale,
        C.TIME_UNSET, manifest.durationUs, format, Track.TRANSFORMATION_NONE,
        trackEncryptionBoxes, nalUnitLengthFieldLength, null, null);
    FragmentedMp4Extractor extractor = new FragmentedMp4Extractor(
        FragmentedMp4Extractor.FLAG_WORKAROUND_EVERY_VIDEO_FRAME_IS_SYNC_FRAME
        | FragmentedMp4Extractor.FLAG_WORKAROUND_IGNORE_TFDT_BOX, null, track);
    extractorWrappers[i] = new ChunkExtractorWrapper(extractor, format);
  }
}
 
開發者ID:jcodeing,項目名稱:K-Sonic,代碼行數:34,代碼來源:DefaultSsChunkSource.java

示例3: maybeBlacklistTrack

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的package包/類
/**
 * Blacklists {@code trackSelectionIndex} in {@code trackSelection} for
 * {@code blacklistDurationMs} if {@code e} is an {@link InvalidResponseCodeException} with
 * {@link InvalidResponseCodeException#responseCode} equal to 404 or 410. Else does nothing. Note
 * that blacklisting will fail if the track is the only non-blacklisted track in the selection.
 *
 * @param trackSelection The track selection.
 * @param trackSelectionIndex The index in the selection to consider blacklisting.
 * @param e The error to inspect.
 * @param blacklistDurationMs The duration to blacklist the track for, if it is blacklisted.
 * @return Whether the track was blacklisted.
 */
public static boolean maybeBlacklistTrack(TrackSelection trackSelection, int trackSelectionIndex,
    Exception e, long blacklistDurationMs) {
  if (trackSelection.length() == 1) {
    // Blacklisting won't ever work if there's only one track in the selection.
    return false;
  }
  if (e instanceof InvalidResponseCodeException) {
    InvalidResponseCodeException responseCodeException = (InvalidResponseCodeException) e;
    int responseCode = responseCodeException.responseCode;
    if (responseCode == 404 || responseCode == 410) {
      boolean blacklisted = trackSelection.blacklist(trackSelectionIndex, blacklistDurationMs);
      if (blacklisted) {
        Log.w(TAG, "Blacklisted: duration=" + blacklistDurationMs + ", responseCode="
            + responseCode + ", format=" + trackSelection.getFormat(trackSelectionIndex));
      } else {
        Log.w(TAG, "Blacklisting failed (cannot blacklist last enabled track): responseCode="
            + responseCode + ", format=" + trackSelection.getFormat(trackSelectionIndex));
      }
      return blacklisted;
    }
  }
  return false;
}
 
開發者ID:zhanglibin123488,項目名稱:videoPickPlayer,代碼行數:36,代碼來源:ChunkedTrackBlacklistUtil.java

示例4: DefaultDashChunkSource

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的package包/類
/**
 * @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
 * @param manifest The initial manifest.
 * @param periodIndex The index of the period in the manifest.
 * @param adaptationSetIndex The index of the adaptation set in the period.
 * @param trackSelection The track selection.
 * @param dataSource A {@link DataSource} suitable for loading the media data.
 * @param elapsedRealtimeOffsetMs If known, an estimate of the instantaneous difference between
 *     server-side unix time and {@link SystemClock#elapsedRealtime()} in milliseconds, specified
 *     as the server's unix time minus the local elapsed time. If unknown, set to 0.
 */
public DefaultDashChunkSource(LoaderErrorThrower manifestLoaderErrorThrower,
    DashManifest manifest, int periodIndex, int adaptationSetIndex, TrackSelection trackSelection,
    DataSource dataSource, long elapsedRealtimeOffsetMs) {
  this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
  this.manifest = manifest;
  this.adaptationSetIndex = adaptationSetIndex;
  this.trackSelection = trackSelection;
  this.dataSource = dataSource;
  this.periodIndex = periodIndex;
  this.elapsedRealtimeOffsetMs = elapsedRealtimeOffsetMs;

  long periodDurationUs = manifest.getPeriodDurationUs(periodIndex);
  List<Representation> representations = getRepresentations();
  representationHolders = new RepresentationHolder[trackSelection.length()];
  for (int i = 0; i < representationHolders.length; i++) {
    Representation representation = representations.get(trackSelection.getIndexInTrackGroup(i));
    representationHolders[i] = new RepresentationHolder(periodDurationUs, representation);
  }
}
 
開發者ID:zhanglibin123488,項目名稱:videoPickPlayer,代碼行數:31,代碼來源:DefaultDashChunkSource.java

示例5: DefaultSsChunkSource

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的package包/類
/**
 * @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
 * @param manifest The initial manifest.
 * @param elementIndex The index of the stream element in the manifest.
 * @param trackSelection The track selection.
 * @param dataSource A {@link DataSource} suitable for loading the media data.
 * @param trackEncryptionBoxes Track encryption boxes for the stream.
 */
public DefaultSsChunkSource(LoaderErrorThrower manifestLoaderErrorThrower, SsManifest manifest,
    int elementIndex, TrackSelection trackSelection, DataSource dataSource,
    TrackEncryptionBox[] trackEncryptionBoxes) {
  this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
  this.manifest = manifest;
  this.elementIndex = elementIndex;
  this.trackSelection = trackSelection;
  this.dataSource = dataSource;

  StreamElement streamElement = manifest.streamElements[elementIndex];

  extractorWrappers = new ChunkExtractorWrapper[trackSelection.length()];
  for (int i = 0; i < extractorWrappers.length; i++) {
    int manifestTrackIndex = trackSelection.getIndexInTrackGroup(i);
    Format format = streamElement.formats[manifestTrackIndex];
    int nalUnitLengthFieldLength = streamElement.type == C.TRACK_TYPE_VIDEO ? 4 : 0;
    Track track = new Track(manifestTrackIndex, streamElement.type, streamElement.timescale,
        C.TIME_UNSET, manifest.durationUs, format, Track.TRANSFORMATION_NONE,
        trackEncryptionBoxes, nalUnitLengthFieldLength, null, null);
    FragmentedMp4Extractor extractor = new FragmentedMp4Extractor(
        FragmentedMp4Extractor.FLAG_WORKAROUND_EVERY_VIDEO_FRAME_IS_SYNC_FRAME
        | FragmentedMp4Extractor.FLAG_WORKAROUND_IGNORE_TFDT_BOX, track, null);
    extractorWrappers[i] = new ChunkExtractorWrapper(extractor, format, false, false);
  }
}
 
開發者ID:zhanglibin123488,項目名稱:videoPickPlayer,代碼行數:34,代碼來源:DefaultSsChunkSource.java

示例6: DefaultDashChunkSource

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的package包/類
/**
 * @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
 * @param manifest The initial manifest.
 * @param periodIndex The index of the period in the manifest.
 * @param adaptationSetIndices The indices of the adaptation sets in the period.
 * @param trackSelection The track selection.
 * @param trackType The type of the tracks in the selection.
 * @param dataSource A {@link DataSource} suitable for loading the media data.
 * @param elapsedRealtimeOffsetMs If known, an estimate of the instantaneous difference between
 *     server-side unix time and {@link SystemClock#elapsedRealtime()} in milliseconds, specified
 *     as the server's unix time minus the local elapsed time. If unknown, set to 0.
 * @param maxSegmentsPerLoad The maximum number of segments to combine into a single request.
 *     Note that segments will only be combined if their {@link Uri}s are the same and if their
 *     data ranges are adjacent.
 * @param enableEventMessageTrack Whether the chunks generated by the source may output an event
 *     message track.
 * @param enableCea608Track Whether the chunks generated by the source may output a CEA-608 track.
 */
public DefaultDashChunkSource(LoaderErrorThrower manifestLoaderErrorThrower,
    DashManifest manifest, int periodIndex, int[] adaptationSetIndices,
    TrackSelection trackSelection, int trackType, DataSource dataSource,
    long elapsedRealtimeOffsetMs, int maxSegmentsPerLoad, boolean enableEventMessageTrack,
    boolean enableCea608Track) {
  this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
  this.manifest = manifest;
  this.adaptationSetIndices = adaptationSetIndices;
  this.trackSelection = trackSelection;
  this.trackType = trackType;
  this.dataSource = dataSource;
  this.periodIndex = periodIndex;
  this.elapsedRealtimeOffsetMs = elapsedRealtimeOffsetMs;
  this.maxSegmentsPerLoad = maxSegmentsPerLoad;

  long periodDurationUs = manifest.getPeriodDurationUs(periodIndex);
  liveEdgeTimeUs = C.TIME_UNSET;
  List<Representation> representations = getRepresentations();
  representationHolders = new RepresentationHolder[trackSelection.length()];
  for (int i = 0; i < representationHolders.length; i++) {
    Representation representation = representations.get(trackSelection.getIndexInTrackGroup(i));
    representationHolders[i] = new RepresentationHolder(periodDurationUs, trackType,
        representation, enableEventMessageTrack, enableCea608Track);
  }
}
 
開發者ID:y20k,項目名稱:transistor,代碼行數:44,代碼來源:DefaultDashChunkSource.java

示例7: DefaultSsChunkSource

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的package包/類
/**
 * @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
 * @param manifest The initial manifest.
 * @param elementIndex The index of the stream element in the manifest.
 * @param trackSelection The track selection.
 * @param dataSource A {@link DataSource} suitable for loading the media data.
 * @param trackEncryptionBoxes Track encryption boxes for the stream.
 */
public DefaultSsChunkSource(LoaderErrorThrower manifestLoaderErrorThrower, SsManifest manifest,
    int elementIndex, TrackSelection trackSelection, DataSource dataSource,
    TrackEncryptionBox[] trackEncryptionBoxes) {
  this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
  this.manifest = manifest;
  this.elementIndex = elementIndex;
  this.trackSelection = trackSelection;
  this.dataSource = dataSource;

  StreamElement streamElement = manifest.streamElements[elementIndex];

  extractorWrappers = new ChunkExtractorWrapper[trackSelection.length()];
  for (int i = 0; i < extractorWrappers.length; i++) {
    int manifestTrackIndex = trackSelection.getIndexInTrackGroup(i);
    Format format = streamElement.formats[manifestTrackIndex];
    int nalUnitLengthFieldLength = streamElement.type == C.TRACK_TYPE_VIDEO ? 4 : 0;
    Track track = new Track(manifestTrackIndex, streamElement.type, streamElement.timescale,
        C.TIME_UNSET, manifest.durationUs, format, Track.TRANSFORMATION_NONE,
        trackEncryptionBoxes, nalUnitLengthFieldLength, null, null);
    FragmentedMp4Extractor extractor = new FragmentedMp4Extractor(
        FragmentedMp4Extractor.FLAG_WORKAROUND_EVERY_VIDEO_FRAME_IS_SYNC_FRAME
        | FragmentedMp4Extractor.FLAG_WORKAROUND_IGNORE_TFDT_BOX, null, track, null);
    extractorWrappers[i] = new ChunkExtractorWrapper(extractor, streamElement.type, format);
  }
}
 
開發者ID:y20k,項目名稱:transistor,代碼行數:34,代碼來源:DefaultSsChunkSource.java

示例8: updateForCurrentTrackSelections

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的package包/類
private void updateForCurrentTrackSelections() {
    if (player == null) {
        return;
    }
    TrackSelectionArray selections = player.getCurrentTrackSelections();
    for (int i = 0; i < selections.length; i++) {
        if (player.getRendererType(i) == C.TRACK_TYPE_VIDEO && selections.get(i) != null) {
            // Video enabled so artwork must be hidden. If the shutter is closed, it will be opened in
            // onRenderedFirstFrame().
            hideArtwork();
            return;
        }
    }
    // Video disabled so the shutter must be closed.
    if (shutterView != null) {
        shutterView.setVisibility(VISIBLE);
    }
    // Display artwork if enabled and available, else hide it.
    if (useArtwork) {
        for (int i = 0; i < selections.length; i++) {
            TrackSelection selection = selections.get(i);
            if (selection != null) {
                for (int j = 0; j < selection.length(); j++) {
                    Metadata metadata = selection.getFormat(j).metadata;
                    if (metadata != null && setArtworkFromMetadata(metadata)) {
                        return;
                    }
                }
            }
        }
        if (setArtworkFromBitmap(null)) {
            return;
        }
    }
    // Artwork disabled or unavailable.
    hideArtwork();
}
 
開發者ID:yangchaojiang,項目名稱:yjPlay,代碼行數:38,代碼來源:SimpleExoPlayerView.java

示例9: updateForCurrentTrackSelections

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的package包/類
private void updateForCurrentTrackSelections() {
    if (player == null) {
        return;
    }
    TrackSelectionArray selections = player.getCurrentTrackSelections();
    for (int i = 0; i < selections.length; i++) {
        if (player.getRendererType(i) == C.TRACK_TYPE_VIDEO && selections.get(i) != null) {
            // Video enabled so artwork must be hidden. If the shutter is closed, it will be opened in
            // onRenderedFirstFrame().
            hideArtwork();
            return;
        }
    }
    // Video disabled so the shutter must be closed.
    if (shutterView != null) {
        shutterView.setVisibility(VISIBLE);
    }
    // Display artwork if enabled and available, else hide it.
    if (useArtwork) {
        for (int i = 0; i < selections.length; i++) {
            TrackSelection selection = selections.get(i);
            if (selection != null) {
                for (int j = 0; j < selection.length(); j++) {
                    Metadata metadata = selection.getFormat(j).metadata;
                    if (metadata != null && setArtworkFromMetadata(metadata)) {
                        return;
                    }
                }
            }
        }
        if (setArtworkFromBitmap(defaultArtwork)) {
            return;
        }
    }
    // Artwork disabled or unavailable.
    hideArtwork();
}
 
開發者ID:Tubitv,項目名稱:TubiPlayer,代碼行數:38,代碼來源:TubiExoPlayerView.java

示例10: updateForCurrentTrackSelections

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的package包/類
private void updateForCurrentTrackSelections() {
  if (player == null) {
    return;
  }
  TrackSelectionArray selections = player.getCurrentTrackSelections();
  for (int i = 0; i < selections.length; i++) {
    if (player.getRendererType(i) == C.TRACK_TYPE_VIDEO && selections.get(i) != null) {
      // Video enabled so artwork must be hidden. If the shutter is closed, it will be opened in
      // onRenderedFirstFrame().
      hideArtwork();
      return;
    }
  }
  // Video disabled so the shutter must be closed.
  if (shutterView != null) {
    shutterView.setVisibility(VISIBLE);
  }
  // Display artwork if enabled and available, else hide it.
  if (useArtwork) {
    for (int i = 0; i < selections.length; i++) {
      TrackSelection selection = selections.get(i);
      if (selection != null) {
        for (int j = 0; j < selection.length(); j++) {
          Metadata metadata = selection.getFormat(j).metadata;
          if (metadata != null && setArtworkFromMetadata(metadata)) {
            return;
          }
        }
      }
    }
    if (setArtworkFromBitmap(defaultArtwork)) {
      return;
    }
  }
  // Artwork disabled or unavailable.
  hideArtwork();
}
 
開發者ID:jcodeing,項目名稱:K-Sonic,代碼行數:38,代碼來源:SimpleExoPlayerView.java

示例11: enableRenderers

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的package包/類
private void enableRenderers(boolean[] rendererWasEnabledFlags, int enabledRendererCount)
    throws ExoPlaybackException {
  enabledRenderers = new Renderer[enabledRendererCount];
  enabledRendererCount = 0;
  for (int i = 0; i < renderers.length; i++) {
    Renderer renderer = renderers[i];
    TrackSelection newSelection = playingPeriodHolder.trackSelections.get(i);
    if (newSelection != null) {
      enabledRenderers[enabledRendererCount++] = renderer;
      if (renderer.getState() == Renderer.STATE_DISABLED) {
        // The renderer needs enabling with its new track selection.
        boolean playing = playWhenReady && state == ExoPlayer.STATE_READY;
        // Consider as joining only if the renderer was previously disabled.
        boolean joining = !rendererWasEnabledFlags[i] && playing;
        // Build an array of formats contained by the selection.
        Format[] formats = new Format[newSelection.length()];
        for (int j = 0; j < formats.length; j++) {
          formats[j] = newSelection.getFormat(j);
        }
        // Enable the renderer.
        renderer.enable(formats, playingPeriodHolder.sampleStreams[i], rendererPositionUs,
            joining, playingPeriodHolder.rendererPositionOffsetUs);
        MediaClock mediaClock = renderer.getMediaClock();
        if (mediaClock != null) {
          if (rendererMediaClock != null) {
            throw ExoPlaybackException.createForUnexpected(
                new IllegalStateException("Multiple renderer media clocks enabled."));
          }
          rendererMediaClock = mediaClock;
          rendererMediaClockSource = renderer;
        }
        // Start the renderer if playing.
        if (playing) {
          renderer.start();
        }
      }
    }
  }
}
 
開發者ID:zhanglibin123488,項目名稱:videoPickPlayer,代碼行數:40,代碼來源:ExoPlayerImplInternal.java

示例12: getFormats

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的package包/類
@NonNull
private static Format[] getFormats(TrackSelection newSelection) {
  // Build an array of formats contained by the selection.
  int length = newSelection != null ? newSelection.length() : 0;
  Format[] formats = new Format[length];
  for (int i = 0; i < length; i++) {
    formats[i] = newSelection.getFormat(i);
  }
  return formats;
}
 
開發者ID:y20k,項目名稱:transistor,代碼行數:11,代碼來源:ExoPlayerImplInternal.java

示例13: enableRenderers

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的package包/類
private void enableRenderers(boolean[] rendererWasEnabledFlags, int enabledRendererCount)
    throws ExoPlaybackException {
  enabledRenderers = new Renderer[enabledRendererCount];
  enabledRendererCount = 0;
  for (int i = 0; i < renderers.length; i++) {
    Renderer renderer = renderers[i];
    TrackSelection newSelection = playingPeriodHolder.trackSelectorResult.selections.get(i);
    if (newSelection != null) {
      enabledRenderers[enabledRendererCount++] = renderer;
      if (renderer.getState() == Renderer.STATE_DISABLED) {
        RendererConfiguration rendererConfiguration =
            playingPeriodHolder.trackSelectorResult.rendererConfigurations[i];
        // The renderer needs enabling with its new track selection.
        boolean playing = playWhenReady && state == ExoPlayer.STATE_READY;
        // Consider as joining only if the renderer was previously disabled.
        boolean joining = !rendererWasEnabledFlags[i] && playing;
        // Build an array of formats contained by the selection.
        Format[] formats = new Format[newSelection.length()];
        for (int j = 0; j < formats.length; j++) {
          formats[j] = newSelection.getFormat(j);
        }
        // Enable the renderer.
        renderer.enable(rendererConfiguration, formats, playingPeriodHolder.sampleStreams[i],
            rendererPositionUs, joining, playingPeriodHolder.getRendererOffset());
        MediaClock mediaClock = renderer.getMediaClock();
        if (mediaClock != null) {
          if (rendererMediaClock != null) {
            throw ExoPlaybackException.createForUnexpected(
                new IllegalStateException("Multiple renderer media clocks enabled."));
          }
          rendererMediaClock = mediaClock;
          rendererMediaClockSource = renderer;
          rendererMediaClock.setPlaybackParameters(playbackParameters);
        }
        // Start the renderer if playing.
        if (playing) {
          renderer.start();
        }
      }
    }
  }
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:43,代碼來源:ExoPlayerImplInternal.java

示例14: enableRenderers

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的package包/類
private void enableRenderers(boolean[] rendererWasEnabledFlags, int enabledRendererCount)
    throws ExoPlaybackException {
  enabledRenderers = new Renderer[enabledRendererCount];
  enabledRendererCount = 0;
  for (int i = 0; i < renderers.length; i++) {
    Renderer renderer = renderers[i];
    TrackSelection newSelection = playingPeriodHolder.trackSelectorResult.selections.get(i);
    if (newSelection != null) {
      enabledRenderers[enabledRendererCount++] = renderer;
      if (renderer.getState() == Renderer.STATE_DISABLED) {
        RendererConfiguration rendererConfiguration =
            playingPeriodHolder.trackSelectorResult.rendererConfigurations[i];
        // The renderer needs enabling with its new track selection.
        boolean playing = playWhenReady && state == ExoPlayer.STATE_READY;
        // Consider as joining only if the renderer was previously disabled.
        boolean joining = !rendererWasEnabledFlags[i] && playing;
        // Build an array of formats contained by the selection.
        Format[] formats = new Format[newSelection.length()];
        for (int j = 0; j < formats.length; j++) {
          formats[j] = newSelection.getFormat(j);
        }
        // Enable the renderer.
        renderer.enable(rendererConfiguration, formats, playingPeriodHolder.sampleStreams[i],
            rendererPositionUs, joining, playingPeriodHolder.getRendererOffset());
        MediaClock mediaClock = renderer.getMediaClock();
        if (mediaClock != null) {
          if (rendererMediaClock != null) {
            throw ExoPlaybackException.createForUnexpected(
                new IllegalStateException("Multiple renderer media clocks enabled."));
          }
          rendererMediaClock = mediaClock;
          rendererMediaClockSource = renderer;
        }
        // Start the renderer if playing.
        if (playing) {
          renderer.start();
        }
      }
    }
  }
}
 
開發者ID:jcodeing,項目名稱:K-Sonic,代碼行數:42,代碼來源:ExoPlayerImplInternal.java

示例15: initializePlaybackLoop

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的package包/類
private void initializePlaybackLoop() throws ExoPlaybackException {
  Assertions.checkNotNull(clock);
  trackSelector.init(new InvalidationListener() {
    @Override
    public void onTrackSelectionsInvalidated() {
      throw new IllegalStateException();
    }
  });
  RendererCapabilities[] rendererCapabilities = new RendererCapabilities[renderers.length];
  for (int i = 0; i < renderers.length; i++) {
    rendererCapabilities[i] = renderers[i].getCapabilities();
  }
  selectorResult = trackSelector.selectTracks(rendererCapabilities,
      mediaPeriod.getTrackGroups());
  SampleStream[] sampleStreams = new SampleStream[renderers.length];
  boolean[] mayRetainStreamFlags = new boolean[renderers.length];
  Arrays.fill(mayRetainStreamFlags, true);
  mediaPeriod.selectTracks(selectorResult.selections.getAll(), mayRetainStreamFlags,
      sampleStreams, new boolean[renderers.length], 0);
  eventListenerHandler.post(new Runnable() {
    @Override
    public void run() {
      for (Player.EventListener eventListener : eventListeners) {
        eventListener.onTracksChanged(selectorResult.groups, selectorResult.selections);
      }
    }
  });

  loadControl.onPrepared();
  loadControl.onTracksSelected(renderers, selectorResult.groups, selectorResult.selections);

  for (int i = 0; i < renderers.length; i++) {
    TrackSelection selection = selectorResult.selections.get(i);
    Format[] formats = new Format[selection.length()];
    for (int j = 0; j < formats.length; j++) {
      formats[j] = selection.getFormat(j);
    }
    renderers[i].enable(selectorResult.rendererConfigurations[i], formats, sampleStreams[i], 0,
        false, 0);
    renderers[i].setCurrentStreamFinal();
  }

  rendererPositionUs = 0;
  changePlaybackState(Player.STATE_BUFFERING);
  playbackHandler.post(this);
}
 
開發者ID:y20k,項目名稱:transistor,代碼行數:47,代碼來源:FakeSimpleExoPlayer.java


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