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


Java Cue类代码示例

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


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

示例1: parse

import com.google.android.exoplayer.text.Cue; //导入依赖的package包/类
@Override
public Mp4WebvttSubtitle parse(byte[] bytes, int offset, int length) throws ParserException {
  // 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, offset + length);
  sampleData.setPosition(offset);
  List<Cue> resultingCueList = new ArrayList<>();
  while (sampleData.bytesLeft() > 0) {
    if (sampleData.bytesLeft() < BOX_HEADER_SIZE) {
      throw new ParserException("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:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:23,代码来源:Mp4WebvttParser.java

示例2: parseVttCueBox

import com.google.android.exoplayer.text.Cue; //导入依赖的package包/类
private static Cue parseVttCueBox(ParsableByteArray sampleData, WebvttCue.Builder builder,
      int remainingCueBoxBytes) throws ParserException {
  builder.reset();
  while (remainingCueBoxBytes > 0) {
    if (remainingCueBoxBytes < BOX_HEADER_SIZE) {
      throw new ParserException("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(boxPayload.trim(), builder);
    } else {
      // Other VTTCueBox children are still not supported and are ignored.
    }
  }
  return builder.build();
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:25,代码来源:Mp4WebvttParser.java

示例3: derivePositionAnchorFromAlignment

import com.google.android.exoplayer.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:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:23,代码来源:WebvttCue.java

示例4: assertCue

import com.google.android.exoplayer.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:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:19,代码来源:WebvttParserTest.java

示例5: assertSpans

import com.google.android.exoplayer.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:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:23,代码来源:TtmlParserTest.java

示例6: parse

import com.google.android.exoplayer.text.Cue; //导入依赖的package包/类
@Override
public Subtitle parse(InputStream inputStream, String inputEncoding, long startTimeUs)
    throws IOException {
  DataInputStream dataInputStream  = new DataInputStream(inputStream);
  String cueText = dataInputStream.readUTF();
  return new Tx3gSubtitle(startTimeUs, new Cue(cueText));
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:8,代码来源:Tx3gParser.java

示例7: invokeRendererInternal

import com.google.android.exoplayer.text.Cue; //导入依赖的package包/类
private void invokeRendererInternal(String cueText) {
  if (cueText == null) {
    textRenderer.onCues(Collections.<Cue>emptyList());
  } else {
    textRenderer.onCues(Collections.singletonList(new Cue(cueText)));
  }
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:8,代码来源:Eia608TrackRenderer.java

示例8: getCues

import com.google.android.exoplayer.text.Cue; //导入依赖的package包/类
@Override
public List<Cue> getCues(long timeUs) {
  CharSequence cueText = root.getText(timeUs - startTimeUs);
  if (cueText == null) {
    return Collections.<Cue>emptyList();
  } else {
    Cue cue = new Cue(cueText);
    return Collections.singletonList(cue);
  }
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:11,代码来源:TtmlSubtitle.java

示例9: getCues

import com.google.android.exoplayer.text.Cue; //导入依赖的package包/类
@Override
public List<Cue> getCues(long timeUs) {
  int index = Util.binarySearchFloor(cueTimesUs, timeUs, true, false);
  if (index == -1 || index % 2 == 1) {
    // timeUs is earlier than the start of the first cue, or corresponds to a gap between cues.
    return Collections.<Cue>emptyList();
  } else {
    return Collections.singletonList(cues[index / 2]);
  }
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:11,代码来源:SubripSubtitle.java

示例10: selectTrack

import com.google.android.exoplayer.text.Cue; //导入依赖的package包/类
public void selectTrack(int type, int index) {
  if (selectedTracks[type] == index) {
    return;
  }
  selectedTracks[type] = index;
  pushTrackSelection(type, true);
  if (type == TYPE_TEXT && index == DISABLED_TRACK && captionListener != null) {
    captionListener.onCues(Collections.<Cue>emptyList());
  }
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:11,代码来源:MediaPlayer.java

示例11: parseLineAttribute

import com.google.android.exoplayer.text.Cue; //导入依赖的package包/类
private static void parseLineAttribute(String s, WebvttCue.Builder builder)
    throws NumberFormatException {
  int commaPosition = s.indexOf(',');
  if (commaPosition != -1) {
    builder.setLineAnchor(parsePositionAnchor(s.substring(commaPosition + 1)));
    s = s.substring(0, commaPosition);
  } else {
    builder.setLineAnchor(Cue.TYPE_UNSET);
  }
  if (s.endsWith("%")) {
    builder.setLine(WebvttParserUtil.parsePercentage(s)).setLineType(Cue.LINE_TYPE_FRACTION);
  } else {
    builder.setLine(Integer.parseInt(s)).setLineType(Cue.LINE_TYPE_NUMBER);
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:16,代码来源:WebvttCueParser.java

示例12: parsePositionAttribute

import com.google.android.exoplayer.text.Cue; //导入依赖的package包/类
private static void parsePositionAttribute(String s, WebvttCue.Builder builder)
    throws NumberFormatException {
  int commaPosition = s.indexOf(',');
  if (commaPosition != -1) {
    builder.setPositionAnchor(parsePositionAnchor(s.substring(commaPosition + 1)));
    s = s.substring(0, commaPosition);
  } else {
    builder.setPositionAnchor(Cue.TYPE_UNSET);
  }
  builder.setPosition(WebvttParserUtil.parsePercentage(s));
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:12,代码来源:WebvttCueParser.java

示例13: parsePositionAnchor

import com.google.android.exoplayer.text.Cue; //导入依赖的package包/类
private static int parsePositionAnchor(String s) {
  switch (s) {
    case "start":
      return Cue.ANCHOR_TYPE_START;
    case "center":
    case "middle":
      return Cue.ANCHOR_TYPE_MIDDLE;
    case "end":
      return Cue.ANCHOR_TYPE_END;
    default:
      Log.w(TAG, "Invalid anchor value: " + s);
      return Cue.TYPE_UNSET;
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:15,代码来源:WebvttCueParser.java

示例14: reset

import com.google.android.exoplayer.text.Cue; //导入依赖的package包/类
public void reset() {
  startTime = 0;
  endTime = 0;
  text = null;
  textAlignment = null;
  line = Cue.DIMEN_UNSET;
  lineType = Cue.TYPE_UNSET;
  lineAnchor = Cue.TYPE_UNSET;
  position = Cue.DIMEN_UNSET;
  positionAnchor = Cue.TYPE_UNSET;
  width = Cue.DIMEN_UNSET;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:13,代码来源:WebvttCue.java

示例15: build

import com.google.android.exoplayer.text.Cue; //导入依赖的package包/类
public WebvttCue build() {
  if (position != Cue.DIMEN_UNSET && positionAnchor == Cue.TYPE_UNSET) {
    derivePositionAnchorFromAlignment();
  }
  return new WebvttCue(startTime, endTime, text, textAlignment, line, lineType, lineAnchor,
      position, positionAnchor, width);
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:8,代码来源:WebvttCue.java


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