mirror of
https://github.com/samsonjs/media.git
synced 2026-04-11 12:15:47 +00:00
Fix positioning issues with ttml regions.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=126790829
This commit is contained in:
parent
d3cd0c2ee4
commit
2426907f34
4 changed files with 10 additions and 5 deletions
|
|
@ -216,6 +216,9 @@ import android.util.Log;
|
|||
for (int i = 0; i < lineCount; i++) {
|
||||
textWidth = Math.max((int) Math.ceil(textLayout.getLineWidth(i)), textWidth);
|
||||
}
|
||||
if (cueSize != Cue.DIMEN_UNSET && textWidth < availableWidth) {
|
||||
textWidth = availableWidth;
|
||||
}
|
||||
textWidth += textPaddingX * 2;
|
||||
|
||||
int textLeft;
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ import java.util.TreeSet;
|
|||
List<Cue> cues = new ArrayList<>();
|
||||
for (Entry<String, SpannableStringBuilder> entry : regionOutputs.entrySet()) {
|
||||
TtmlRegion region = regionMap.get(entry.getKey());
|
||||
cues.add(new Cue(cleanUpText(entry.getValue()), null, region.line, Cue.TYPE_UNSET,
|
||||
cues.add(new Cue(cleanUpText(entry.getValue()), null, region.line, region.lineType,
|
||||
Cue.TYPE_UNSET, region.position, Cue.TYPE_UNSET, region.width));
|
||||
}
|
||||
return cues;
|
||||
|
|
|
|||
|
|
@ -218,8 +218,8 @@ public final class TtmlParser extends SimpleSubtitleParser {
|
|||
}
|
||||
}
|
||||
}
|
||||
return position != Cue.DIMEN_UNSET ? new Pair<>(regionId, new TtmlRegion(position, line, width))
|
||||
: null;
|
||||
return position != Cue.DIMEN_UNSET ? new Pair<>(regionId, new TtmlRegion(position, line,
|
||||
Cue.LINE_TYPE_FRACTION, width)) : null;
|
||||
}
|
||||
|
||||
private String[] parseStyleIds(String parentStyleIds) {
|
||||
|
|
|
|||
|
|
@ -24,15 +24,17 @@ import com.google.android.exoplayer.text.Cue;
|
|||
|
||||
public final float position;
|
||||
public final float line;
|
||||
public final int lineType;
|
||||
public final float width;
|
||||
|
||||
public TtmlRegion() {
|
||||
this(Cue.DIMEN_UNSET, Cue.DIMEN_UNSET, Cue.DIMEN_UNSET);
|
||||
this(Cue.DIMEN_UNSET, Cue.DIMEN_UNSET, Cue.TYPE_UNSET, Cue.DIMEN_UNSET);
|
||||
}
|
||||
|
||||
public TtmlRegion(float position, float line, float width) {
|
||||
public TtmlRegion(float position, float line, int lineType, float width) {
|
||||
this.position = position;
|
||||
this.line = line;
|
||||
this.lineType = lineType;
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue