fix the subtitle size

This commit is contained in:
Bnyro 2022-11-12 10:34:08 +01:00
parent 318c564621
commit 0754ab289f

View File

@ -90,6 +90,7 @@ import com.google.android.exoplayer2.source.DefaultMediaSourceFactory
import com.google.android.exoplayer2.source.MediaSource import com.google.android.exoplayer2.source.MediaSource
import com.google.android.exoplayer2.source.MergingMediaSource import com.google.android.exoplayer2.source.MergingMediaSource
import com.google.android.exoplayer2.source.ProgressiveMediaSource import com.google.android.exoplayer2.source.ProgressiveMediaSource
import com.google.android.exoplayer2.text.Cue.TEXT_SIZE_TYPE_ABSOLUTE
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector import com.google.android.exoplayer2.trackselection.DefaultTrackSelector
import com.google.android.exoplayer2.ui.CaptionStyleCompat import com.google.android.exoplayer2.ui.CaptionStyleCompat
import com.google.android.exoplayer2.ui.StyledPlayerView import com.google.android.exoplayer2.ui.StyledPlayerView
@ -717,11 +718,17 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
playerBinding.exoProgress.setPlayer(exoPlayer) playerBinding.exoProgress.setPlayer(exoPlayer)
if (PlayerHelper.useSystemCaptionStyle) { applyCaptionStyle()
// set the subtitle style }
val captionStyle = PlayerHelper.getCaptionStyle(requireContext())
exoPlayerView.subtitleView?.setApplyEmbeddedStyles(captionStyle == CaptionStyleCompat.DEFAULT) private fun applyCaptionStyle() {
exoPlayerView.subtitleView?.setStyle(captionStyle) val captionStyle = PlayerHelper.getCaptionStyle(requireContext())
exoPlayerView.subtitleView?.apply {
setApplyEmbeddedFontSizes(false)
setFixedTextSize(TEXT_SIZE_TYPE_ABSOLUTE, 18F)
if (!PlayerHelper.useSystemCaptionStyle) return
setApplyEmbeddedStyles(captionStyle == CaptionStyleCompat.DEFAULT)
setStyle(captionStyle)
} }
} }