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


Java Cue类代码示例

本文整理汇总了Java中com.google.android.exoplayer2.text.Cue的典型用法代码示例。如果您正苦于以下问题:Java Cue类的具体用法?Java Cue怎么用?Java Cue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Cue类属于com.google.android.exoplayer2.text包,在下文中一共展示了Cue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: decode

import com.google.android.exoplayer2.text.Cue; //导入依赖的package包/类
@Override
protected Mp4WebvttSubtitle decode(byte[] bytes, int length, boolean reset)
    throws SubtitleDecoderException {
  // Webvtt in Mp4 samples have boxes inside of them, so we have to do a traditional box parsing:
  // first 4 bytes size and then 4 bytes type.
  sampleData.reset(bytes, length);
  List<Cue> resultingCueList = new ArrayList<>();
  while (sampleData.bytesLeft() > 0) {
    if (sampleData.bytesLeft() < BOX_HEADER_SIZE) {
      throw new SubtitleDecoderException("Incomplete Mp4Webvtt Top Level box header found.");
    }
    int boxSize = sampleData.readInt();
    int boxType = sampleData.readInt();
    if (boxType == TYPE_vttc) {
      resultingCueList.add(parseVttCueBox(sampleData, builder, boxSize - BOX_HEADER_SIZE));
    } else {
      // Peers of the VTTCueBox are still not supported and are skipped.
      sampleData.skipBytes(boxSize - BOX_HEADER_SIZE);
    }
  }
  return new Mp4WebvttSubtitle(resultingCueList);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:23,代码来源:Mp4WebvttDecoder.java

示例2: parseVttCueBox

import com.google.android.exoplayer2.text.Cue; //导入依赖的package包/类
private static Cue parseVttCueBox(ParsableByteArray sampleData, WebvttCue.Builder builder,
      int remainingCueBoxBytes) throws SubtitleDecoderException {
  builder.reset();
  while (remainingCueBoxBytes > 0) {
    if (remainingCueBoxBytes < BOX_HEADER_SIZE) {
      throw new SubtitleDecoderException("Incomplete vtt cue box header found.");
    }
    int boxSize = sampleData.readInt();
    int boxType = sampleData.readInt();
    remainingCueBoxBytes -= BOX_HEADER_SIZE;
    int payloadLength = boxSize - BOX_HEADER_SIZE;
    String boxPayload = new String(sampleData.data, sampleData.getPosition(), payloadLength);
    sampleData.skipBytes(payloadLength);
    remainingCueBoxBytes -= payloadLength;
    if (boxType == TYPE_sttg) {
      WebvttCueParser.parseCueSettingsList(boxPayload, builder);
    } else if (boxType == TYPE_payl) {
      WebvttCueParser.parseCueText(null, boxPayload.trim(), builder,
          Collections.<WebvttCssStyle>emptyList());
    } else {
      // Other VTTCueBox children are still not supported and are ignored.
    }
  }
  return builder.build();
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:26,代码来源:Mp4WebvttDecoder.java

示例3: parseLineAttribute

import com.google.android.exoplayer2.text.Cue; //导入依赖的package包/类
private static void parseLineAttribute(String s, WebvttCue.Builder builder)
    throws NumberFormatException {
  int commaIndex = s.indexOf(',');
  if (commaIndex != -1) {
    builder.setLineAnchor(parsePositionAnchor(s.substring(commaIndex + 1)));
    s = s.substring(0, commaIndex);
  } else {
    builder.setLineAnchor(Cue.TYPE_UNSET);
  }
  if (s.endsWith("%")) {
    builder.setLine(WebvttParserUtil.parsePercentage(s)).setLineType(Cue.LINE_TYPE_FRACTION);
  } else {
    int lineNumber = Integer.parseInt(s);
    if (lineNumber < 0) {
      // WebVTT defines line -1 as last visible row when lineAnchor is ANCHOR_TYPE_START, where-as
      // Cue defines it to be the first row that's not visible.
      lineNumber--;
    }
    builder.setLine(lineNumber).setLineType(Cue.LINE_TYPE_NUMBER);
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:22,代码来源:WebvttCueParser.java

示例4: derivePositionAnchorFromAlignment

import com.google.android.exoplayer2.text.Cue; //导入依赖的package包/类
private Builder derivePositionAnchorFromAlignment() {
  if (textAlignment == null) {
    positionAnchor = Cue.TYPE_UNSET;
  } else {
    switch (textAlignment) {
      case ALIGN_NORMAL:
        positionAnchor = Cue.ANCHOR_TYPE_START;
        break;
      case ALIGN_CENTER:
        positionAnchor = Cue.ANCHOR_TYPE_MIDDLE;
        break;
      case ALIGN_OPPOSITE:
        positionAnchor = Cue.ANCHOR_TYPE_END;
        break;
      default:
        Log.w(TAG, "Unrecognized alignment: " + textAlignment);
        positionAnchor = Cue.ANCHOR_TYPE_START;
        break;
    }
  }
  return this;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:23,代码来源:WebvttCue.java

示例5: setupBitmapLayout

import com.google.android.exoplayer2.text.Cue; //导入依赖的package包/类
@SuppressWarnings("PMD.NPathComplexity")  // TODO break this method up
private void setupBitmapLayout() {
    int parentWidth = parentRight - parentLeft;
    int parentHeight = parentBottom - parentTop;
    float anchorX = parentLeft + (parentWidth * cuePosition);
    float anchorY = parentTop + (parentHeight * cueLine);
    int width = Math.round(parentWidth * cueSize);

    int height = isCueDimensionSet(cueBitmapHeight)
            ? Math.round(parentHeight * cueBitmapHeight)
            : Math.round(width * ((float) cueBitmap.getHeight() / cueBitmap.getWidth()));

    int x = Math.round(cueLineAnchor == Cue.ANCHOR_TYPE_END
            ? (anchorX - width)
            : cueLineAnchor == Cue.ANCHOR_TYPE_MIDDLE ? (anchorX - (width / 2f)) : anchorX);

    int y = Math.round(cuePositionAnchor == Cue.ANCHOR_TYPE_END
            ? (anchorY - height)
            : cuePositionAnchor == Cue.ANCHOR_TYPE_MIDDLE ? (anchorY - (height / 2f)) : anchorY);

    bitmapRect = new Rect(x, y, x + width, y + height);
}
 
开发者ID:novoda,项目名称:no-player,代码行数:23,代码来源:SubtitlePainter.java

示例6: map

import com.google.android.exoplayer2.text.Cue; //导入依赖的package包/类
static TextCues map(List<Cue> cues) {
    if (cues == null) {
        return TextCues.of(Collections.<NoPlayerCue>emptyList());
    }

    List<NoPlayerCue> noPlayerCues = new ArrayList<>(cues.size());

    for (Cue cue : cues) {
        NoPlayerCue noPlayerCue = new NoPlayerCue(
                cue.text,
                cue.textAlignment,
                cue.bitmap,
                cue.line,
                cue.lineType,
                cue.lineAnchor,
                cue.position,
                cue.positionAnchor,
                cue.size,
                cue.bitmapHeight,
                cue.windowColorSet,
                cue.windowColor
        );
        noPlayerCues.add(noPlayerCue);
    }
    return TextCues.of(noPlayerCues);
}
 
开发者ID:novoda,项目名称:no-player,代码行数:27,代码来源:ExoPlayerCueMapper.java

示例7: decode

import com.google.android.exoplayer2.text.Cue; //导入依赖的package包/类
@Override
protected Mp4WebvttSubtitle decode(byte[] bytes, int length) throws SubtitleDecoderException {
  // Webvtt in Mp4 samples have boxes inside of them, so we have to do a traditional box parsing:
  // first 4 bytes size and then 4 bytes type.
  sampleData.reset(bytes, length);
  List<Cue> resultingCueList = new ArrayList<>();
  while (sampleData.bytesLeft() > 0) {
    if (sampleData.bytesLeft() < BOX_HEADER_SIZE) {
      throw new SubtitleDecoderException("Incomplete Mp4Webvtt Top Level box header found.");
    }
    int boxSize = sampleData.readInt();
    int boxType = sampleData.readInt();
    if (boxType == TYPE_vttc) {
      resultingCueList.add(parseVttCueBox(sampleData, builder, boxSize - BOX_HEADER_SIZE));
    } else {
      // Peers of the VTTCueBox are still not supported and are skipped.
      sampleData.skipBytes(boxSize - BOX_HEADER_SIZE);
    }
  }
  return new Mp4WebvttSubtitle(resultingCueList);
}
 
开发者ID:jcodeing,项目名称:K-Sonic,代码行数:22,代码来源:Mp4WebvttDecoder.java

示例8: testDecodeWithPositioning

import com.google.android.exoplayer2.text.Cue; //导入依赖的package包/类
public void testDecodeWithPositioning() throws IOException, SubtitleDecoderException {
  WebvttSubtitle subtitle = getSubtitleForTestAsset(WITH_POSITIONING_FILE);
  // Test event count.
  assertEquals(12, subtitle.getEventTimeCount());
  // Test cues.
  assertCue(subtitle, 0, 0, 1234000, "This is the first subtitle.", Alignment.ALIGN_NORMAL,
      Cue.DIMEN_UNSET, Cue.TYPE_UNSET, Cue.TYPE_UNSET, 0.1f, Cue.ANCHOR_TYPE_START, 0.35f);
  assertCue(subtitle, 2, 2345000, 3456000, "This is the second subtitle.",
      Alignment.ALIGN_OPPOSITE, Cue.DIMEN_UNSET, Cue.TYPE_UNSET, Cue.TYPE_UNSET, Cue.DIMEN_UNSET,
      Cue.TYPE_UNSET, 0.35f);
  assertCue(subtitle, 4, 4000000, 5000000, "This is the third subtitle.",
      Alignment.ALIGN_CENTER, 0.45f, Cue.LINE_TYPE_FRACTION, Cue.ANCHOR_TYPE_END, Cue.DIMEN_UNSET,
      Cue.TYPE_UNSET, 0.35f);
  assertCue(subtitle, 6, 6000000, 7000000, "This is the fourth subtitle.",
      Alignment.ALIGN_CENTER, -10f, Cue.LINE_TYPE_NUMBER, Cue.TYPE_UNSET, Cue.DIMEN_UNSET,
      Cue.TYPE_UNSET, Cue.DIMEN_UNSET);
  assertCue(subtitle, 8, 7000000, 8000000, "This is the fifth subtitle.",
      Alignment.ALIGN_OPPOSITE, Cue.DIMEN_UNSET, Cue.TYPE_UNSET, Cue.TYPE_UNSET, 0.1f,
      Cue.ANCHOR_TYPE_END, 0.1f);
  assertCue(subtitle, 10, 10000000, 11000000, "This is the sixth subtitle.",
      Alignment.ALIGN_CENTER, 0.45f, Cue.LINE_TYPE_FRACTION, Cue.ANCHOR_TYPE_END, Cue.DIMEN_UNSET,
      Cue.TYPE_UNSET, 0.35f);
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:24,代码来源:WebvttDecoderTest.java

示例9: assertCue

import com.google.android.exoplayer2.text.Cue; //导入依赖的package包/类
private static void assertCue(WebvttSubtitle subtitle, int eventTimeIndex, long startTimeUs,
    int endTimeUs, String text, Alignment textAlignment, float line, int lineType, int lineAnchor,
    float position, int positionAnchor, float size) {
  assertEquals(startTimeUs, subtitle.getEventTime(eventTimeIndex));
  assertEquals(endTimeUs, subtitle.getEventTime(eventTimeIndex + 1));
  List<Cue> cues = subtitle.getCues(subtitle.getEventTime(eventTimeIndex));
  assertEquals(1, cues.size());
  // Assert cue properties.
  Cue cue = cues.get(0);
  assertEquals(text, cue.text.toString());
  assertEquals(textAlignment, cue.textAlignment);
  assertEquals(line, cue.line);
  assertEquals(lineType, cue.lineType);
  assertEquals(lineAnchor, cue.lineAnchor);
  assertEquals(position, cue.position);
  assertEquals(positionAnchor, cue.positionAnchor);
  assertEquals(size, cue.size);
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:19,代码来源:WebvttDecoderTest.java

示例10: assertSpans

import com.google.android.exoplayer2.text.Cue; //导入依赖的package包/类
private void assertSpans(TtmlSubtitle subtitle, int second,
    String text, String font, int fontStyle,
    int backgroundColor, int color, boolean isUnderline,
    boolean isLinethrough, Layout.Alignment alignment) {

  long timeUs = second * 1000000;
  List<Cue> cues = subtitle.getCues(timeUs);

  assertEquals(1, cues.size());
  assertEquals(text, String.valueOf(cues.get(0).text));
  assertEquals("single cue expected for timeUs: " + timeUs, 1, cues.size());
  SpannableStringBuilder spannable = (SpannableStringBuilder) cues.get(0).text;

  assertFont(spannable, font);
  assertStyle(spannable, fontStyle);
  assertUnderline(spannable, isUnderline);
  assertStrikethrough(spannable, isLinethrough);
  assertUnderline(spannable, isUnderline);
  assertBackground(spannable, backgroundColor);
  assertForeground(spannable, color);
  assertAlignment(spannable, alignment);
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:23,代码来源:TtmlDecoderTest.java

示例11: decode

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

  ParsableByteArray data = new ParsableByteArray(bytes, length);
  if (!haveInitializationData) {
    parseHeader(data);
  }
  parseEventBody(data, cues, cueTimesUs);

  Cue[] cuesArray = new Cue[cues.size()];
  cues.toArray(cuesArray);
  long[] cueTimesUsArray = cueTimesUs.toArray();
  return new SsaSubtitle(cuesArray, cueTimesUsArray);
}
 
开发者ID:y20k,项目名称:transistor,代码行数:17,代码来源:SsaDecoder.java

示例12: testDecodeWithPositioning

import com.google.android.exoplayer2.text.Cue; //导入依赖的package包/类
public void testDecodeWithPositioning() throws IOException, SubtitleDecoderException {
  WebvttSubtitle subtitle = getSubtitleForTestAsset(WITH_POSITIONING_FILE);
  // Test event count.
  assertEquals(12, subtitle.getEventTimeCount());
  // Test cues.
  assertCue(subtitle, 0, 0, 1234000, "This is the first subtitle.", Alignment.ALIGN_NORMAL,
      Cue.DIMEN_UNSET, Cue.TYPE_UNSET, Cue.TYPE_UNSET, 0.1f, Cue.ANCHOR_TYPE_START, 0.35f);
  assertCue(subtitle, 2, 2345000, 3456000, "This is the second subtitle.",
      Alignment.ALIGN_OPPOSITE, Cue.DIMEN_UNSET, Cue.TYPE_UNSET, Cue.TYPE_UNSET, Cue.DIMEN_UNSET,
      Cue.TYPE_UNSET, 0.35f);
  assertCue(subtitle, 4, 4000000, 5000000, "This is the third subtitle.",
      Alignment.ALIGN_CENTER, 0.45f, Cue.LINE_TYPE_FRACTION, Cue.ANCHOR_TYPE_END, Cue.DIMEN_UNSET,
      Cue.TYPE_UNSET, 0.35f);
  assertCue(subtitle, 6, 6000000, 7000000, "This is the fourth subtitle.",
      Alignment.ALIGN_CENTER, -11f, Cue.LINE_TYPE_NUMBER, Cue.TYPE_UNSET, Cue.DIMEN_UNSET,
      Cue.TYPE_UNSET, Cue.DIMEN_UNSET);
  assertCue(subtitle, 8, 7000000, 8000000, "This is the fifth subtitle.",
      Alignment.ALIGN_OPPOSITE, Cue.DIMEN_UNSET, Cue.TYPE_UNSET, Cue.TYPE_UNSET, 0.1f,
      Cue.ANCHOR_TYPE_END, 0.1f);
  assertCue(subtitle, 10, 10000000, 11000000, "This is the sixth subtitle.",
      Alignment.ALIGN_CENTER, 0.45f, Cue.LINE_TYPE_FRACTION, Cue.ANCHOR_TYPE_END, Cue.DIMEN_UNSET,
      Cue.TYPE_UNSET, 0.35f);
}
 
开发者ID:y20k,项目名称:transistor,代码行数:24,代码来源:WebvttDecoderTest.java

示例13: setupBitmapLayout

import com.google.android.exoplayer2.text.Cue; //导入依赖的package包/类
private void setupBitmapLayout() {
  int parentWidth = parentRight - parentLeft;
  int parentHeight = parentBottom - parentTop;
  float anchorX = parentLeft + (parentWidth * cuePosition);
  float anchorY = parentTop + (parentHeight * cueLine);
  int width = Math.round(parentWidth * cueSize);
  int height = cueBitmapHeight != Cue.DIMEN_UNSET ? Math.round(parentHeight * cueBitmapHeight)
      : Math.round(width * ((float) cueBitmap.getHeight() / cueBitmap.getWidth()));
  int x = Math.round(cueLineAnchor == Cue.ANCHOR_TYPE_END ? (anchorX - width)
      : cueLineAnchor == Cue.ANCHOR_TYPE_MIDDLE ? (anchorX - (width / 2)) : anchorX);
  int y = Math.round(cuePositionAnchor == Cue.ANCHOR_TYPE_END ? (anchorY - height)
      : cuePositionAnchor == Cue.ANCHOR_TYPE_MIDDLE ? (anchorY - (height / 2)) : anchorY);
  bitmapRect = new Rect(x, y, x + width, y + height);
}
 
开发者ID:yangchaojiang,项目名称:yjPlay,代码行数:15,代码来源:SubtitlePainter.java

示例14: setCues

import com.google.android.exoplayer2.text.Cue; //导入依赖的package包/类
/**
 * Sets the cues to be displayed by the view.
 *
 * @param cues The cues to display.
 */
public void setCues(List<Cue> cues) {
  if (this.cues == cues) {
    return;
  }
  this.cues = cues;
  // Ensure we have sufficient painters.
  int cueCount = (cues == null) ? 0 : cues.size();
  while (painters.size() < cueCount) {
    painters.add(new SubtitlePainter(getContext()));
  }
  // Invalidate to trigger drawing.
  invalidate();
}
 
开发者ID:yangchaojiang,项目名称:yjPlay,代码行数:19,代码来源:SubtitleView.java

示例15: decode

import com.google.android.exoplayer2.text.Cue; //导入依赖的package包/类
@Override
protected Subtitle decode(byte[] bytes, int length, boolean reset)
    throws SubtitleDecoderException {
  parsableByteArray.reset(bytes, length);
  String cueTextString = readSubtitleText(parsableByteArray);
  if (cueTextString.isEmpty()) {
    return Tx3gSubtitle.EMPTY;
  }
  // Attach default styles.
  SpannableStringBuilder cueText = new SpannableStringBuilder(cueTextString);
  attachFontFace(cueText, defaultFontFace, DEFAULT_FONT_FACE, 0, cueText.length(),
      SPAN_PRIORITY_LOW);
  attachColor(cueText, defaultColorRgba, DEFAULT_COLOR, 0, cueText.length(),
      SPAN_PRIORITY_LOW);
  attachFontFamily(cueText, defaultFontFamily, DEFAULT_FONT_FAMILY, 0, cueText.length(),
      SPAN_PRIORITY_LOW);
  float verticalPlacement = defaultVerticalPlacement;
  // Find and attach additional styles.
  while (parsableByteArray.bytesLeft() >= SIZE_ATOM_HEADER) {
    int position = parsableByteArray.getPosition();
    int atomSize = parsableByteArray.readInt();
    int atomType = parsableByteArray.readInt();
    if (atomType == TYPE_STYL) {
      assertTrue(parsableByteArray.bytesLeft() >= SIZE_SHORT);
      int styleRecordCount = parsableByteArray.readUnsignedShort();
      for (int i = 0; i < styleRecordCount; i++) {
        applyStyleRecord(parsableByteArray, cueText);
      }
    } else if (atomType == TYPE_TBOX && customVerticalPlacement) {
      assertTrue(parsableByteArray.bytesLeft() >= SIZE_SHORT);
      int requestedVerticalPlacement = parsableByteArray.readUnsignedShort();
      verticalPlacement = (float) requestedVerticalPlacement / calculatedVideoTrackHeight;
      verticalPlacement = Util.constrainValue(verticalPlacement, 0.0f, 0.95f);
    }
    parsableByteArray.setPosition(position + atomSize);
  }
  return new Tx3gSubtitle(new Cue(cueText, null, verticalPlacement, Cue.LINE_TYPE_FRACTION,
      Cue.ANCHOR_TYPE_START, Cue.DIMEN_UNSET, Cue.TYPE_UNSET, Cue.DIMEN_UNSET));
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:40,代码来源:Tx3gDecoder.java


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