Commit c7f763a3 by Arnold Szabo

#1583 - Modify in event time generation of TtmlNode

Look for "div" tags when generating the set of times.
parent eafca540
...@@ -479,7 +479,7 @@ public final class TtmlDecoder extends SimpleSubtitleDecoder { ...@@ -479,7 +479,7 @@ public final class TtmlDecoder extends SimpleSubtitleDecoder {
long startTime = C.TIME_UNSET; long startTime = C.TIME_UNSET;
long endTime = C.TIME_UNSET; long endTime = C.TIME_UNSET;
String regionId = TtmlNode.ANONYMOUS_REGION_ID; String regionId = TtmlNode.ANONYMOUS_REGION_ID;
String imageId = ""; String imageId = null;
String[] styleIds = null; String[] styleIds = null;
int attributeCount = parser.getAttributeCount(); int attributeCount = parser.getAttributeCount();
TtmlStyle style = parseStyleAttributes(parser, null); TtmlStyle style = parseStyleAttributes(parser, null);
...@@ -511,7 +511,11 @@ public final class TtmlDecoder extends SimpleSubtitleDecoder { ...@@ -511,7 +511,11 @@ public final class TtmlDecoder extends SimpleSubtitleDecoder {
} }
break; break;
case ATTR_IMAGE: case ATTR_IMAGE:
imageId = value.substring(1); // Parse URI reference only if refers to an element in the same document (it must start with '#')
// Resolving URIs from external sources is not supported
if (value.startsWith("#")) {
imageId = value.substring(1);
}
break; break;
default: default:
// Do nothing. // Do nothing.
......
...@@ -159,7 +159,8 @@ import java.util.TreeSet; ...@@ -159,7 +159,8 @@ import java.util.TreeSet;
private void getEventTimes(TreeSet<Long> out, boolean descendsPNode) { private void getEventTimes(TreeSet<Long> out, boolean descendsPNode) {
boolean isPNode = TAG_P.equals(tag); boolean isPNode = TAG_P.equals(tag);
if (descendsPNode || isPNode) { boolean isDivNode = TAG_DIV.equals(tag);
if (descendsPNode || isPNode || (isDivNode && imageId != null)) {
if (startTimeUs != C.TIME_UNSET) { if (startTimeUs != C.TIME_UNSET) {
out.add(startTimeUs); out.add(startTimeUs);
} }
...@@ -180,7 +181,7 @@ import java.util.TreeSet; ...@@ -180,7 +181,7 @@ import java.util.TreeSet;
} }
public List<Cue> getCues(long timeUs, Map<String, TtmlStyle> globalStyles, public List<Cue> getCues(long timeUs, Map<String, TtmlStyle> globalStyles,
Map<String, TtmlRegion> regionMap, Map<String, String> imageMap) { Map<String, TtmlRegion> regionMap, Map<String, String> imageMap) {
TreeMap<String, SpannableStringBuilder> regionOutputs = new TreeMap<>(); TreeMap<String, SpannableStringBuilder> regionOutputs = new TreeMap<>();
List<Pair<String, String>> regionImageList = new ArrayList<>(); List<Pair<String, String>> regionImageList = new ArrayList<>();
...@@ -204,7 +205,7 @@ import java.util.TreeSet; ...@@ -204,7 +205,7 @@ import java.util.TreeSet;
Cue.TYPE_UNSET, Cue.TYPE_UNSET,
region.line, region.line,
region.lineAnchor, region.lineAnchor,
region.width, region.width == Cue.DIMEN_UNSET ? 0.5f : region.width,
Cue.DIMEN_UNSET Cue.DIMEN_UNSET
) )
); );
...@@ -229,12 +230,17 @@ import java.util.TreeSet; ...@@ -229,12 +230,17 @@ import java.util.TreeSet;
return cues; return cues;
} }
private void traverseForImage(long timeUs, String inheritedRegion, List<Pair<String, String>> regionImageList) { private void traverseForImage(
// TODO isActive needed? long timeUs,
String inheritedRegion,
List<Pair<String, String>> regionImageList) {
String resolvedRegionId = ANONYMOUS_REGION_ID.equals(regionId) ? inheritedRegion : regionId; String resolvedRegionId = ANONYMOUS_REGION_ID.equals(regionId) ? inheritedRegion : regionId;
if (TAG_DIV.equals(tag) && imageId != null) {
regionImageList.add(new Pair<>(resolvedRegionId, imageId)); if (isActive(timeUs)) {
if (TAG_DIV.equals(tag) && imageId != null) {
regionImageList.add(new Pair<>(resolvedRegionId, imageId));
}
} }
for (int i = 0; i < getChildCount(); ++i) { for (int i = 0; i < getChildCount(); ++i) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment