Fix positioning of subtitles.
SubtitleView forwards the cue box position to SubtitlePainter. This should be the position relative to the canvas of the SubtitleView. Currently, however, we forward the position relative to the parent of SubtitleView. That causes problems if SubtitleView has a non-zero offset position to its parent. Issue:#4788 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=215535281
This commit is contained in:
parent
4386d5d466
commit
43c01562d1
@ -14,6 +14,9 @@
|
||||
* Fix an issue with blind seeking to windows with non-zero offset in a
|
||||
`ConcatenatingMediaSource`
|
||||
([#4873](https://github.com/google/ExoPlayer/issues/4873)).
|
||||
* Fix issue where subtitles have a wrong position if SubtitleView has a non-zero
|
||||
offset to its parent
|
||||
([#4788](https://github.com/google/ExoPlayer/issues/4788)).
|
||||
|
||||
### 2.9.0 ###
|
||||
|
||||
|
@ -247,19 +247,17 @@ public final class SubtitleView extends View implements TextOutput {
|
||||
@Override
|
||||
public void dispatchDraw(Canvas canvas) {
|
||||
int cueCount = (cues == null) ? 0 : cues.size();
|
||||
int rawTop = getTop();
|
||||
int rawBottom = getBottom();
|
||||
int rawViewHeight = getHeight();
|
||||
|
||||
// Calculate the bounds after padding is taken into account.
|
||||
int left = getLeft() + getPaddingLeft();
|
||||
int top = rawTop + getPaddingTop();
|
||||
int right = getRight() - getPaddingRight();
|
||||
int bottom = rawBottom - getPaddingBottom();
|
||||
// Calculate the cue box bounds relative to the canvas after padding is taken into account.
|
||||
int left = getPaddingLeft();
|
||||
int top = getPaddingTop();
|
||||
int right = getWidth() - getPaddingRight();
|
||||
int bottom = rawViewHeight - getPaddingBottom();
|
||||
if (bottom <= top || right <= left) {
|
||||
// No space to draw subtitles.
|
||||
return;
|
||||
}
|
||||
int rawViewHeight = rawBottom - rawTop;
|
||||
int viewHeightMinusPadding = bottom - top;
|
||||
|
||||
float defaultViewTextSizePx =
|
||||
|
Loading…
x
Reference in New Issue
Block a user