Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ab348c04
authored
Jul 03, 2020
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge pull request #7568 from juankysoriano:subtitles-font-size-bug
PiperOrigin-RevId: 319223173
parents
729ec8a1
5c096acc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
27 deletions
RELEASENOTES.md
library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitleView.java
RELEASENOTES.md
View file @
ab348c04
...
@@ -135,6 +135,8 @@
...
@@ -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.
...
...
library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitleView.java
View file @
ab348c04
...
@@ -34,7 +34,6 @@ import android.widget.FrameLayout;
...
@@ -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 {
...
@@ -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
()
:
1
f
;
setFractionalTextSize
(
DEFAULT_TEXT_SIZE_FRACTION
*
getUserCaptionFontScale
());
setFractionalTextSize
(
DEFAULT_TEXT_SIZE_FRACTION
*
fontScale
);
}
}
/**
/**
...
@@ -291,14 +291,13 @@ public final class SubtitleView extends FrameLayout implements TextOutput {
...
@@ -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 {
...
@@ -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
())
{
@Nullable
return
1
f
;
CaptioningManager
captioningManager
=
}
(
CaptioningManager
)
getContext
().
getSystemService
(
Context
.
CAPTIONING_SERVICE
);
return
captioningManager
!=
null
&&
captioningManager
.
isEnabled
();
}
@RequiresApi
(
19
)
private
float
getUserCaptionFontScaleV19
()
{
@Nullable
@Nullable
CaptioningManager
captioningManager
=
CaptioningManager
captioningManager
=
(
CaptioningManager
)
getContext
().
getSystemService
(
Context
.
CAPTIONING_SERVICE
);
(
CaptioningManager
)
getContext
().
getSystemService
(
Context
.
CAPTIONING_SERVICE
);
return
captioningManager
==
null
?
1
f
:
captioningManager
.
getFontScale
();
return
captioningManager
!=
null
&&
captioningManager
.
isEnabled
()
?
captioningManager
.
getFontScale
()
:
1
f
;
}
}
@RequiresApi
(
19
)
private
CaptionStyleCompat
getUserCaptionStyle
()
{
private
CaptionStyleCompat
getUserCaptionStyleV19
()
{
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
return
captioningManager
!=
null
&&
captioningManager
.
isEnabled
()
?
CaptionStyleCompat
.
DEFAULT
?
CaptionStyleCompat
.
createFromCaptionStyle
(
captioningManager
.
getUserStyle
())
:
CaptionStyleCompat
.
createFromCaptionStyle
(
captioningManager
.
getUserStyle
())
;
:
CaptionStyleCompat
.
DEFAULT
;
}
}
private
void
updateOutput
()
{
private
void
updateOutput
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment