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