mirror of
https://github.com/samsonjs/media.git
synced 2026-04-25 14:47:40 +00:00
Merge pull request #7568 from juankysoriano:subtitles-font-size-bug
PiperOrigin-RevId: 319223173
This commit is contained in:
commit
ab348c045c
2 changed files with 26 additions and 27 deletions
|
|
@ -135,6 +135,8 @@
|
||||||
([#7475](https://github.com/google/ExoPlayer/issues/7475)).
|
([#7475](https://github.com/google/ExoPlayer/issues/7475)).
|
||||||
* Redefine `Cue.lineType=LINE_TYPE_NUMBER` in terms of aligning the cue
|
* Redefine `Cue.lineType=LINE_TYPE_NUMBER` in terms of aligning the cue
|
||||||
text lines to grid of viewport lines, and ignore `Cue.lineAnchor`.
|
text lines to grid of viewport lines, and ignore `Cue.lineAnchor`.
|
||||||
|
* Check `CaptionManager.isEnabled()` before using it for user-specified
|
||||||
|
font-scaling.
|
||||||
* DRM:
|
* DRM:
|
||||||
* Add support for attaching DRM sessions to clear content in the demo app.
|
* Add support for attaching DRM sessions to clear content in the demo app.
|
||||||
* Remove `DrmSessionManager` references from all renderers.
|
* Remove `DrmSessionManager` references from all renderers.
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@ import android.widget.FrameLayout;
|
||||||
import androidx.annotation.Dimension;
|
import androidx.annotation.Dimension;
|
||||||
import androidx.annotation.IntDef;
|
import androidx.annotation.IntDef;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.RequiresApi;
|
|
||||||
import com.google.android.exoplayer2.text.CaptionStyleCompat;
|
import com.google.android.exoplayer2.text.CaptionStyleCompat;
|
||||||
import com.google.android.exoplayer2.text.Cue;
|
import com.google.android.exoplayer2.text.Cue;
|
||||||
import com.google.android.exoplayer2.text.TextOutput;
|
import com.google.android.exoplayer2.text.TextOutput;
|
||||||
|
|
@ -225,12 +224,13 @@ public final class SubtitleView extends FrameLayout implements TextOutput {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the text size to one derived from {@link CaptioningManager#getFontScale()}, or to a
|
* Sets the text size based on {@link CaptioningManager#getFontScale()} if {@link
|
||||||
* default size before API level 19.
|
* CaptioningManager} is available and enabled.
|
||||||
|
*
|
||||||
|
* <p>Otherwise (and always before API level 19) uses a default font scale of 1.0.
|
||||||
*/
|
*/
|
||||||
public void setUserDefaultTextSize() {
|
public void setUserDefaultTextSize() {
|
||||||
float fontScale = Util.SDK_INT >= 19 && !isInEditMode() ? getUserCaptionFontScaleV19() : 1f;
|
setFractionalTextSize(DEFAULT_TEXT_SIZE_FRACTION * getUserCaptionFontScale());
|
||||||
setFractionalTextSize(DEFAULT_TEXT_SIZE_FRACTION * fontScale);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -291,14 +291,13 @@ public final class SubtitleView extends FrameLayout implements TextOutput {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the caption style to be equivalent to the one returned by
|
* Styles the captions using {@link CaptioningManager#getUserStyle()} if {@link CaptioningManager}
|
||||||
* {@link CaptioningManager#getUserStyle()}, or to a default style before API level 19.
|
* is available and enabled.
|
||||||
|
*
|
||||||
|
* <p>Otherwise (and always before API level 19) uses a default style.
|
||||||
*/
|
*/
|
||||||
public void setUserDefaultStyle() {
|
public void setUserDefaultStyle() {
|
||||||
setStyle(
|
setStyle(getUserCaptionStyle());
|
||||||
Util.SDK_INT >= 19 && isCaptionManagerEnabled() && !isInEditMode()
|
|
||||||
? getUserCaptionStyleV19()
|
|
||||||
: CaptionStyleCompat.DEFAULT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -325,30 +324,28 @@ public final class SubtitleView extends FrameLayout implements TextOutput {
|
||||||
updateOutput();
|
updateOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(19)
|
private float getUserCaptionFontScale() {
|
||||||
private boolean isCaptionManagerEnabled() {
|
if (Util.SDK_INT < 19 || isInEditMode()) {
|
||||||
|
return 1f;
|
||||||
|
}
|
||||||
@Nullable
|
@Nullable
|
||||||
CaptioningManager captioningManager =
|
CaptioningManager captioningManager =
|
||||||
(CaptioningManager) getContext().getSystemService(Context.CAPTIONING_SERVICE);
|
(CaptioningManager) getContext().getSystemService(Context.CAPTIONING_SERVICE);
|
||||||
return captioningManager != null && captioningManager.isEnabled();
|
return captioningManager != null && captioningManager.isEnabled()
|
||||||
|
? captioningManager.getFontScale()
|
||||||
|
: 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(19)
|
private CaptionStyleCompat getUserCaptionStyle() {
|
||||||
private float getUserCaptionFontScaleV19() {
|
if (Util.SDK_INT < 19 || isInEditMode()) {
|
||||||
|
return CaptionStyleCompat.DEFAULT;
|
||||||
|
}
|
||||||
@Nullable
|
@Nullable
|
||||||
CaptioningManager captioningManager =
|
CaptioningManager captioningManager =
|
||||||
(CaptioningManager) getContext().getSystemService(Context.CAPTIONING_SERVICE);
|
(CaptioningManager) getContext().getSystemService(Context.CAPTIONING_SERVICE);
|
||||||
return captioningManager == null ? 1f : captioningManager.getFontScale();
|
return captioningManager != null && captioningManager.isEnabled()
|
||||||
}
|
? CaptionStyleCompat.createFromCaptionStyle(captioningManager.getUserStyle())
|
||||||
|
: CaptionStyleCompat.DEFAULT;
|
||||||
@RequiresApi(19)
|
|
||||||
private CaptionStyleCompat getUserCaptionStyleV19() {
|
|
||||||
@Nullable
|
|
||||||
CaptioningManager captioningManager =
|
|
||||||
(CaptioningManager) getContext().getSystemService(Context.CAPTIONING_SERVICE);
|
|
||||||
return captioningManager == null
|
|
||||||
? CaptionStyleCompat.DEFAULT
|
|
||||||
: CaptionStyleCompat.createFromCaptionStyle(captioningManager.getUserStyle());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateOutput() {
|
private void updateOutput() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue