mirror of
https://github.com/samsonjs/media.git
synced 2026-04-25 14:47:40 +00:00
Discard subtitles with invalid positions
textWidth can be negative if textLeft extends parentRight (i.e. the subtitle is positioned entirely off the screen to the RHS). We should just discard and log a warning in this case. Issue: #2497 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=148481310
This commit is contained in:
parent
129334d2a0
commit
ad857852e5
1 changed files with 6 additions and 2 deletions
|
|
@ -266,6 +266,12 @@ import com.google.android.exoplayer2.util.Util;
|
|||
textRight = textLeft + textWidth;
|
||||
}
|
||||
|
||||
textWidth = textRight - textLeft;
|
||||
if (textWidth <= 0) {
|
||||
Log.w(TAG, "Skipped drawing subtitle cue (invalid horizontal positioning)");
|
||||
return;
|
||||
}
|
||||
|
||||
int textTop;
|
||||
if (cueLine != Cue.DIMEN_UNSET) {
|
||||
int anchorPosition;
|
||||
|
|
@ -292,8 +298,6 @@ import com.google.android.exoplayer2.util.Util;
|
|||
textTop = parentBottom - textHeight - (int) (parentHeight * bottomPaddingFraction);
|
||||
}
|
||||
|
||||
textWidth = textRight - textLeft;
|
||||
|
||||
// Update the derived drawing variables.
|
||||
this.textLayout = new StaticLayout(cueText, textPaint, textWidth, textAlignment, spacingMult,
|
||||
spacingAdd, true);
|
||||
|
|
|
|||
Loading…
Reference in a new issue