1
0
mirror of https://gitlab.com/agosto182/p2play synced 2024-12-30 10:50:57 +01:00

Fix player stucks on resume player

This commit is contained in:
Ivan Agosto 2024-08-09 15:13:09 -06:00
parent 48eec0dc88
commit 4de1408ba6

View File

@ -149,7 +149,7 @@ class ReproductorActivity : AppCompatActivity() {
runOnUiThread {
try {
if (PlaybackSingleton.player == null || !PlaybackSingleton.player!!.playWhenReady) {
if (PlaybackSingleton.player == null || !PlaybackSingleton.player!!.isPlaying) {
PlaybackSingleton.player = ExoPlayer.Builder(this)
//.setSeekBackIncrementMs(10000)
//.setSeekForwardIncrementMs(10000)
@ -160,7 +160,6 @@ class ReproductorActivity : AppCompatActivity() {
player = PlaybackSingleton.player!!
binding.exoPlayer.player = player
binding.exoPlayer
player.addListener(
object : Player.Listener {
override fun onPlaybackStateChanged(playbackState: Int) {
@ -175,9 +174,6 @@ class ReproductorActivity : AppCompatActivity() {
}
)
println("----- video --------")
println(videoPlayback.streamingData?.playlistUrl)
if (!isResume) {
val mediaItem = MediaItem.Builder()
.setUri(videoPlayback.streamingData?.playlistUrl!!)
@ -192,7 +188,7 @@ class ReproductorActivity : AppCompatActivity() {
}
// Start the playback.
// TODO: Setting for autoplay
// player.play()
player.playWhenReady = true
} catch (err: Exception) {
err.printStackTrace()
}
@ -359,6 +355,10 @@ class ReproductorActivity : AppCompatActivity() {
} else {
binding.commentBox.commentaryLayout.visibility = View.GONE
}
if (::player.isInitialized && !player.isPlaying) {
binding.exoPlayer.onResume()
}
}
private fun getDescription() {