Java Code Examples for com.google.android.exoplayer2.trackselection.TrackSelectorResult#isRendererEnabled()

The following examples show how to use com.google.android.exoplayer2.trackselection.TrackSelectorResult#isRendererEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExoPlayerImplInternal.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
private void enableRenderers(boolean[] rendererWasEnabledFlags, int totalEnabledRendererCount)
    throws ExoPlaybackException {
  enabledRenderers = new Renderer[totalEnabledRendererCount];
  int enabledRendererCount = 0;
  TrackSelectorResult trackSelectorResult = queue.getPlayingPeriod().getTrackSelectorResult();
  // Reset all disabled renderers before enabling any new ones. This makes sure resources released
  // by the disabled renderers will be available to renderers that are being enabled.
  for (int i = 0; i < renderers.length; i++) {
    if (!trackSelectorResult.isRendererEnabled(i)) {
      renderers[i].reset();
    }
  }
  // Enable the renderers.
  for (int i = 0; i < renderers.length; i++) {
    if (trackSelectorResult.isRendererEnabled(i)) {
      enableRenderer(i, rendererWasEnabledFlags[i], enabledRendererCount++);
    }
  }
}
 
Example 2
Source File: ExoPlayerImplInternal.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void enableRenderers(boolean[] rendererWasEnabledFlags, int totalEnabledRendererCount)
    throws ExoPlaybackException {
  enabledRenderers = new Renderer[totalEnabledRendererCount];
  int enabledRendererCount = 0;
  TrackSelectorResult trackSelectorResult = queue.getPlayingPeriod().getTrackSelectorResult();
  // Reset all disabled renderers before enabling any new ones. This makes sure resources released
  // by the disabled renderers will be available to renderers that are being enabled.
  for (int i = 0; i < renderers.length; i++) {
    if (!trackSelectorResult.isRendererEnabled(i)) {
      renderers[i].reset();
    }
  }
  // Enable the renderers.
  for (int i = 0; i < renderers.length; i++) {
    if (trackSelectorResult.isRendererEnabled(i)) {
      enableRenderer(i, rendererWasEnabledFlags[i], enabledRendererCount++);
    }
  }
}
 
Example 3
Source File: ExoPlayerImplInternal.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void enableRenderers(boolean[] rendererWasEnabledFlags, int totalEnabledRendererCount)
    throws ExoPlaybackException {
  enabledRenderers = new Renderer[totalEnabledRendererCount];
  int enabledRendererCount = 0;
  TrackSelectorResult trackSelectorResult = queue.getPlayingPeriod().getTrackSelectorResult();
  // Reset all disabled renderers before enabling any new ones. This makes sure resources released
  // by the disabled renderers will be available to renderers that are being enabled.
  for (int i = 0; i < renderers.length; i++) {
    if (!trackSelectorResult.isRendererEnabled(i)) {
      renderers[i].reset();
    }
  }
  // Enable the renderers.
  for (int i = 0; i < renderers.length; i++) {
    if (trackSelectorResult.isRendererEnabled(i)) {
      enableRenderer(i, rendererWasEnabledFlags[i], enabledRendererCount++);
    }
  }
}
 
Example 4
Source File: MediaPeriodHolder.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void enableTrackSelectionsInResult(TrackSelectorResult trackSelectorResult) {
  for (int i = 0; i < trackSelectorResult.length; i++) {
    boolean rendererEnabled = trackSelectorResult.isRendererEnabled(i);
    TrackSelection trackSelection = trackSelectorResult.selections.get(i);
    if (rendererEnabled && trackSelection != null) {
      trackSelection.enable();
    }
  }
}
 
Example 5
Source File: MediaPeriodHolder.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void disableTrackSelectionsInResult(TrackSelectorResult trackSelectorResult) {
  for (int i = 0; i < trackSelectorResult.length; i++) {
    boolean rendererEnabled = trackSelectorResult.isRendererEnabled(i);
    TrackSelection trackSelection = trackSelectorResult.selections.get(i);
    if (rendererEnabled && trackSelection != null) {
      trackSelection.disable();
    }
  }
}
 
Example 6
Source File: MediaPeriodHolder.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void enableTrackSelectionsInResult(TrackSelectorResult trackSelectorResult) {
  for (int i = 0; i < trackSelectorResult.length; i++) {
    boolean rendererEnabled = trackSelectorResult.isRendererEnabled(i);
    TrackSelection trackSelection = trackSelectorResult.selections.get(i);
    if (rendererEnabled && trackSelection != null) {
      trackSelection.enable();
    }
  }
}
 
