com.google.android.exoplayer2.util.Util.toArray()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(1.4k)|赞(0)|评价(0)|浏览(257)

本文整理了Java中com.google.android.exoplayer2.util.Util.toArray()方法的一些代码示例,展示了Util.toArray()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.toArray()方法的具体详情如下:
包路径:com.google.android.exoplayer2.util.Util
类名称:Util
方法名:toArray

Util.toArray介绍

[英]Converts a list of integers to a primitive array.
[中]将整数列表转换为基元数组。

代码示例

代码示例来源:origin: google/ExoPlayer

  1. selectedTrackIndices);
  2. return selectedTrackIndices.size() < 2 ? NO_TRACKS : Util.toArray(selectedTrackIndices);

代码示例来源:origin: google/ExoPlayer

  1. private int[] getVideoTrackIndices(
  2. TrackGroup trackGroup,
  3. int[] formatSupports,
  4. String[] formatIds,
  5. boolean canIncludeAdditionalFormats) {
  6. List<Integer> trackIndices = new ArrayList<>();
  7. // Always select explicitly listed representations.
  8. for (String formatId : formatIds) {
  9. int trackIndex = getTrackIndex(trackGroup, formatId);
  10. Log.d(tag, "Adding base video format: "
  11. + Format.toLogString(trackGroup.getFormat(trackIndex)));
  12. trackIndices.add(trackIndex);
  13. }
  14. // Select additional video representations, if supported by the device.
  15. if (canIncludeAdditionalFormats) {
  16. for (int i = 0; i < trackGroup.length; i++) {
  17. if (!trackIndices.contains(i) && isFormatHandled(formatSupports[i])) {
  18. Log.d(tag, "Adding extra video format: "
  19. + Format.toLogString(trackGroup.getFormat(i)));
  20. trackIndices.add(i);
  21. }
  22. }
  23. }
  24. int[] trackIndicesArray = Util.toArray(trackIndices);
  25. Arrays.sort(trackIndicesArray);
  26. return trackIndicesArray;
  27. }

相关文章