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


Java ParsableByteArray.readLine方法代码示例

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


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

示例1: getNextEvent

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Positions the input right before the next event, and returns the kind of event found. Does not
 * consume any data from such event, if any.
 *
 * @return The kind of event found.
 */
private static int getNextEvent(ParsableByteArray parsableWebvttData) {
  int foundEvent = EVENT_NONE;
  int currentInputPosition = 0;
  while (foundEvent == EVENT_NONE) {
    currentInputPosition = parsableWebvttData.getPosition();
    String line = parsableWebvttData.readLine();
    if (line == null) {
      foundEvent = EVENT_END_OF_FILE;
    } else if (STYLE_START.equals(line)) {
      foundEvent = EVENT_STYLE_BLOCK;
    } else if (COMMENT_START.startsWith(line)) {
      foundEvent = EVENT_COMMENT;
    } else {
      foundEvent = EVENT_CUE;
    }
  }
  parsableWebvttData.setPosition(currentInputPosition);
  return foundEvent;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:26,代码来源:WebvttDecoder.java

示例2: if

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Parses the next valid WebVTT cue in a parsable array, including timestamps, settings and text.
 *
 * @param webvttData Parsable WebVTT file data.
 * @param builder Builder for WebVTT Cues.
 * @param styles List of styles defined by the CSS style blocks preceeding the cues.
 * @return Whether a valid Cue was found.
 */
/* package */ boolean parseCue(ParsableByteArray webvttData, WebvttCue.Builder builder,
    List<WebvttCssStyle> styles) {
  String firstLine = webvttData.readLine();
  Matcher cueHeaderMatcher = WebvttCueParser.CUE_HEADER_PATTERN.matcher(firstLine);
  if (cueHeaderMatcher.matches()) {
    // We have found the timestamps in the first line. No id present.
    return parseCue(null, cueHeaderMatcher, webvttData, builder, textBuilder, styles);
  } else {
    // The first line is not the timestamps, but could be the cue id.
    String secondLine = webvttData.readLine();
    cueHeaderMatcher = WebvttCueParser.CUE_HEADER_PATTERN.matcher(secondLine);
    if (cueHeaderMatcher.matches()) {
      // We can do the rest of the parsing, including the id.
      return parseCue(firstLine.trim(), cueHeaderMatcher, webvttData, builder, textBuilder,
          styles);
    }
  }
  return false;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:28,代码来源:WebvttCueParser.java

示例3: parseCue

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private static boolean parseCue(String id, Matcher cueHeaderMatcher, ParsableByteArray webvttData,
    WebvttCue.Builder builder, StringBuilder textBuilder, List<WebvttCssStyle> styles) {
  try {
    // Parse the cue start and end times.
    builder.setStartTime(WebvttParserUtil.parseTimestampUs(cueHeaderMatcher.group(1)))
        .setEndTime(WebvttParserUtil.parseTimestampUs(cueHeaderMatcher.group(2)));
  } catch (NumberFormatException e) {
    Log.w(TAG, "Skipping cue with bad header: " + cueHeaderMatcher.group());
    return false;
  }

  parseCueSettingsList(cueHeaderMatcher.group(3), builder);

  // Parse the cue text.
  textBuilder.setLength(0);
  String line;
  while ((line = webvttData.readLine()) != null && !line.isEmpty()) {
    if (textBuilder.length() > 0) {
      textBuilder.append("\n");
    }
    textBuilder.append(line.trim());
  }
  parseCueText(id, textBuilder.toString(), builder, styles);
  return true;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:26,代码来源:WebvttCueParser.java

示例4: findNextCueHeader

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Reads lines up to and including the next WebVTT cue header.
 *
 * @param input The input from which lines should be read.
 * @return A {@link Matcher} for the WebVTT cue header, or null if the end of the input was
 *     reached without a cue header being found. In the case that a cue header is found, groups 1,
 *     2 and 3 of the returned matcher contain the start time, end time and settings list.
 */
public static Matcher findNextCueHeader(ParsableByteArray input) {
  String line;
  while ((line = input.readLine()) != null) {
    if (COMMENT.matcher(line).matches()) {
      // Skip until the end of the comment block.
      while ((line = input.readLine()) != null && !line.isEmpty()) {}
    } else {
      Matcher cueHeaderMatcher = WebvttCueParser.CUE_HEADER_PATTERN.matcher(line);
      if (cueHeaderMatcher.matches()) {
        return cueHeaderMatcher;
      }
    }
  }
  return null;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:24,代码来源:WebvttParserUtil.java

示例5: skipStyleBlock

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
static void skipStyleBlock(ParsableByteArray input) {
  // The style block cannot contain empty lines, so we assume the input ends when a empty line
  // is found.
  String line;
  do {
    line = input.readLine();
  } while (!TextUtils.isEmpty(line));
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:9,代码来源:CssParser.java

示例6: validateWebvttHeaderLine

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Reads and validates the first line of a WebVTT file.
 *
 * @param input The input from which the line should be read.
 * @throws SubtitleDecoderException If the line isn't the start of a valid WebVTT file.
 */
public static void validateWebvttHeaderLine(ParsableByteArray input)
    throws SubtitleDecoderException {
  String line = input.readLine();
  if (line == null || !HEADER.matcher(line).matches()) {
    throw new SubtitleDecoderException("Expected WEBVTT. Got " + line);
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:14,代码来源:WebvttParserUtil.java

示例7: decode

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
@Override
protected SubripSubtitle decode(byte[] bytes, int length, boolean reset) {
  ArrayList<Cue> cues = new ArrayList<>();
  LongArray cueTimesUs = new LongArray();
  ParsableByteArray subripData = new ParsableByteArray(bytes, length);
  String currentLine;

  while ((currentLine = subripData.readLine()) != null) {
    if (currentLine.length() == 0) {
      // Skip blank lines.
      continue;
    }

    // Parse the index line as a sanity check.
    try {
      Integer.parseInt(currentLine);
    } catch (NumberFormatException e) {
      Log.w(TAG, "Skipping invalid index: " + currentLine);
      continue;
    }

    // Read and parse the timing line.
    boolean haveEndTimecode = false;
    currentLine = subripData.readLine();
    Matcher matcher = SUBRIP_TIMING_LINE.matcher(currentLine);
    if (matcher.matches()) {
      cueTimesUs.add(parseTimecode(matcher, 1));
      if (!TextUtils.isEmpty(matcher.group(6))) {
        haveEndTimecode = true;
        cueTimesUs.add(parseTimecode(matcher, 6));
      }
    } else {
      Log.w(TAG, "Skipping invalid timing: " + currentLine);
      continue;
    }

    // Read and parse the text.
    textBuilder.setLength(0);
    while (!TextUtils.isEmpty(currentLine = subripData.readLine())) {
      if (textBuilder.length() > 0) {
        textBuilder.append("<br>");
      }
      textBuilder.append(currentLine.trim());
    }

    Spanned text = Html.fromHtml(textBuilder.toString());
    cues.add(new Cue(text));
    if (haveEndTimecode) {
      cues.add(null);
    }
  }

  Cue[] cuesArray = new Cue[cues.size()];
  cues.toArray(cuesArray);
  long[] cueTimesUsArray = cueTimesUs.toArray();
  return new SubripSubtitle(cuesArray, cueTimesUsArray);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:58,代码来源:SubripDecoder.java


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