mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Fix subtitle painter issues
This commit is contained in:
parent
21923ae1fa
commit
31513202df
1 changed files with 7 additions and 5 deletions
|
|
@ -65,9 +65,9 @@ import com.google.android.exoplayer2.util.Util;
|
||||||
private final Paint paint;
|
private final Paint paint;
|
||||||
|
|
||||||
// Previous input variables.
|
// Previous input variables.
|
||||||
private Bitmap cueBitmap;
|
|
||||||
private CharSequence cueText;
|
private CharSequence cueText;
|
||||||
private Alignment cueTextAlignment;
|
private Alignment cueTextAlignment;
|
||||||
|
private Bitmap cueBitmap;
|
||||||
private float cueLine;
|
private float cueLine;
|
||||||
@Cue.LineType
|
@Cue.LineType
|
||||||
private int cueLineType;
|
private int cueLineType;
|
||||||
|
|
@ -148,12 +148,14 @@ import com.google.android.exoplayer2.util.Util;
|
||||||
boolean isTextCue = cue.bitmap == null;
|
boolean isTextCue = cue.bitmap == null;
|
||||||
CharSequence cueText = null;
|
CharSequence cueText = null;
|
||||||
Bitmap cueBitmap = null;
|
Bitmap cueBitmap = null;
|
||||||
|
int windowColor = Color.BLACK;
|
||||||
if (isTextCue) {
|
if (isTextCue) {
|
||||||
cueText = cue.text;
|
cueText = cue.text;
|
||||||
if (TextUtils.isEmpty(cueText)) {
|
if (TextUtils.isEmpty(cueText)) {
|
||||||
// Nothing to draw.
|
// Nothing to draw.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
windowColor = cue.windowColorSet ? cue.windowColor : style.windowColor;
|
||||||
if (!applyEmbeddedStyles) {
|
if (!applyEmbeddedStyles) {
|
||||||
// Strip out any embedded styling.
|
// Strip out any embedded styling.
|
||||||
cueText = cueText.toString();
|
cueText = cueText.toString();
|
||||||
|
|
@ -174,7 +176,7 @@ import com.google.android.exoplayer2.util.Util;
|
||||||
&& this.applyEmbeddedStyles == applyEmbeddedStyles
|
&& this.applyEmbeddedStyles == applyEmbeddedStyles
|
||||||
&& this.foregroundColor == style.foregroundColor
|
&& this.foregroundColor == style.foregroundColor
|
||||||
&& this.backgroundColor == style.backgroundColor
|
&& this.backgroundColor == style.backgroundColor
|
||||||
&& this.windowColor == style.windowColor
|
&& this.windowColor == windowColor
|
||||||
&& this.edgeType == style.edgeType
|
&& this.edgeType == style.edgeType
|
||||||
&& this.edgeColor == style.edgeColor
|
&& this.edgeColor == style.edgeColor
|
||||||
&& Util.areEqual(this.textPaint.getTypeface(), style.typeface)
|
&& Util.areEqual(this.textPaint.getTypeface(), style.typeface)
|
||||||
|
|
@ -275,7 +277,7 @@ import com.google.android.exoplayer2.util.Util;
|
||||||
if (cueLine >= 0) {
|
if (cueLine >= 0) {
|
||||||
anchorPosition = Math.round(cueLine * firstLineHeight) + parentTop;
|
anchorPosition = Math.round(cueLine * firstLineHeight) + parentTop;
|
||||||
} else {
|
} else {
|
||||||
anchorPosition = Math.round(cueLine * firstLineHeight) + parentBottom;
|
anchorPosition = Math.round((cueLine + 1) * firstLineHeight) + parentBottom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
textTop = cueLineAnchor == Cue.ANCHOR_TYPE_END ? anchorPosition - textHeight
|
textTop = cueLineAnchor == Cue.ANCHOR_TYPE_END ? anchorPosition - textHeight
|
||||||
|
|
@ -309,8 +311,8 @@ import com.google.android.exoplayer2.util.Util;
|
||||||
int height = (int) (width * ((float) cueBitmap.getHeight() / cueBitmap.getWidth()));
|
int height = (int) (width * ((float) cueBitmap.getHeight() / cueBitmap.getWidth()));
|
||||||
int x = (int) (cueLineAnchor == Cue.ANCHOR_TYPE_END ? (anchorX - width)
|
int x = (int) (cueLineAnchor == Cue.ANCHOR_TYPE_END ? (anchorX - width)
|
||||||
: cueLineAnchor == Cue.ANCHOR_TYPE_MIDDLE ? (anchorX - (width / 2)) : anchorX);
|
: cueLineAnchor == Cue.ANCHOR_TYPE_MIDDLE ? (anchorX - (width / 2)) : anchorX);
|
||||||
int y = (int) (cuePositionAnchor == Cue.ANCHOR_TYPE_END ? (anchorY - width)
|
int y = (int) (cuePositionAnchor == Cue.ANCHOR_TYPE_END ? (anchorY - height)
|
||||||
: cuePositionAnchor == Cue.ANCHOR_TYPE_MIDDLE ? (anchorY - (width / 2)) : anchorY);
|
: cuePositionAnchor == Cue.ANCHOR_TYPE_MIDDLE ? (anchorY - (height / 2)) : anchorY);
|
||||||
bitmapRect = new Rect(x, y, x + width, y + height);
|
bitmapRect = new Rect(x, y, x + width, y + height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue