|
player.setOnErrorListener(this); |
I had a problem when I was playing a long audio URL, for example, after 800 seconds, I had an error because the data was not buffered. It seems to me that this hook solves this problem
player.setOnBufferingUpdateListener(object : MediaPlayer.OnBufferingUpdateListener {
override fun onBufferingUpdate(mp: MediaPlayer?, percent: Int) {
if (shouldSeekTo > 0) {
mp?.let {
val duration = it.duration
val startFromInPercentage = ((shouldSeekTo * 100) / duration)
Log.d("WrappedMediaPlayer", "onBufferingUpdate: $percent\trequired: $startFromInPercentage")
if (percent > startFromInPercentage) {
if (!it.isPlaying) {
mp.start()
ref.handleIsPlaying()
playing = true
}
it.seekTo(shouldSeekTo)
shouldSeekTo = -1
} else {
if (it.isPlaying) {
it.pause()
playing = false
}
}
}
}
}
})
flutter_audioplayers/android/src/main/java/xyz/luan/audioplayers/WrappedMediaPlayer.java
Line 231 in f8ef363
I had a problem when I was playing a long audio URL, for example, after 800 seconds, I had an error because the data was not buffered. It seems to me that this hook solves this problem