clean the list while forward seek.

This commit is contained in:
ood_tsen 2015-06-03 20:28:30 +08:00
parent fd2ebc767c
commit b95b0aad5c

View File

@ -54,10 +54,18 @@ public class TextParser implements SubtitleParser {
SubtitleData cue = new SubtitleData(startTimeUs, text);
while (subtitleList.size() > MAX_SUBTITLE_COUNT) {
subtitleList.remove(0);
}
//try to resize the list.
if (subtitleList.size() > 0) {
long lastTimeUs = subtitleList.get(subtitleList.size() - 1).startTimePosUs;
if (startTimeUs < lastTimeUs) {
//when forward seek
subtitleList.clear();
}
while (subtitleList.size() > MAX_SUBTITLE_COUNT) {
subtitleList.remove(0);
}
}
subtitleList.add(cue);
Collections.sort(subtitleList, new Comparator<SubtitleData>() {