当前位置: 首页>>代码示例>>Java>>正文


Java ParsableByteArray.readString方法代码示例

本文整理汇总了Java中com.google.android.exoplayer2.util.ParsableByteArray.readString方法的典型用法代码示例。如果您正苦于以下问题:Java ParsableByteArray.readString方法的具体用法?Java ParsableByteArray.readString怎么用?Java ParsableByteArray.readString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.exoplayer2.util.ParsableByteArray的用法示例。


在下文中一共展示了ParsableByteArray.readString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readVorbisCommentHeader

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Reads a vorbis comment header.
 *
 * @see <a href="https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-640004.2.3">
 *     Vorbis spec/Comment header</a>
 * @param headerData a {@link ParsableByteArray} wrapping the header data.
 * @return a {@link VorbisUtil.CommentHeader} with all the comments.
 * @throws ParserException thrown if invalid capture pattern is detected.
 */
public static CommentHeader readVorbisCommentHeader(ParsableByteArray headerData)
    throws ParserException {

  verifyVorbisHeaderCapturePattern(0x03, headerData, false);
  int length = 7;

  int len = (int) headerData.readLittleEndianUnsignedInt();
  length += 4;
  String vendor = headerData.readString(len);
  length += vendor.length();

  long commentListLen = headerData.readLittleEndianUnsignedInt();
  String[] comments = new String[(int) commentListLen];
  length += 4;
  for (int i = 0; i < commentListLen; i++) {
    len = (int) headerData.readLittleEndianUnsignedInt();
    length += 4;
    comments[i] = headerData.readString(len);
    length += comments[i].length();
  }
  if ((headerData.readUnsignedByte() & 0x01) == 0) {
    throw new ParserException("framing bit expected to be set");
  }
  length += 1;
  return new CommentHeader(vendor, comments, length);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:36,代码来源:VorbisUtil.java

示例2: readSubtitleText

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private static String readSubtitleText(ParsableByteArray parsableByteArray)
    throws SubtitleDecoderException {
  assertTrue(parsableByteArray.bytesLeft() >= SIZE_SHORT);
  int textLength = parsableByteArray.readUnsignedShort();
  if (textLength == 0) {
    return "";
  }
  if (parsableByteArray.bytesLeft() >= SIZE_BOM_UTF16) {
    char firstChar = parsableByteArray.peekChar();
    if (firstChar == BOM_UTF16_BE || firstChar == BOM_UTF16_LE) {
      return parsableByteArray.readString(textLength, Charset.forName(C.UTF16_NAME));
    }
  }
  return parsableByteArray.readString(textLength, Charset.forName(C.UTF8_NAME));
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:16,代码来源:Tx3gDecoder.java

示例3: parseSelector

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Returns a string containing the selector. The input is expected to have the form
 * {@code ::cue(tag#id.class1.class2[voice="someone"]}, where every element is optional.
 *
 * @param input From which the selector is obtained.
 * @return A string containing the target, empty string if the selector is universal
 *     (targets all cues) or null if an error was encountered.
 */
private static String parseSelector(ParsableByteArray input, StringBuilder stringBuilder) {
  skipWhitespaceAndComments(input);
  if (input.bytesLeft() < 5) {
    return null;
  }
  String cueSelector = input.readString(5);
  if (!"::cue".equals(cueSelector)) {
    return null;
  }
  int position = input.getPosition();
  String token = parseNextToken(input, stringBuilder);
  if (token == null) {
    return null;
  }
  if (BLOCK_START.equals(token)) {
    input.setPosition(position);
    return "";
  }
  String target = null;
  if ("(".equals(token)) {
    target = readCueTarget(input);
  }
  token = parseNextToken(input, stringBuilder);
  if (!")".equals(token) || token == null) {
    return null;
  }
  return target;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:37,代码来源:CssParser.java


注:本文中的com.google.android.exoplayer2.util.ParsableByteArray.readString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。