Merge pull request #1181 from Bnyro/master

fix deprecation
This commit is contained in:
Bnyro 2022-08-27 11:56:32 +02:00 committed by GitHub
commit 966405e922
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1100,18 +1100,14 @@ class PlayerFragment : BaseFragment() {
} }
} }
@Deprecated(message = "Deprecated", level = DeprecationLevel.HIDDEN) override fun onPlaybackStateChanged(playbackState: Int) {
override fun onPlayerStateChanged(
playWhenReady: Boolean,
playbackState: Int
) {
exoPlayerView.keepScreenOn = !( exoPlayerView.keepScreenOn = !(
playbackState == Player.STATE_IDLE || playbackState == Player.STATE_IDLE ||
playbackState == Player.STATE_ENDED || playbackState == Player.STATE_ENDED
!playWhenReady
) )
// check if video has ended, next video is available and autoplay is enabled. // check if video has ended, next video is available and autoplay is enabled.
@Suppress("DEPRECATION")
if ( if (
playbackState == Player.STATE_ENDED && playbackState == Player.STATE_ENDED &&
nextStreamId != null && nextStreamId != null &&
@ -1123,19 +1119,21 @@ class PlayerFragment : BaseFragment() {
if (autoplayEnabled) playNextVideo() if (autoplayEnabled) playNextVideo()
} }
if (playWhenReady && playbackState == Player.STATE_READY) { if (playbackState == Player.STATE_READY) {
// media actually playing // media actually playing
transitioning = false transitioning = false
binding.playImageView.setImageResource(R.drawable.ic_pause) binding.playImageView.setImageResource(R.drawable.ic_pause)
} else if (playWhenReady) {
// might be idle (plays after prepare()),
// buffering (plays when data available)
// or ended (plays when seek away from end)
binding.playImageView.setImageResource(R.drawable.ic_play)
} else { } else {
// player paused in any state // player paused in any state
binding.playImageView.setImageResource(R.drawable.ic_play) binding.playImageView.setImageResource(R.drawable.ic_play)
} }
// listen for the stop button in the notification
if (playbackState == PlaybackState.STATE_STOPPED) {
// finish PiP by finishing the activity
activity?.finish()
}
super.onPlaybackStateChanged(playbackState)
} }
}) })
@ -1191,6 +1189,7 @@ class PlayerFragment : BaseFragment() {
Html.fromHtml(description, Html.FROM_HTML_MODE_COMPACT) Html.fromHtml(description, Html.FROM_HTML_MODE_COMPACT)
.trim() .trim()
} else { } else {
@Suppress("DEPRECATION")
Html.fromHtml(description).trim() Html.fromHtml(description).trim()
} }
} else { } else {