feat: add "Rich caption rendering" setting (#5371)

This commit is contained in:
RafaRamos 2023-12-21 18:33:38 +01:00 committed by GitHub
parent 1e67660879
commit f60375a110
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 1 deletions

View File

@ -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"

View File

@ -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,

View File

@ -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)

View File

@ -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>

View File

@ -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">