Java Code Examples for com.google.android.exoplayer2.trackselection.MappingTrackSelector.MappedTrackInfo#getRendererCount()

The following examples show how to use com.google.android.exoplayer2.trackselection.MappingTrackSelector.MappedTrackInfo#getRendererCount() . 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: DownloadHelper.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Convenience method to add selections of tracks for all specified audio languages. If an audio
 * track in one of the specified languages is not available, the default fallback audio track is
 * used instead. Must not be called until after preparation completes.
 *
 * @param languages A list of audio languages for which tracks should be added to the download
 *     selection, as IETF BCP 47 conformant tags.
 */
public void addAudioLanguagesToSelection(String... languages) {
  assertPreparedWithMedia();
  for (int periodIndex = 0; periodIndex < mappedTrackInfos.length; periodIndex++) {
    DefaultTrackSelector.ParametersBuilder parametersBuilder =
        DEFAULT_TRACK_SELECTOR_PARAMETERS_WITHOUT_CONTEXT.buildUpon();
    MappedTrackInfo mappedTrackInfo = mappedTrackInfos[periodIndex];
    int rendererCount = mappedTrackInfo.getRendererCount();
    for (int rendererIndex = 0; rendererIndex < rendererCount; rendererIndex++) {
      if (mappedTrackInfo.getRendererType(rendererIndex) != C.TRACK_TYPE_AUDIO) {
        parametersBuilder.setRendererDisabled(rendererIndex, /* disabled= */ true);
      }
    }
    for (String language : languages) {
      parametersBuilder.setPreferredAudioLanguage(language);
      addTrackSelection(periodIndex, parametersBuilder.build());
    }
  }
}
 
Example 2
Source File: DownloadHelper.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Convenience method to add selections of tracks for all specified text languages. Must not be
 * called until after preparation completes.
 *
 * @param selectUndeterminedTextLanguage Whether a text track with undetermined language should be
 *     selected for downloading if no track with one of the specified {@code languages} is
 *     available.
 * @param languages A list of text languages for which tracks should be added to the download
 *     selection, as IETF BCP 47 conformant tags.
 */
public void addTextLanguagesToSelection(
    boolean selectUndeterminedTextLanguage, String... languages) {
  assertPreparedWithMedia();
  for (int periodIndex = 0; periodIndex < mappedTrackInfos.length; periodIndex++) {
    DefaultTrackSelector.ParametersBuilder parametersBuilder =
        DEFAULT_TRACK_SELECTOR_PARAMETERS_WITHOUT_CONTEXT.buildUpon();
    MappedTrackInfo mappedTrackInfo = mappedTrackInfos[periodIndex];
    int rendererCount = mappedTrackInfo.getRendererCount();
    for (int rendererIndex = 0; rendererIndex < rendererCount; rendererIndex++) {
      if (mappedTrackInfo.getRendererType(rendererIndex) != C.TRACK_TYPE_TEXT) {
        parametersBuilder.setRendererDisabled(rendererIndex, /* disabled= */ true);
      }
    }
    parametersBuilder.setSelectUndeterminedTextLanguage(selectUndeterminedTextLanguage);
    for (String language : languages) {
      parametersBuilder.setPreferredTextLanguage(language);
      addTrackSelection(periodIndex, parametersBuilder.build());
    }
  }
}
 
Example 3
Source File: DownloadHelper.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Convenience method to add selections of tracks for all specified audio languages. If an audio
 * track in one of the specified languages is not available, the default fallback audio track is
 * used instead. Must not be called until after preparation completes.
 *
 * @param languages A list of audio languages for which tracks should be added to the download
 *     selection, as IETF BCP 47 conformant tags.
 */
public void addAudioLanguagesToSelection(String... languages) {
  assertPreparedWithMedia();
  for (int periodIndex = 0; periodIndex < mappedTrackInfos.length; periodIndex++) {
    DefaultTrackSelector.ParametersBuilder parametersBuilder =
        DEFAULT_TRACK_SELECTOR_PARAMETERS.buildUpon();
    MappedTrackInfo mappedTrackInfo = mappedTrackInfos[periodIndex];
    int rendererCount = mappedTrackInfo.getRendererCount();
    for (int rendererIndex = 0; rendererIndex < rendererCount; rendererIndex++) {
      if (mappedTrackInfo.getRendererType(rendererIndex) != C.TRACK_TYPE_AUDIO) {
        parametersBuilder.setRendererDisabled(rendererIndex, /* disabled= */ true);
      }
    }
    for (String language : languages) {
      parametersBuilder.setPreferredAudioLanguage(language);
      addTrackSelection(periodIndex, parametersBuilder.build());
    }
  }
}
 
Example 4
Source File: DownloadHelper.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Convenience method to add selections of tracks for all specified text languages. Must not be
 * called until after preparation completes.
 *
 * @param selectUndeterminedTextLanguage Whether a text track with undetermined language should be
 *     selected for downloading if no track with one of the specified {@code languages} is
 *     available.
 * @param languages A list of text languages for which tracks should be added to the download
 *     selection, as IETF BCP 47 conformant tags.
 */
public void addTextLanguagesToSelection(
    boolean selectUndeterminedTextLanguage, String... languages) {
  assertPreparedWithMedia();
  for (int periodIndex = 0; periodIndex < mappedTrackInfos.length; periodIndex++) {
    DefaultTrackSelector.ParametersBuilder parametersBuilder =
        DEFAULT_TRACK_SELECTOR_PARAMETERS.buildUpon();
    MappedTrackInfo mappedTrackInfo = mappedTrackInfos[periodIndex];
    int rendererCount = mappedTrackInfo.getRendererCount();
    for (int rendererIndex = 0; rendererIndex < rendererCount; rendererIndex++) {
      if (mappedTrackInfo.getRendererType(rendererIndex) != C.TRACK_TYPE_TEXT) {
        parametersBuilder.setRendererDisabled(rendererIndex, /* disabled= */ true);
      }
    }
    parametersBuilder.setSelectUndeterminedTextLanguage(selectUndeterminedTextLanguage);
    for (String language : languages) {
      parametersBuilder.setPreferredTextLanguage(language);
      addTrackSelection(periodIndex, parametersBuilder.build());
    }
  }
}
 
Example 5
Source File: DownloadHelper.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Convenience method to add selections of tracks for all specified audio languages. If an audio
 * track in one of the specified languages is not available, the default fallback audio track is
 * used instead. Must not be called until after preparation completes.
 *
 * @param languages A list of audio languages for which tracks should be added to the download
 *     selection, as IETF BCP 47 conformant tags.
 */
public void addAudioLanguagesToSelection(String... languages) {
  assertPreparedWithMedia();
  for (int periodIndex = 0; periodIndex < mappedTrackInfos.length; periodIndex++) {
    DefaultTrackSelector.ParametersBuilder parametersBuilder =
        DEFAULT_TRACK_SELECTOR_PARAMETERS.buildUpon();
    MappedTrackInfo mappedTrackInfo = mappedTrackInfos[periodIndex];
    int rendererCount = mappedTrackInfo.getRendererCount();
    for (int rendererIndex = 0; rendererIndex < rendererCount; rendererIndex++) {
      if (mappedTrackInfo.getRendererType(rendererIndex) != C.TRACK_TYPE_AUDIO) {
        parametersBuilder.setRendererDisabled(rendererIndex, /* disabled= */ true);
      }
    }
    for (String language : languages) {
      parametersBuilder.setPreferredAudioLanguage(language);
      addTrackSelection(periodIndex, parametersBuilder.build());
    }
  }
}
 
Example 6
Source File: DownloadHelper.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Convenience method to add selections of tracks for all specified text languages. Must not be
 * called until after preparation completes.
 *
 * @param selectUndeterminedTextLanguage Whether a text track with undetermined language should be
 *     selected for downloading if no track with one of the specified {@code languages} is
 *     available.
 * @param languages A list of text languages for which tracks should be added to the download
 *     selection, as IETF BCP 47 conformant tags.
 */
public void addTextLanguagesToSelection(
    boolean selectUndeterminedTextLanguage, String... languages) {
  assertPreparedWithMedia();
  for (int periodIndex = 0; periodIndex < mappedTrackInfos.length; periodIndex++) {
    DefaultTrackSelector.ParametersBuilder parametersBuilder =
        DEFAULT_TRACK_SELECTOR_PARAMETERS.buildUpon();
    MappedTrackInfo mappedTrackInfo = mappedTrackInfos[periodIndex];
    int rendererCount = mappedTrackInfo.getRendererCount();
    for (int rendererIndex = 0; rendererIndex < rendererCount; rendererIndex++) {
      if (mappedTrackInfo.getRendererType(rendererIndex) != C.TRACK_TYPE_TEXT) {
        parametersBuilder.setRendererDisabled(rendererIndex, /* disabled= */ true);
      }
    }
    parametersBuilder.setSelectUndeterminedTextLanguage(selectUndeterminedTextLanguage);
    for (String language : languages) {
      parametersBuilder.setPreferredTextLanguage(language);
      addTrackSelection(periodIndex, parametersBuilder.build());
    }
  }
}