Merge pull request #1817 from Bnyro/master

fix the subtitle size
This commit is contained in:
Bnyro 2022-11-12 10:34:24 +01:00 committed by GitHub
commit b9451e001a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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