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 onPlayerStateChanged(
playWhenReady: Boolean,
playbackState: Int
) {
override fun onPlaybackStateChanged(playbackState: Int) {
exoPlayerView.keepScreenOn = !(
playbackState == Player.STATE_IDLE ||
playbackState == Player.STATE_ENDED ||
!playWhenReady
playbackState == Player.STATE_ENDED
)
// check if video has ended, next video is available and autoplay is enabled.
@Suppress("DEPRECATION")
if (
playbackState == Player.STATE_ENDED &&
nextStreamId != null &&
@ -1123,19 +1119,21 @@ class PlayerFragment : BaseFragment() {
if (autoplayEnabled) playNextVideo()
}
if (playWhenReady && playbackState == Player.STATE_READY) {
if (playbackState == Player.STATE_READY) {
// media actually playing
transitioning = false
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 {
// player paused in any state
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)
.trim()
} else {
@Suppress("DEPRECATION")
Html.fromHtml(description).trim()
}
} else {