fix: handle buffering state in playback state management as playing
This commit is contained in:
+5
-1
@@ -24,15 +24,19 @@ internal class AndroidAudioPlayer(
|
||||
init {
|
||||
player.addListener(
|
||||
object : Player.Listener {
|
||||
var isBuffering = false
|
||||
|
||||
override fun onPlaybackStateChanged(playbackState: Int) {
|
||||
if (playbackState == Player.STATE_ENDED) {
|
||||
_playbackState.value = PlaybackState.ENDED
|
||||
}
|
||||
|
||||
isBuffering = playbackState == Player.STATE_BUFFERING
|
||||
}
|
||||
|
||||
override fun onIsPlayingChanged(isPlaying: Boolean) {
|
||||
_playbackState.value = when {
|
||||
isPlaying -> PlaybackState.PLAYING
|
||||
isPlaying || isBuffering -> PlaybackState.PLAYING
|
||||
player.playbackState == Player.STATE_ENDED -> PlaybackState.ENDED
|
||||
else -> PlaybackState.PAUSED
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user