@@ -35,6 +35,7 @@ import android.view.animation.AccelerateDecelerateInterpolator
3535import android.view.animation.AlphaAnimation
3636import android.view.animation.Animation
3737import android.view.animation.AnimationUtils
38+ import android.view.animation.DecelerateInterpolator
3839import android.widget.LinearLayout
3940import androidx.annotation.OptIn
4041import androidx.appcompat.app.AlertDialog
@@ -97,6 +98,8 @@ import kotlin.math.max
9798import kotlin.math.min
9899import kotlin.math.round
99100import kotlin.math.roundToInt
101+ import com.lagradost.cloudstream3.utils.AppContextUtils.shouldShowPlayerMetadata
102+
100103
101104// You can zoom out more than 100%, but it will zoom back into 100%
102105const val MINIMUM_ZOOM = 0.95f
@@ -133,7 +136,7 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
133136 private var uiShowingBeforeGesture = false
134137 protected var isLocked = false
135138 protected var timestampShowState = false
136-
139+ private var metadataVisibilityToken = 0
137140 protected var hasEpisodes = false
138141 private set
139142 // protected val hasEpisodes
@@ -235,10 +238,55 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
235238 requestUpdateBrightnessOverlayOnNextLayout()
236239 }
237240 }
238-
239241 return root
240242 }
241243
244+ private fun scheduleMetadataVisibility () {
245+ val metadataScrim = playerBinding?.playerMetadataScrim ? : return
246+ val ctx = metadataScrim.context ? : return
247+
248+ if (! ctx.shouldShowPlayerMetadata()) {
249+ metadataScrim.isVisible = false
250+ metadataVisibilityToken++
251+ return
252+ }
253+
254+ if (isLayout(PHONE )) {
255+ metadataScrim.isVisible = false
256+ metadataVisibilityToken++
257+ return
258+ }
259+
260+ val isPaused = currentPlayerStatus == CSPlayerLoading .IsPaused
261+ val token = ++ metadataVisibilityToken
262+
263+ if (isPaused) {
264+ metadataScrim.postDelayed({
265+ if (token != metadataVisibilityToken) return @postDelayed
266+ metadataScrim.alpha = 0f
267+ metadataScrim.isVisible = true
268+ metadataScrim.animate()
269+ .alpha(1f )
270+ .setDuration(500L )
271+ .setInterpolator(DecelerateInterpolator ())
272+ .start()
273+ hidePlayerUI()
274+ }, 8000L )
275+ } else {
276+ if (metadataScrim.isVisible) {
277+ metadataScrim.animate()
278+ .alpha(0f )
279+ .setDuration(300L )
280+ .setInterpolator(AccelerateDecelerateInterpolator ())
281+ .withEndAction {
282+ metadataScrim.alpha = 0f // force final state
283+ metadataScrim.isVisible = false
284+ }
285+ .start()
286+ }
287+ }
288+ }
289+
242290 @SuppressLint(" UnsafeOptInUsageError" )
243291 override fun playerUpdated (player : Any? ) {
244292 super .playerUpdated(player)
@@ -456,6 +504,12 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
456504 start()
457505 }
458506 }
507+ playerBinding?.playerMetadataScrim?.let {
508+ ObjectAnimator .ofFloat(it, " translationY" , 1f ).apply {
509+ duration = 200
510+ start()
511+ }
512+ }
459513
460514 val playerBarMove = if (isShowing) 0f else 50 .toPx.toFloat()
461515 playerBinding?.bottomPlayerBar?.let {
@@ -522,7 +576,7 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
522576 override fun subtitlesChanged () {
523577 val tracks = player.getVideoTracks()
524578 val isBuiltinSubtitles = tracks.currentTextTracks.all { track ->
525- track.sampleMimeType == MimeTypes .APPLICATION_MEDIA3_CUES
579+ track.sampleMimeType == MimeTypes .APPLICATION_MEDIA3_CUES
526580 }
527581 // Subtitle offset is not possible on built-in media3 tracks
528582 playerBinding?.playerSubtitleOffsetBtt?.isGone =
@@ -1013,7 +1067,6 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
10131067 // BOTTOM
10141068 playerLockHolder.startAnimation(fadeAnimation)
10151069 // player_go_back_holder?.startAnimation(fadeAnimation)
1016-
10171070 shadowOverlay.isVisible = true
10181071 shadowOverlay.startAnimation(fadeAnimation)
10191072 }
@@ -1084,6 +1137,7 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
10841137
10851138 override fun playerStatusChanged () {
10861139 super .playerStatusChanged()
1140+ scheduleMetadataVisibility()
10871141 delayHide()
10881142 }
10891143
@@ -2177,6 +2231,12 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
21772231 }
21782232
21792233 protected fun uiReset () {
2234+ metadataVisibilityToken++
2235+ playerBinding?.playerMetadataScrim?.let {
2236+ it.animate().cancel()
2237+ it.alpha = 0f
2238+ it.isVisible = false
2239+ }
21802240 isShowing = false
21812241 toggleEpisodesOverlay(false )
21822242 // if nothing has loaded these buttons should not be visible
0 commit comments