Example 7
Source File: MediaPeriodHolder.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void disableTrackSelectionsInResult(TrackSelectorResult trackSelectorResult) {
  for (int i = 0; i < trackSelectorResult.length; i++) {
    boolean rendererEnabled = trackSelectorResult.isRendererEnabled(i);
    TrackSelection trackSelection = trackSelectorResult.selections.get(i);
    if (rendererEnabled && trackSelection != null) {
      trackSelection.disable();
    }
  }
}
 
Example 8
Source File: MediaPeriodHolder.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void enableTrackSelectionsInResult() {
  TrackSelectorResult trackSelectorResult = this.trackSelectorResult;
  if (!isLoadingMediaPeriod() || trackSelectorResult == null) {
    return;
  }
  for (int i = 0; i < trackSelectorResult.length; i++) {
    boolean rendererEnabled = trackSelectorResult.isRendererEnabled(i);
    TrackSelection trackSelection = trackSelectorResult.selections.get(i);
    if (rendererEnabled && trackSelection != null) {
      trackSelection.enable();
    }
  }
}
 
Example 9
Source File: MediaPeriodHolder.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void disableTrackSelectionsInResult() {
  TrackSelectorResult trackSelectorResult = this.trackSelectorResult;
  if (!isLoadingMediaPeriod() || trackSelectorResult == null) {
    return;
  }
  for (int i = 0; i < trackSelectorResult.length; i++) {
    boolean rendererEnabled = trackSelectorResult.isRendererEnabled(i);
    TrackSelection trackSelection = trackSelectorResult.selections.get(i);
    if (rendererEnabled && trackSelection != null) {
      trackSelection.disable();
    }
  }
}
 
Example 10
Source File: MediaPeriodHolder.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * For each renderer of type {@link C#TRACK_TYPE_NONE} that was enabled, we will associate it with
 * a dummy {@link EmptySampleStream}.
 */
private void associateNoSampleRenderersWithEmptySampleStream(
    @NullableType SampleStream[] sampleStreams) {
  TrackSelectorResult trackSelectorResult = Assertions.checkNotNull(this.trackSelectorResult);
  for (int i = 0; i < rendererCapabilities.length; i++) {
    if (rendererCapabilities[i].getTrackType() == C.TRACK_TYPE_NONE
        && trackSelectorResult.isRendererEnabled(i)) {
      sampleStreams[i] = new EmptySampleStream();
    }
  }
}
 
Example 11
Source File: MediaPeriodHolder.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void enableTrackSelectionsInResult() {
  TrackSelectorResult trackSelectorResult = this.trackSelectorResult;
  if (!isLoadingMediaPeriod() || trackSelectorResult == null) {
    return;
  }
  for (int i = 0; i < trackSelectorResult.length; i++) {
    boolean rendererEnabled = trackSelectorResult.isRendererEnabled(i);
    TrackSelection trackSelection = trackSelectorResult.selections.get(i);
    if (rendererEnabled && trackSelection != null) {
      trackSelection.enable();
    }
  }
}
 
Example 12
Source File: MediaPeriodHolder.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void disableTrackSelectionsInResult() {
  TrackSelectorResult trackSelectorResult = this.trackSelectorResult;
  if (!isLoadingMediaPeriod() || trackSelectorResult == null) {
    return;
  }
  for (int i = 0; i < trackSelectorResult.length; i++) {
    boolean rendererEnabled = trackSelectorResult.isRendererEnabled(i);
    TrackSelection trackSelection = trackSelectorResult.selections.get(i);
    if (rendererEnabled && trackSelection != null) {
      trackSelection.disable();
    }
  }
}
 
Example 13
Source File: MediaPeriodHolder.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * For each renderer of type {@link C#TRACK_TYPE_NONE} that was enabled, we will associate it with
 * a dummy {@link EmptySampleStream}.
 */
private void associateNoSampleRenderersWithEmptySampleStream(
    @NullableType SampleStream[] sampleStreams) {
  TrackSelectorResult trackSelectorResult = Assertions.checkNotNull(this.trackSelectorResult);
  for (int i = 0; i < rendererCapabilities.length; i++) {
    if (rendererCapabilities[i].getTrackType() == C.TRACK_TYPE_NONE
        && trackSelectorResult.isRendererEnabled(i)) {
      sampleStreams[i] = new EmptySampleStream();
    }
  }
}