From 4de1408ba612bf88b9d3d254d83913a9da652450 Mon Sep 17 00:00:00 2001 From: Ivan Agosto Date: Fri, 9 Aug 2024 15:13:09 -0600 Subject: [PATCH] Fix player stucks on resume player --- .../org/libre/agosto/p2play/ReproductorActivity.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/libre/agosto/p2play/ReproductorActivity.kt b/app/src/main/java/org/libre/agosto/p2play/ReproductorActivity.kt index d55d1b1..fe28cba 100644 --- a/app/src/main/java/org/libre/agosto/p2play/ReproductorActivity.kt +++ b/app/src/main/java/org/libre/agosto/p2play/ReproductorActivity.kt @@ -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() {