Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add "Rich caption rendering" setting #5371

Merged
merged 3 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ object PreferenceKeys {
const val SEARCH_HISTORY_TOGGLE = "search_history_toggle"
const val SYSTEM_CAPTION_STYLE = "system_caption_style"
const val CAPTION_SETTINGS = "caption_settings"
const val RICH_CAPTION_RENDERING = "rich_caption_rendering"
const val SEEK_INCREMENT = "seek_increment"
const val DEFAULT_RESOLUTION = "default_res"
const val DEFAULT_RESOLUTION_MOBILE = "default_res_mobile"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ object PlayerHelper {
true
)

val useRichCaptionRendering: Boolean
get() = PreferenceHelper.getBoolean(
PreferenceKeys.RICH_CAPTION_RENDERING,
false
)

private val bufferingGoal: Int
get() = PreferenceHelper.getString(
PreferenceKeys.BUFFERING_GOAL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,8 @@ open class CustomExoPlayerView(
val captionStyle = PlayerHelper.getCaptionStyle(context)
subtitleView?.apply {
setApplyEmbeddedFontSizes(false)
setViewType(SubtitleView.VIEW_TYPE_WEB)
setFixedTextSize(Cue.TEXT_SIZE_TYPE_ABSOLUTE, PlayerHelper.captionsTextSize)
if (PlayerHelper.useRichCaptionRendering) setViewType(SubtitleView.VIEW_TYPE_WEB)
if (!PlayerHelper.useSystemCaptionStyle) return
setApplyEmbeddedStyles(captionStyle == CaptionStyleCompat.DEFAULT)
setStyle(captionStyle)
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@
<string name="watch_positions_title">Remembered playback positions</string>
<string name="reset_watch_positions">Reset</string>
<string name="system_caption_style">System caption style</string>
<string name="rich_caption_rendering">Rich caption rendering</string>
<string name="rich_caption_rendering_summary">Render web captions for a more rich and customized experience.</string>
<string name="captions">Captions</string>
<string name="none">None</string>
<string name="general">General</string>
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/xml/player_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@
app:key="caption_settings"
app:title="@string/caption_settings" />

<SwitchPreferenceCompat
android:icon="@drawable/ic_caption"
app:defaultValue="false"
app:key="rich_caption_rendering"
app:title="@string/rich_caption_rendering"
android:summary="@string/rich_caption_rendering_summary"/>

</PreferenceCategory>

<PreferenceCategory app:title="@string/queue">
Expand Down
Loading