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

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

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

Util.split介绍

[英]Splits a string using value.split(regex, -1). Note: this is is similar to String#split(String) but empty matches at the end of the string will not be omitted from the returned array.
[中]使用值拆分字符串。split(regex,-1)。注意:这与字符串#split(String)类似,但返回的数组中不会忽略字符串末尾的空匹配项。

代码示例

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

/**
 * Splits a codecs sequence string, as defined in RFC 6381, into individual codec strings.
 *
 * @param codecs A codec sequence string, as defined in RFC 6381.
 * @return The split codecs, or an array of length zero if the input was empty.
 */
public static String[] splitCodecs(String codecs) {
 if (TextUtils.isEmpty(codecs)) {
  return new String[0];
 }
 return split(codecs.trim(), "(\\s*,\\s*)");
}

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

/**
 * Parses a WebVTT timestamp.
 *
 * @param timestamp The timestamp string.
 * @return The parsed timestamp in microseconds.
 * @throws NumberFormatException If the timestamp could not be parsed.
 */
public static long parseTimestampUs(String timestamp) throws NumberFormatException {
 long value = 0;
 String[] parts = Util.splitAtFirst(timestamp, "\\.");
 String[] subparts = Util.split(parts[0], ":");
 for (String subpart : subparts) {
  value = (value * 60) + Long.parseLong(subpart);
 }
 value *= 1000;
 if (parts.length == 2) {
  value += Long.parseLong(parts[1]);
 }
 return value * 1000;
}

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

private String[] parseStyleIds(String parentStyleIds) {
 parentStyleIds = parentStyleIds.trim();
 return parentStyleIds.isEmpty() ? new String[0] : Util.split(parentStyleIds, "\\s+");
}

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

/**
  * Compares version strings of format "12.123.35.23".
  */
 private static int compareVersionStrings(String versionLeft, String versionRight) {
  if (versionLeft == null || versionRight == null) {
   return 0;
  }
  String[] versionStringsLeft = Util.split(versionLeft, "\\.");
  String[] versionStringsRight = Util.split(versionRight, "\\.");
  int minLength = Math.min(versionStringsLeft.length, versionStringsRight.length);
  for (int i = 0; i < minLength; i++) {
   if (!versionStringsLeft[i].equals(versionStringsRight[i])) {
    try {
     int versionIntLeft = Integer.parseInt(versionStringsLeft[i]);
     int versionIntRight = Integer.parseInt(versionStringsRight[i]);
     return versionIntLeft - versionIntRight;
    } catch (NumberFormatException e) {
     return 0;
    }
   }
  }
  return 0;
 }
}

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

public static StartTag buildStartTag(String fullTagExpression, int position) {
 fullTagExpression = fullTagExpression.trim();
 if (fullTagExpression.isEmpty()) {
  return null;
 }
 int voiceStartIndex = fullTagExpression.indexOf(" ");
 String voice;
 if (voiceStartIndex == -1) {
  voice = "";
 } else {
  voice = fullTagExpression.substring(voiceStartIndex).trim();
  fullTagExpression = fullTagExpression.substring(0, voiceStartIndex);
 }
 String[] nameAndClasses = Util.split(fullTagExpression, "\\.");
 String name = nameAndClasses[0];
 String[] classes;
 if (nameAndClasses.length > 1) {
  classes = Arrays.copyOfRange(nameAndClasses, 1, nameAndClasses.length);
 } else {
  classes = NO_CLASSES;
 }
 return new StartTag(name, position, voice, classes);
}

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

private FrameAndTickRate parseFrameAndTickRates(XmlPullParser xmlParser)
  throws SubtitleDecoderException {
 int frameRate = DEFAULT_FRAME_RATE;
 String frameRateString = xmlParser.getAttributeValue(TTP, "frameRate");
 if (frameRateString != null) {
  frameRate = Integer.parseInt(frameRateString);
 }
 float frameRateMultiplier = 1;
 String frameRateMultiplierString = xmlParser.getAttributeValue(TTP, "frameRateMultiplier");
 if (frameRateMultiplierString != null) {
  String[] parts = Util.split(frameRateMultiplierString, " ");
  if (parts.length != 2) {
   throw new SubtitleDecoderException("frameRateMultiplier doesn't have 2 parts");
  }
  float numerator = Integer.parseInt(parts[0]);
  float denominator = Integer.parseInt(parts[1]);
  frameRateMultiplier = numerator / denominator;
 }
 int subFrameRate = DEFAULT_FRAME_AND_TICK_RATE.subFrameRate;
 String subFrameRateString = xmlParser.getAttributeValue(TTP, "subFrameRate");
 if (subFrameRateString != null) {
  subFrameRate = Integer.parseInt(subFrameRateString);
 }
 int tickRate = DEFAULT_FRAME_AND_TICK_RATE.tickRate;
 String tickRateString = xmlParser.getAttributeValue(TTP, "tickRate");
 if (tickRateString != null) {
  tickRate = Integer.parseInt(tickRateString);
 }
 return new FrameAndTickRate(frameRate * frameRateMultiplier, subFrameRate, tickRate);
}

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

/**
 * Sets the target of a {@link WebvttCssStyle} by splitting a selector of the form
 * {@code ::cue(tag#id.class1.class2[voice="someone"]}, where every element is optional.
 */
private void applySelectorToStyle(WebvttCssStyle style, String selector) {
 if ("".equals(selector)) {
  return; // Universal selector.
 }
 int voiceStartIndex = selector.indexOf('[');
 if (voiceStartIndex != -1) {
  Matcher matcher = VOICE_NAME_PATTERN.matcher(selector.substring(voiceStartIndex));
  if (matcher.matches()) {
   style.setTargetVoice(matcher.group(1));
  }
  selector = selector.substring(0, voiceStartIndex);
 }
 String[] classDivision = Util.split(selector, "\\.");
 String tagAndIdDivision = classDivision[0];
 int idPrefixIndex = tagAndIdDivision.indexOf('#');
 if (idPrefixIndex != -1) {
  style.setTargetTagName(tagAndIdDivision.substring(0, idPrefixIndex));
  style.setTargetId(tagAndIdDivision.substring(idPrefixIndex + 1)); // We discard the '#'.
 } else {
  style.setTargetTagName(tagAndIdDivision);
 }
 if (classDivision.length > 1) {
  style.setTargetClasses(Arrays.copyOfRange(classDivision, 1, classDivision.length));
 }
}

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

groupedAdaptationSetIndices[groupCount++] = new int[] {i};
} else {
 String[] extraAdaptationSetIds = Util.split(adaptationSetSwitchingProperty.value, ",");
 int[] adaptationSetIndices = new int[1 + extraAdaptationSetIds.length];
 adaptationSetIndices[0] = i;

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

String[] sysDisplaySizeParts = split(sysDisplaySize.trim(), "x");
if (sysDisplaySizeParts.length == 2) {
 int width = Integer.parseInt(sysDisplaySizeParts[0]);

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

@Override
public long open(DataSpec dataSpec) throws IOException {
 transferInitializing(dataSpec);
 this.dataSpec = dataSpec;
 Uri uri = dataSpec.uri;
 String scheme = uri.getScheme();
 if (!SCHEME_DATA.equals(scheme)) {
  throw new ParserException("Unsupported scheme: " + scheme);
 }
 String[] uriParts = Util.split(uri.getSchemeSpecificPart(), ",");
 if (uriParts.length != 2) {
  throw new ParserException("Unexpected URI format: " + uri);
 }
 String dataString = uriParts[1];
 if (uriParts[0].contains(";base64")) {
  try {
   data = Base64.decode(dataString, 0);
  } catch (IllegalArgumentException e) {
   throw new ParserException("Error while parsing Base64 encoded string: " + dataString, e);
  }
 } else {
  // TODO: Add support for other charsets.
  data = Util.getUtf8Bytes(URLDecoder.decode(dataString, C.ASCII_NAME));
 }
 transferStarted(dataSpec);
 return data.length;
}

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

private static void parseFontSize(String expression, TtmlStyle out) throws
  SubtitleDecoderException {
 String[] expressions = Util.split(expression, "\\s+");
 Matcher matcher;
 if (expressions.length == 1) {

相关文章